123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- class SimpleCollector {
-
- function _removeTrailingSlash($path) {
- if (substr($path, -1) == DIRECTORY_SEPARATOR) {
- return substr($path, 0, -1);
- } elseif (substr($path, -1) == '/') {
- return substr($path, 0, -1);
- } else {
- return $path;
- }
- }
-
- function collect(&$test, $path) {
- $path = $this->_removeTrailingSlash($path);
- if ($handle = opendir($path)) {
- while (($entry = readdir($handle)) !== false) {
- if ($this->_isHidden($entry)) {
- continue;
- }
- $this->_handle($test, $path . DIRECTORY_SEPARATOR . $entry);
- }
- closedir($handle);
- }
- }
-
- function _handle(&$test, $file) {
- if (is_dir($file)) {
- return;
- }
- $test->addTestFile($file);
- }
-
- function _isHidden($filename) {
- return strncmp($filename, '.', 1) == 0;
- }
- }
- class SimplePatternCollector extends SimpleCollector {
- var $_pattern;
-
- function SimplePatternCollector($pattern = '/php$/i') {
- $this->_pattern = $pattern;
- }
-
- function _handle(&$test, $filename) {
- if (preg_match($this->_pattern, $filename)) {
- parent::_handle($test, $filename);
- }
- }
- }
- ?>
|