Skip to content

Commit

Permalink
Redoing fix done in 1559683
Browse files Browse the repository at this point in the history
Adding more test cleanup to try and solve build issues.
  • Loading branch information
markstory committed Sep 23, 2011
1 parent eccc05d commit 36928d3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
41 changes: 40 additions & 1 deletion lib/Cake/Test/Case/Utility/FolderTest.php
Expand Up @@ -26,6 +26,45 @@
*/
class FolderTest extends CakeTestCase {

protected static $_tmp = array();

/**
* Save the directory names in TMP
*
* @return void
*/
public static function setUpBeforeClass() {
foreach (scandir(TMP) as $file) {
if (is_dir(TMP . $file) && !in_array($file, array('.', '..'))) {
self::$_tmp[] = $file;
}
}
}

/**
* setUp clearstatcache() to flush file descriptors.
*
* @return void
*/
public function setUp() {
parent::setUp();
clearstatcache();
}

/**
* Restore the TMP directory to its original state.
*
* @return void
*/
public function tearDown() {
$exclude = array_merge(self::$_tmp, array('.', '..'));
foreach (scandir(TMP) as $file) {
if (is_dir(TMP . $file) && !in_array($file, $exclude)) {
unlink(TMP . $file);
}
}
}

/**
* testBasic method
*
Expand Down Expand Up @@ -261,7 +300,7 @@ public function testZeroAsDirectory() {
$expected = array('0', 'cache', 'logs', 'sessions', 'tests');
$this->assertEqual($expected, $result[0]);

$result = $Folder->read(true, array('.', '..', 'logs', '.svn'));
$result = $Folder->read(true, array('logs'));
$expected = array('0', 'cache', 'sessions', 'tests');
$this->assertEqual($expected, $result[0]);

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Utility/Folder.php
Expand Up @@ -415,7 +415,7 @@ public function tree($path = null, $exceptions = true, $type = null) {
}
if ($item->isFile()) {
$files[] = $item->getPathName();
} else if ($item->isDir()) {
} else if ($item->isDir() && !in_array($name, array('.', '..'))) {
$directories[] = $item->getPathName();
}
}
Expand Down

0 comments on commit 36928d3

Please sign in to comment.