Skip to content

Commit

Permalink
Merge branch '6.5' into 7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Sep 7, 2018
2 parents f15275f + b812332 commit 3b09dbd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/Runner/Filter/NameFilterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -70,7 +70,7 @@ public function accept(): bool
$accepted = $set >= $this->filterMin && $set <= $this->filterMax;
}

return $accepted;
return (bool) $accepted;
}

/**
Expand Down
24 changes: 10 additions & 14 deletions tests/unit/Runner/Filter/NameFilterIteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,28 @@
namespace PHPUnit\Runner\Filter;

use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\TestSuiteIterator;
use PHPUnit\Framework\TestSuite;

class NameFilterIteratorTest extends TestCase
{
public function testCaseSensitiveMatch()
{
$iterator = $this->getTestSuiteIteratorMock();
$filter = new NameFilterIterator($iterator, 'Success');
$this->assertTrue((bool) $filter->accept());
$this->assertTrue($this->createFilter('BankAccountTest')->accept());
}

public function testCaseInsensitiveMatch()
{
$iterator = $this->getTestSuiteIteratorMock();
$filter = new NameFilterIterator($iterator, 'success');
$this->assertTrue((bool) $filter->accept());
$this->assertTrue($this->createFilter('bankaccounttest')->accept());
}

/**
* @return TestSuiteIterator
*/
private function getTestSuiteIteratorMock()
private function createFilter(string $filter): NameFilterIterator
{
$success = new \Success();
$iterator = $this->createMock(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;
}
Expand Down

0 comments on commit 3b09dbd

Please sign in to comment.