diff --git a/composer.json b/composer.json index cae97e22..795e272b 100644 --- a/composer.json +++ b/composer.json @@ -40,22 +40,22 @@ "ext-simplexml": "*", "fidry/cpu-core-counter": "^0.4.1 || ^0.5.1", "jean85/pretty-package-versions": "^2.0.5", - "phpunit/php-code-coverage": "^9.2.24", + "phpunit/php-code-coverage": "^9.2.25", "phpunit/php-file-iterator": "^3.0.6", "phpunit/php-timer": "^5.0.3", - "phpunit/phpunit": "^9.6.3", - "sebastian/environment": "^5.1.4", - "symfony/console": "^5.4.16 || ^6.2.5", - "symfony/process": "^5.4.11 || ^6.2.5" + "phpunit/phpunit": "^9.6.4", + "sebastian/environment": "^5.1.5", + "symfony/console": "^5.4.21 || ^6.2.7", + "symfony/process": "^5.4.21 || ^6.2.7" }, "require-dev": { "ext-pcov": "*", "ext-posix": "*", "doctrine/coding-standard": "^10.0.0", "infection/infection": "^0.26.19", - "squizlabs/php_codesniffer": "^3.7.1", - "symfony/filesystem": "^5.4.13 || ^6.2.5", - "vimeo/psalm": "^5.6" + "squizlabs/php_codesniffer": "^3.7.2", + "symfony/filesystem": "^5.4.21 || ^6.2.7", + "vimeo/psalm": "^5.7.7" }, "autoload": { "psr-4": { diff --git a/src/Runners/PHPUnit/ResultPrinter.php b/src/Runners/PHPUnit/ResultPrinter.php index 7721ffe2..98b21075 100644 --- a/src/Runners/PHPUnit/ResultPrinter.php +++ b/src/Runners/PHPUnit/ResultPrinter.php @@ -39,6 +39,7 @@ use function get_class; use function implode; use function is_array; +use function is_string; use function max; use function preg_split; use function rtrim; @@ -687,13 +688,17 @@ private function processTestdoxReader(TestSuite $testSuite): void $prettifier = new NamePrettifier(false); - $class = $testSuite->name; - assert(class_exists($class)); + $separator = PHP_EOL; + foreach ($testSuite->cases as $index => $case) { + if ($index === 0) { + $class = $case->class; + assert(class_exists($class)); + + $this->output->writeln($prettifier->prettifyTestClass($class)); + } - $this->output->writeln($prettifier->prettifyTestClass($class)); + assert(isset($class) && is_string($class) && class_exists($class)); - $separator = PHP_EOL; - foreach ($testSuite->cases as $case) { $separator = PHP_EOL; $testCase = new $class($case->name); assert($testCase instanceof TestCase); diff --git a/test/Unit/Runners/PHPUnit/RunnerTestCase.php b/test/Unit/Runners/PHPUnit/RunnerTestCase.php index 75390f19..18e55d3f 100644 --- a/test/Unit/Runners/PHPUnit/RunnerTestCase.php +++ b/test/Unit/Runners/PHPUnit/RunnerTestCase.php @@ -533,6 +533,19 @@ final public function testRunnerReversed(): void static::assertSame($defaultOrder, $reverseOrderReversed); } + final public function testTestdoxAndDataProvider(): void + { + $this->bareOptions['--path'] = $this->fixture('testdox_dataprovider'); + $this->bareOptions['--testdox'] = true; + + $runnerResult = $this->runRunner(); + + $output = $runnerResult->getOutput(); + static::assertStringContainsString('✔ Trim with data set "leading space is trimmed"', $output); + static::assertStringContainsString('✔ Trim with data set "trailing space and newline are trimmed"', $output); + static::assertStringContainsString('OK (2 tests, 2 assertions)', $output); + } + /** @return string[] */ private function prepareOutputForTestOrderCheck(string $output): array { diff --git a/test/fixtures/testdox_dataprovider/TestdoxDataProviderTest.php b/test/fixtures/testdox_dataprovider/TestdoxDataProviderTest.php new file mode 100644 index 00000000..a68f2314 --- /dev/null +++ b/test/fixtures/testdox_dataprovider/TestdoxDataProviderTest.php @@ -0,0 +1,33 @@ +> */ + public function provideTrimData(): array + { + return [ + 'leading space is trimmed' => [ + 'Hello World', + ' Hello World', + ], + 'trailing space and newline are trimmed' => [ + 'Hello World', + "Hello World \n", + ], + ]; + } +}