Skip to content

Commit

Permalink
Merge branch '7.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Sep 7, 2018
2 parents 0dcbb02 + 3b09dbd commit 44970ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 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
23 changes: 10 additions & 13 deletions tests/unit/Runner/Filter/NameFilterIteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 44970ca

Please sign in to comment.