Skip to content

Commit

Permalink
Make filtered event give only filtered results. Test added that cover…
Browse files Browse the repository at this point in the history
…s this case.
  • Loading branch information
marac19901990 authored and sebastianbergmann committed Jan 7, 2024
1 parent 13087a8 commit 38b30cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Event/Value/TestSuite/TestSuiteBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
15 changes: 15 additions & 0 deletions tests/unit/Event/Value/TestSuite/TestSuiteBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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]);
Expand Down

0 comments on commit 38b30cf

Please sign in to comment.