3
* This file is part of PHPUnit.
5
* (c) Sebastian Bergmann <sebastian@phpunit.de>
7
* For the full copyright and license information, please view the LICENSE
8
* file that was distributed with this source code.
14
* @author Sebastian Bergmann <sebastian@phpunit.de>
15
* @copyright Sebastian Bergmann <sebastian@phpunit.de>
16
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
17
* @link http://www.phpunit.de/
18
* @since Class available since Release 4.0.0
20
class PHPUnit_Runner_Filter_Test extends RecursiveFilterIterator
25
protected $filter = null;
37
* @param RecursiveIterator $iterator
38
* @param string $filter
40
public function __construct(RecursiveIterator $iterator, $filter)
42
parent::__construct($iterator);
43
$this->setFilter($filter);
47
* @param string $filter
49
protected function setFilter($filter)
51
if (PHPUnit_Util_Regex::pregMatchSafe($filter, '') === false) {
53
// * testAssertEqualsSucceeds#4
54
// * testAssertEqualsSucceeds#4-8
55
if (preg_match('/^(.*?)#(\d+)(?:-(\d+))?$/', $filter, $matches)) {
56
if (isset($matches[3]) && $matches[2] < $matches[3]) {
58
'%s.*with data set #(\d+)$',
62
$this->filterMin = $matches[2];
63
$this->filterMax = $matches[3];
66
'%s.*with data set #%s$',
72
// * testDetermineJsonError@JSON_ERROR_NONE
73
// * testDetermineJsonError@JSON.*
74
elseif (preg_match('/^(.*?)@(.+)$/', $filter, $matches)) {
76
'%s.*with data set "%s"$',
82
// Escape delimiters in regular expression. Do NOT use preg_quote,
83
// to keep magic characters.
84
$filter = sprintf('/%s/', str_replace(
89
$this->filter = $filter;
95
public function accept()
97
$test = $this->getInnerIterator()->current();
99
if ($test instanceof PHPUnit_Framework_TestSuite) {
103
$tmp = PHPUnit_Util_Test::describe($test, false);
106
$name = join('::', $tmp);
111
$accepted = preg_match($this->filter, $name, $matches);
113
if ($accepted && isset($this->filterMax)) {
114
$set = end($matches);
115
$accepted = $set >= $this->filterMin && $set <= $this->filterMax;