Permalink
Browse files

Using Folder class in CakeTestSuite, this fixes issues where

hidden directories from VCS would be added as test cases.
Fixes #1933
  • Loading branch information...
1 parent 682dc5e commit 02a6883b22d198960fad8fd7584b3a38c579f6a1 @markstory markstory committed Aug 27, 2011
Showing with 14 additions and 21 deletions.
  1. +1 −2 lib/Cake/Test/Case/AllComponentsTest.php
  2. +7 −11 lib/Cake/TestSuite/CakeTestSuite.php
  3. +6 −8 lib/Cake/Utility/Folder.php
@@ -36,8 +36,7 @@ public static function suite() {
$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;
}
}
@@ -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 @@ public function addTestDirectory($directory = '.') {
* @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);
}
}
-}
+}
@@ -384,14 +384,9 @@ public function chmod($path, $mode = false, $recursive = true, $exceptions = arr
* @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 @@ public function tree($path, $exceptions = true, $type = null) {
$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) {

0 comments on commit 02a6883

Please sign in to comment.