Skip to content

Commit

Permalink
Make --filter case insensitive - issue #3181
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Feldmann authored and sebastianbergmann committed Sep 7, 2018
1 parent 2c73693 commit 7c39e56
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog-6.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes of the PHPUnit 6.5 release series are documented in this fil
## [6.5.13] - 2018-MM-DD

* Fixed [#3254](https://github.com/sebastianbergmann/phpunit/issues/3254): TextUI test runner cannot run a `Test` instance that is not a `TestSuite`
* Fixed [#3181](https://github.com/sebastianbergmann/phpunit/issues/3181): Make --filter case insensitive

## [6.5.12] - 2018-08-22

Expand Down
2 changes: 1 addition & 1 deletion src/Runner/Filter/NameFilterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected function setFilter($filter)

// Escape delimiters in regular expression. Do NOT use preg_quote,
// to keep magic characters.
$filter = \sprintf('/%s/', \str_replace(
$filter = \sprintf('/%s/i', \str_replace(
'/',
'\\/',
$filter
Expand Down
41 changes: 41 additions & 0 deletions tests/unit/Runner/Filter/NameFilterIteratorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Runner\Filter;

use PHPUnit\Framework\TestCase;

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

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

/**
* @return \PHPUnit\Framework\TestSuiteIterator
*/
private function getTestSuiteItteratorMock()
{
$success = new \Success();
$iterator = $this->createMock(\PHPUnit\Framework\TestSuiteIterator::class);
$iterator->expects($this->once())->method('current')->willReturn($success);

return $iterator;
}
}

0 comments on commit 7c39e56

Please sign in to comment.