Skip to content

Commit 9fd51fd

Browse files
Refactor
1 parent e174340 commit 9fd51fd

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

src/TextUI/TestRunner.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use function mt_srand;
1313
use PHPUnit\Event;
1414
use PHPUnit\Framework\TestSuite;
15-
use PHPUnit\Runner\Filter\Factory;
1615
use PHPUnit\Runner\ResultCache\ResultCache;
1716
use PHPUnit\Runner\TestSuiteSorter;
1817
use PHPUnit\TextUI\Configuration\Configuration;
@@ -54,7 +53,7 @@ public function run(Configuration $configuration, ResultCache $resultCache, Test
5453
);
5554
}
5655

57-
(new TestSuiteFilterProcessor(new Factory))->process($configuration, $suite);
56+
(new TestSuiteFilterProcessor)->process($configuration, $suite);
5857

5958
Event\Facade::emitter()->testRunnerExecutionStarted(
6059
Event\TestSuite\TestSuiteBuilder::from($suite),

src/TextUI/TestSuiteFilterProcessor.php

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,14 @@
2121
*/
2222
final class TestSuiteFilterProcessor
2323
{
24-
private Factory $filterFactory;
25-
26-
public function __construct(Factory $factory = new Factory)
27-
{
28-
$this->filterFactory = $factory;
29-
}
30-
3124
/**
3225
* @throws Event\RuntimeException
3326
* @throws FilterNotConfiguredException
3427
*/
3528
public function process(Configuration $configuration, TestSuite $suite): void
3629
{
30+
$factory = new Factory;
31+
3732
if (!$configuration->hasFilter() &&
3833
!$configuration->hasGroups() &&
3934
!$configuration->hasExcludeGroups() &&
@@ -43,19 +38,19 @@ public function process(Configuration $configuration, TestSuite $suite): void
4338
}
4439

4540
if ($configuration->hasExcludeGroups()) {
46-
$this->filterFactory->addExcludeGroupFilter(
41+
$factory->addExcludeGroupFilter(
4742
$configuration->excludeGroups(),
4843
);
4944
}
5045

5146
if ($configuration->hasGroups()) {
52-
$this->filterFactory->addIncludeGroupFilter(
47+
$factory->addIncludeGroupFilter(
5348
$configuration->groups(),
5449
);
5550
}
5651

5752
if ($configuration->hasTestsCovering()) {
58-
$this->filterFactory->addIncludeGroupFilter(
53+
$factory->addIncludeGroupFilter(
5954
array_map(
6055
static fn (string $name): string => '__phpunit_covers_' . $name,
6156
$configuration->testsCovering(),
@@ -64,7 +59,7 @@ public function process(Configuration $configuration, TestSuite $suite): void
6459
}
6560

6661
if ($configuration->hasTestsUsing()) {
67-
$this->filterFactory->addIncludeGroupFilter(
62+
$factory->addIncludeGroupFilter(
6863
array_map(
6964
static fn (string $name): string => '__phpunit_uses_' . $name,
7065
$configuration->testsUsing(),
@@ -73,12 +68,12 @@ public function process(Configuration $configuration, TestSuite $suite): void
7368
}
7469

7570
if ($configuration->hasFilter()) {
76-
$this->filterFactory->addNameFilter(
71+
$factory->addNameFilter(
7772
$configuration->filter(),
7873
);
7974
}
8075

81-
$suite->injectFilter($this->filterFactory);
76+
$suite->injectFilter($factory);
8277

8378
Event\Facade::emitter()->testSuiteFiltered(
8479
Event\TestSuite\TestSuiteBuilder::from($suite),

0 commit comments

Comments
 (0)