Adding Folder tests, fixes cases where ordered directory entries were expected

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8100 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
davidpersson 2009-03-15 00:10:53 +00:00
parent ed43e95cf3
commit 70f18af78d

View file

@ -271,13 +271,16 @@ class FolderTest extends CakeTestCase {
);
$result = $Folder->tree(TEST_CAKE_CORE_INCLUDE_PATH . 'config', false);
$this->assertEqual($result, $expected);
$this->assertIdentical(array_diff($expected[0], $result[0]), array());
$this->assertIdentical(array_diff($result[0], $expected[0]), array());
$result = $Folder->tree(TEST_CAKE_CORE_INCLUDE_PATH . 'config', false, 'dir');
$this->assertEqual($result, $expected[0]);
$this->assertIdentical(array_diff($expected[0], $result), array());
$this->assertIdentical(array_diff($result, $expected[0]), array());
$result = $Folder->tree(TEST_CAKE_CORE_INCLUDE_PATH . 'config', false, 'files');
$this->assertEqual($result, $expected[1]);
$this->assertIdentical(array_diff($expected[1], $result), array());
$this->assertIdentical(array_diff($result, $expected[1]), array());
}
/**
* testWindowsPath method
@ -405,10 +408,20 @@ class FolderTest extends CakeTestCase {
$Folder->cd(TEST_CAKE_CORE_INCLUDE_PATH . 'config');
$result = $Folder->find();
$expected = array('config.php', 'paths.php');
$this->assertIdentical(array_diff($expected, $result), array());
$this->assertIdentical(array_diff($result, $expected), array());
$result = $Folder->find('.*', true);
$expected = array('config.php', 'paths.php');
$this->assertIdentical($result, $expected);
$result = $Folder->find('.*\.php');
$expected = array('config.php', 'paths.php');
$this->assertIdentical(array_diff($expected, $result), array());
$this->assertIdentical(array_diff($result, $expected), array());
$result = $Folder->find('.*\.php', true);
$expected = array('config.php', 'paths.php');
$this->assertIdentical($result, $expected);
$result = $Folder->find('.*ig\.php');
@ -450,6 +463,14 @@ class FolderTest extends CakeTestCase {
TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php',
TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'paths.php'
);
$this->assertIdentical(array_diff($expected, $result), array());
$this->assertIdentical(array_diff($result, $expected), array());
$result = $Folder->findRecursive('(config|paths)\.php', true);
$expected = array(
TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php',
TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'paths.php'
);
$this->assertIdentical($result, $expected);
$Folder->cd(TMP);
@ -472,6 +493,14 @@ class FolderTest extends CakeTestCase {
TMP . 'testme' . DS . 'my.php',
TMP . 'testme' . DS . 'paths.php'
);
$this->assertIdentical(array_diff($expected, $result), array());
$this->assertIdentical(array_diff($result, $expected), array());
$result = $Folder->findRecursive('(paths|my)\.php', true);
$expected = array(
TMP . 'testme' . DS . 'my.php',
TMP . 'testme' . DS . 'paths.php'
);
$this->assertIdentical($result, $expected);
$Folder->cd(TEST_CAKE_CORE_INCLUDE_PATH . 'config');