Skip to content

Commit

Permalink
Improved regular expression for data-sets when functional flag is use…
Browse files Browse the repository at this point in the history
…d. (#914)

Co-authored-by: Tommy Seus <[email protected]>
  • Loading branch information
tommyseus and tommyseus-iw24 authored Dec 5, 2024
1 parent fcda4be commit 9ac8eda
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/WrapperRunner/SuiteLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use function mt_srand;
use function ob_get_clean;
use function ob_start;
use function preg_quote;
use function sprintf;
use function str_starts_with;
use function strlen;
Expand Down Expand Up @@ -87,7 +88,7 @@ public function __construct(
if ($test->providedData() !== []) {
$dataName = $test->dataName();
if ($this->options->functional) {
$name = sprintf('/%s\s.*%s.*$/', $name, $dataName);
$name = sprintf('/%s%s$/', preg_quote($name, '/'), preg_quote($test->dataSetAsString(), '/'));
} else {
if (is_int($dataName)) {
$name .= '#' . $dataName;
Expand Down
10 changes: 5 additions & 5 deletions test/Unit/WrapperRunner/WrapperRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ public function testGroupOptionWithDataProviderAndCodeCoverageEnabled(): void
* @see https://bugs.php.net/bug.php?id=77726
* @see https://github.com/php/php-src/pull/8114
*/
#[RequiresPhp('8.2')]
#[RequiresPhp('>=8.2')]
public function testFunctionalParallelization(): void
{
$this->bareOptions['path'] = $this->fixture('function_parallelization_tests');
Expand All @@ -643,7 +643,7 @@ public function testFunctionalParallelization(): void
Processes: 2
Runtime: PHP %s
.......... 10 / 10 (100%)
.................... 20 / 20 (100%)
Time: %s, Memory: %s MB
Expand All @@ -653,7 +653,7 @@ public function testFunctionalParallelization(): void
self::assertSame(RunnerInterface::SUCCESS_EXIT, $runnerResult->exitCode);
}

#[RequiresPhp('8.2')]
#[RequiresPhp('>=8.2')]
public function testSameBeginningOfName(): void
{
$this->bareOptions['path'] = $this->fixture('same_beginning_of_name');
Expand All @@ -675,7 +675,7 @@ public function testSameBeginningOfName(): void
self::assertSame(RunnerInterface::SUCCESS_EXIT, $runnerResult->exitCode);
}

#[RequiresPhp('8.2')]
#[RequiresPhp('>=8.2')]
public function testFunctionalParallelizationWithJunitLogging(): void
{
$outputFile = $this->tmpDir . DIRECTORY_SEPARATOR . 'test-output.xml';
Expand All @@ -692,7 +692,7 @@ public function testFunctionalParallelizationWithJunitLogging(): void
Processes: 1
Runtime: PHP %s
.......... 10 / 10 (100%)
.................... 20 / 20 (100%)
Time: %s, Memory: %s MB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ public static function dataProvider1(): array
['a', 'a'],
['b', 'b'],
['c', 'c'],
['d', 'd'],
['e', 'e'],
['f', 'f'],
['g', 'g'],
['h', 'h'],
['i', 'i'],
['k', 'k'],
['l', 'l'],
];
}

Expand All @@ -27,6 +35,7 @@ public static function dataProvider2(): array
'test1 with spaces' => ['a', 'a'],
"test2 with \0" => ['b', 'b'],
'test3' => ['c', 'c'],
'Test\\Class\\Name' => ['d', 'd'],
];
}

Expand Down

0 comments on commit 9ac8eda

Please sign in to comment.