Skip to content

Commit 31bd807

Browse files
bug symfony#58828 [PhpUnitBridge] fix dumping tests to skip with data providers (xabbuh)
This PR was merged into the 5.4 branch. Discussion ---------- [PhpUnitBridge] fix dumping tests to skip with data providers | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | | License | MIT Without the fix running `SYMFONY_PHPUNIT_SKIPPED_TESTS='phpunit.skipped' php ./phpunit src/Symfony/Component/Lock/Tests/Store/DoctrineDbalPostgreSqlStoreTest.php` without the `pdo_pgsql` extension enabled the generated skip file looked like this: ``` <?php return array ( 'PHPUnit\\Framework\\DataProviderTestSuite' => array ( 'Symfony\\Component\\Lock\\Tests\\Store\\DoctrineDbalPostgreSqlStoreTest::testInvalidDriver' => 1, ), 'Symfony\\Component\\Lock\\Tests\\Store\\DoctrineDbalPostgreSqlStoreTest' => array ( 'testSaveAfterConflict' => 1, 'testWaitAndSaveAfterConflictReleasesLockFromInternalStore' => 1, 'testWaitAndSaveReadAfterConflictReleasesLockFromInternalStore' => 1, 'testSave' => 1, 'testSaveWithDifferentResources' => 1, 'testSaveWithDifferentKeysOnSameResources' => 1, 'testSaveTwice' => 1, 'testDeleteIsolated' => 1, 'testBlockingLocks' => 1, 'testSharedLockReadFirst' => 1, 'testSharedLockWriteFirst' => 1, 'testSharedLockPromote' => 1, 'testSharedLockPromoteAllowed' => 1, 'testSharedLockDemote' => 1, ), ); ``` Thus, running the tests again with the extension enabled would only run 14 tests instead of the expected total number of 16 tests. With the patch applied the generated skip file looks like this: ``` <?php return array ( 'Symfony\\Component\\Lock\\Tests\\Store\\DoctrineDbalPostgreSqlStoreTest' => array ( 'testInvalidDriver with data set #0' => 1, 'testInvalidDriver with data set #1' => 1, 'testSaveAfterConflict' => 1, 'testWaitAndSaveAfterConflictReleasesLockFromInternalStore' => 1, 'testWaitAndSaveReadAfterConflictReleasesLockFromInternalStore' => 1, 'testSave' => 1, 'testSaveWithDifferentResources' => 1, 'testSaveWithDifferentKeysOnSameResources' => 1, 'testSaveTwice' => 1, 'testDeleteIsolated' => 1, 'testBlockingLocks' => 1, 'testSharedLockReadFirst' => 1, 'testSharedLockWriteFirst' => 1, 'testSharedLockPromote' => 1, 'testSharedLockPromoteAllowed' => 1, 'testSharedLockDemote' => 1, ), ); ``` Commits ------- 95f41cc fix dumping tests to skip with data providers
2 parents 16087db + 95f41cc commit 31bd807

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Doctrine\Common\Annotations\AnnotationRegistry;
1515
use PHPUnit\Framework\AssertionFailedError;
16+
use PHPUnit\Framework\DataProviderTestSuite;
1617
use PHPUnit\Framework\RiskyTestError;
1718
use PHPUnit\Framework\TestCase;
1819
use PHPUnit\Framework\TestSuite;
@@ -196,7 +197,13 @@ public function startTestSuite($suite)
196197
public function addSkippedTest($test, \Exception $e, $time)
197198
{
198199
if (0 < $this->state) {
199-
$this->isSkipped[\get_class($test)][$test->getName()] = 1;
200+
if ($test instanceof DataProviderTestSuite) {
201+
foreach ($test->tests() as $testWithDataProvider) {
202+
$this->isSkipped[\get_class($testWithDataProvider)][$testWithDataProvider->getName()] = 1;
203+
}
204+
} else {
205+
$this->isSkipped[\get_class($test)][$test->getName()] = 1;
206+
}
200207
}
201208
}
202209

0 commit comments

Comments
 (0)