diff --git a/src/Runner/Filter/NameFilterIterator.php b/src/Runner/Filter/NameFilterIterator.php index e005bd22398..40b02cf82ac 100644 --- a/src/Runner/Filter/NameFilterIterator.php +++ b/src/Runner/Filter/NameFilterIterator.php @@ -51,12 +51,12 @@ public function accept(): bool return true; } - $tmp = Test::describe($test); + $tmp = \PHPUnit\Util\Test::describe($test, false); if ($test instanceof WarningTestCase) { $name = $test->getMessage(); } else { - if ($tmp[0] != '') { + if ($tmp[0] !== '') { $name = \implode('::', $tmp); } else { $name = $tmp[1]; @@ -70,7 +70,7 @@ public function accept(): bool $accepted = $set >= $this->filterMin && $set <= $this->filterMax; } - return $accepted; + return (bool) $accepted; } /** diff --git a/tests/unit/Runner/Filter/NameFilterIteratorTest.php b/tests/unit/Runner/Filter/NameFilterIteratorTest.php index 21d88f537cf..d832851d686 100644 --- a/tests/unit/Runner/Filter/NameFilterIteratorTest.php +++ b/tests/unit/Runner/Filter/NameFilterIteratorTest.php @@ -10,31 +10,28 @@ namespace PHPUnit\Runner\Filter; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\TestSuite; class NameFilterIteratorTest extends TestCase { public function testCaseSensitiveMatch() { - $iterator = $this->getTestSuiteItteratorMock(); - $filter = new NameFilterIterator($iterator, 'Success'); - $this->assertTrue((bool) $filter->accept()); + $this->assertTrue($this->createFilter('BankAccountTest')->accept()); } public function testCaseInsensitiveMatch() { - $iterator = $this->getTestSuiteItteratorMock(); - $filter = new NameFilterIterator($iterator, 'success'); - $this->assertTrue((bool) $filter->accept()); + $this->assertTrue($this->createFilter('bankaccounttest')->accept()); } - /** - * @return \PHPUnit\Framework\TestSuiteIterator - */ - private function getTestSuiteItteratorMock() + private function createFilter(string $filter): NameFilterIterator { - $success = new \Success(); - $iterator = $this->createMock(\PHPUnit\Framework\TestSuiteIterator::class); - $iterator->expects($this->once())->method('current')->willReturn($success); + $suite = new TestSuite; + $suite->addTest(new \BankAccountTest('testBalanceIsInitiallyZero')); + + $iterator = new NameFilterIterator($suite->getIterator(), $filter); + + $iterator->rewind(); return $iterator; }