diff --git a/src/Event/Value/TestSuite/TestSuiteBuilder.php b/src/Event/Value/TestSuite/TestSuiteBuilder.php index c8988693076..e9688a8f56f 100644 --- a/src/Event/Value/TestSuite/TestSuiteBuilder.php +++ b/src/Event/Value/TestSuite/TestSuiteBuilder.php @@ -107,7 +107,7 @@ public static function from(FrameworkTestSuite $testSuite): TestSuite */ private static function process(FrameworkTestSuite $testSuite, &$tests): void { - foreach ($testSuite->tests() as $test) { + foreach ($testSuite->getIterator() as $test) { if ($test instanceof FrameworkTestSuite) { self::process($test, $tests); diff --git a/tests/unit/Event/Value/TestSuite/TestSuiteBuilderTest.php b/tests/unit/Event/Value/TestSuite/TestSuiteBuilderTest.php index de36fdf7d90..b3885c1fbbe 100644 --- a/tests/unit/Event/Value/TestSuite/TestSuiteBuilderTest.php +++ b/tests/unit/Event/Value/TestSuite/TestSuiteBuilderTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\Attributes\Small; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestSuite as FrameworkTestSuite; +use PHPUnit\Runner\Filter\Factory; use PHPUnit\TextUI\CliArguments\Builder as CliArgumentsBuilder; use PHPUnit\TextUI\Configuration\Merger as ConfigurationMerger; use PHPUnit\TextUI\XmlConfiguration\Loader as XmlConfigurationLoader; @@ -29,9 +30,23 @@ public function test_Builds_TestSuite_value_object_for_test_suite_loaded_from_XM $this->assertTrue($testSuite->isWithName()); $this->assertStringEndsWith('phpunit.xml', $testSuite->name()); $this->assertSame(3, $testSuite->count()); + $this->assertSame(3, $testSuite->tests()->count()); $this->assertCount(3, $testSuite->tests()); } + public function testBuildCountWithFilter() + { + $testSuite = $this->testSuiteFromXmlConfiguration(); + $filterFactory = new Factory(); + $filterFactory->addNameFilter('one'); + $testSuite->injectFilter($filterFactory); + $testSuite = TestSuiteBuilder::from($testSuite); + + $this->assertSame(1, $testSuite->count()); + $this->assertSame(1, $testSuite->tests()->count()); + $this->assertCount(1, $testSuite->tests()); + } + public function test_Builds_TestSuite_value_object_for_test_case_class(): void { $testSuite = TestSuiteBuilder::from($this->testSuiteFromXmlConfiguration()->tests()[0]->tests()[0]);