diff --git a/src/TUnit/util/PhpFileIterator.php b/src/TUnit/util/PhpFileIterator.php index d9a7b4a..8c1bc1a 100644 --- a/src/TUnit/util/PhpFileIterator.php +++ b/src/TUnit/util/PhpFileIterator.php @@ -32,6 +32,19 @@ parent::__construct(new RecursiveDirectoryIterator($dir)); } + /** + * Gets the children for the inner iterator + * + * @author Tommy Montgomery + * @version 1.0 + * @since 1.0 + * + * @return RecursivePhpFileIterator + */ + public function getChildren() { + return new self($this->current()->getPathName()); + } + /** * Defines acceptance criteria for iteration * @@ -43,9 +56,12 @@ */ public function accept() { return - !$this->getInnerIterator()->isDot() && - strpos($this->current()->getPathName(), DIRECTORY_SEPARATOR . '.') === false && - substr($this->current()->getFileName(), -4) === '.php'; + strpos($this->current()->getPathName(), DIRECTORY_SEPARATOR . '.') === false && ( + $this->current()->isDir() || ( + !$this->getInnerIterator()->isDot() && + substr($this->current()->getFileName(), -4) === '.php' + ) + ); } } diff --git a/src/TUnit/util/TestAccumulator.php b/src/TUnit/util/TestAccumulator.php index d20485c..231bf1d 100644 --- a/src/TUnit/util/TestAccumulator.php +++ b/src/TUnit/util/TestAccumulator.php @@ -60,7 +60,7 @@ * @return array */ public static function getTestsFromDir($dir, $recursive = true) { - $iterator = ($recursive) ? new RecursivePhpFileIterator($dir) : new PhpFileIterator($dir); + $iterator = ($recursive) ? new RecursiveIteratorIterator(new RecursivePhpFileIterator($dir)) : new PhpFileIterator($dir); $tests = array(); foreach ($iterator as $file) {