diff --git a/lib/Cake/Test/Case/AllComponentsTest.php b/lib/Cake/Test/Case/AllComponentsTest.php index f93628417..3b6f5ce03 100644 --- a/lib/Cake/Test/Case/AllComponentsTest.php +++ b/lib/Cake/Test/Case/AllComponentsTest.php @@ -36,8 +36,7 @@ class AllComponentsTest extends PHPUnit_Framework_TestSuite { $suite->addTestFile(CORE_TEST_CASES . DS . 'Controller' . DS . 'ComponentTest.php'); $suite->addTestFile(CORE_TEST_CASES . DS . 'Controller' . DS . 'ComponentCollectionTest.php'); - $suite->addTestDirectory(CORE_TEST_CASES . DS . 'Controller' . DS . 'Component'); - $suite->addTestDirectory(CORE_TEST_CASES . DS . 'Controller' . DS . 'Component' . DS . 'Auth'); + $suite->addTestDirectoryRecursive(CORE_TEST_CASES . DS . 'Controller' . DS . 'Component'); return $suite; } } diff --git a/lib/Cake/TestSuite/CakeTestSuite.php b/lib/Cake/TestSuite/CakeTestSuite.php index 1b121b65c..ea8656155 100644 --- a/lib/Cake/TestSuite/CakeTestSuite.php +++ b/lib/Cake/TestSuite/CakeTestSuite.php @@ -18,6 +18,8 @@ */ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); +App::uses('Folder', 'Utility'); + class CakeTestSuite extends PHPUnit_Framework_TestSuite { /** @@ -27,13 +29,10 @@ class CakeTestSuite extends PHPUnit_Framework_TestSuite { * @return void */ public function addTestDirectory($directory = '.') { - $files = new DirectoryIterator($directory); + $folder = new Folder($directory); + list($dirs, $files) = $folder->read(true, false, true); foreach ($files as $file) { - if (!$file->isFile()) { - continue; - } - $file = $file->getRealPath(); $this->addTestFile($file); } } @@ -45,15 +44,12 @@ class CakeTestSuite extends PHPUnit_Framework_TestSuite { * @return void */ public function addTestDirectoryRecursive($directory = '.') { - $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)); + $folder = new Folder($directory); + $files = $folder->tree(null, false, 'files'); foreach ($files as $file) { - if (!$file->isFile()) { - continue; - } - $file = $file->getRealPath(); $this->addTestFile($file); } } -} \ No newline at end of file +} diff --git a/lib/Cake/Utility/Folder.php b/lib/Cake/Utility/Folder.php index 9614a66da..671ff1e2b 100644 --- a/lib/Cake/Utility/Folder.php +++ b/lib/Cake/Utility/Folder.php @@ -384,14 +384,9 @@ class Folder { * @param string $type either file or dir. null returns both files and directories * @return mixed array of nested directories and files in each directory */ - public function tree($path, $exceptions = true, $type = null) { - $original = $this->path; - $path = rtrim($path, DS); - if (!$this->cd($path)) { - if ($type === null) { - return array(array(), array()); - } - return array(); + public function tree($path = null, $exceptions = true, $type = null) { + if ($path == null) { + $path = $this->path; } $files = array(); $directories = array($path); @@ -408,6 +403,9 @@ class Folder { $directory = new RecursiveDirectoryIterator($path); $iterator = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::SELF_FIRST); } catch (UnexpectedValueException $e) { + if ($type === null) { + return array(array(), array()); + } return array(); } foreach ($iterator as $item) {