X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fphpunit%2Fphpunit%2Fsrc%2FRunner%2FFilter%2FTest.php;fp=vendor%2Fphpunit%2Fphpunit%2Fsrc%2FRunner%2FFilter%2FTest.php;h=bae4a5c91f39453df1609f63bf753a50d8f57e47;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/phpunit/phpunit/src/Runner/Filter/Test.php b/vendor/phpunit/phpunit/src/Runner/Filter/Test.php new file mode 100644 index 000000000..bae4a5c91 --- /dev/null +++ b/vendor/phpunit/phpunit/src/Runner/Filter/Test.php @@ -0,0 +1,116 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * @since Class available since Release 4.0.0 + */ +class PHPUnit_Runner_Filter_Test extends RecursiveFilterIterator +{ + /** + * @var string + */ + protected $filter = null; + + /** + * @var int + */ + protected $filterMin; + /** + * @var int + */ + protected $filterMax; + + /** + * @param RecursiveIterator $iterator + * @param string $filter + */ + public function __construct(RecursiveIterator $iterator, $filter) + { + parent::__construct($iterator); + $this->setFilter($filter); + } + + /** + * @param string $filter + */ + protected function setFilter($filter) + { + if (PHPUnit_Util_Regex::pregMatchSafe($filter, '') === false) { + // Handles: + // * testAssertEqualsSucceeds#4 + // * testAssertEqualsSucceeds#4-8 + if (preg_match('/^(.*?)#(\d+)(?:-(\d+))?$/', $filter, $matches)) { + if (isset($matches[3]) && $matches[2] < $matches[3]) { + $filter = sprintf( + '%s.*with data set #(\d+)$', + $matches[1] + ); + + $this->filterMin = $matches[2]; + $this->filterMax = $matches[3]; + } else { + $filter = sprintf( + '%s.*with data set #%s$', + $matches[1], + $matches[2] + ); + } + } // Handles: + // * testDetermineJsonError@JSON_ERROR_NONE + // * testDetermineJsonError@JSON.* + elseif (preg_match('/^(.*?)@(.+)$/', $filter, $matches)) { + $filter = sprintf( + '%s.*with data set "%s"$', + $matches[1], + $matches[2] + ); + } + + // Escape delimiters in regular expression. Do NOT use preg_quote, + // to keep magic characters. + $filter = sprintf('/%s/', str_replace( + '/', + '\\/', + $filter + )); + } + + $this->filter = $filter; + } + + /** + * @return bool + */ + public function accept() + { + $test = $this->getInnerIterator()->current(); + + if ($test instanceof PHPUnit_Framework_TestSuite) { + return true; + } + + $tmp = PHPUnit_Util_Test::describe($test, false); + + if ($tmp[0] != '') { + $name = implode('::', $tmp); + } else { + $name = $tmp[1]; + } + + $accepted = @preg_match($this->filter, $name, $matches); + + if ($accepted && isset($this->filterMax)) { + $set = end($matches); + $accepted = $set >= $this->filterMin && $set <= $this->filterMax; + } + + return $accepted; + } +}