From d725869507d2420784666c66f6ed2a1d6a850143 Mon Sep 17 00:00:00 2001 From: Kyle Robinson Young Date: Mon, 14 Nov 2011 23:47:52 -0800 Subject: [PATCH 1/2] Add test cases to include $exceptions with Folder::chmod() --- lib/Cake/Test/Case/Utility/FolderTest.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/FolderTest.php b/lib/Cake/Test/Case/Utility/FolderTest.php index 48855bc34..69368de1a 100644 --- a/lib/Cake/Test/Case/Utility/FolderTest.php +++ b/lib/Cake/Test/Case/Utility/FolderTest.php @@ -268,11 +268,26 @@ class FolderTest extends CakeTestCase { $filePath = $new . DS . 'test1.php'; $File = new File($filePath); $this->assertTrue($File->create()); - $copy = TMP . 'test_folder_copy'; - - $this->assertTrue($Folder->chmod($new, 0777, true)); - $this->assertEqual($File->perms(), '0777'); + + $filePath = $new . DS . 'skip_me.php'; + $File = new File($filePath); + $this->assertTrue($File->create()); + $this->assertTrue($Folder->chmod($new, 0755, true)); + $this->assertTrue($Folder->chmod($new, 0777, true, array('skip_me.php', 'test2'))); + + $perms = substr(sprintf('%o', fileperms($new . DS . 'test1')), -4); + $this->assertEqual($perms, '0777'); + + $perms = substr(sprintf('%o', fileperms($new . DS . 'test2')), -4); + $this->assertEqual($perms, '0755'); + + $perms = substr(sprintf('%o', fileperms($new . DS . 'test1.php')), -4); + $this->assertEqual($perms, '0777'); + + $perms = substr(sprintf('%o', fileperms($new . DS . 'skip_me.php')), -4); + $this->assertEqual($perms, '0755'); + $Folder->delete($new); } From 1ebaaf4dd175b94289bad54b3986184f5e72fde3 Mon Sep 17 00:00:00 2001 From: Kyle Robinson Young Date: Tue, 15 Nov 2011 08:18:05 -0800 Subject: [PATCH 2/2] Update to assertEquals on Folder tests --- lib/Cake/Test/Case/Utility/FolderTest.php | 58 +++++++++++------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/FolderTest.php b/lib/Cake/Test/Case/Utility/FolderTest.php index 69368de1a..33b5149fc 100644 --- a/lib/Cake/Test/Case/Utility/FolderTest.php +++ b/lib/Cake/Test/Case/Utility/FolderTest.php @@ -75,15 +75,15 @@ class FolderTest extends CakeTestCase { $Folder = new Folder($path); $result = $Folder->pwd(); - $this->assertEqual($result, $path); + $this->assertEquals($result, $path); $result = Folder::addPathElement($path, 'test'); $expected = $path . DS . 'test'; - $this->assertEqual($expected, $result); + $this->assertEquals($expected, $result); $result = $Folder->cd(ROOT); $expected = ROOT; - $this->assertEqual($expected, $result); + $this->assertEquals($expected, $result); $result = $Folder->cd(ROOT . DS . 'non-existent'); $this->assertFalse($result); @@ -101,13 +101,13 @@ class FolderTest extends CakeTestCase { $Folder = new Folder($path); $result = $Folder->pwd(); - $this->assertEqual($result, $path); + $this->assertEquals($result, $path); $result = Folder::isSlashTerm($inside); $this->assertTrue($result); $result = $Folder->realpath('Test/'); - $this->assertEqual($result, $path . DS .'Test' . DS); + $this->assertEquals($result, $path . DS .'Test' . DS); $result = $Folder->inPath('Test' . DS); $this->assertTrue($result); @@ -230,7 +230,7 @@ class FolderTest extends CakeTestCase { $expected = $new . ' is a file'; $result = $Folder->errors(); - $this->assertEqual($result[0], $expected); + $this->assertEquals($result[0], $expected); $new = TMP . 'test_folder_new'; $result = $Folder->create($new); @@ -277,16 +277,16 @@ class FolderTest extends CakeTestCase { $this->assertTrue($Folder->chmod($new, 0777, true, array('skip_me.php', 'test2'))); $perms = substr(sprintf('%o', fileperms($new . DS . 'test1')), -4); - $this->assertEqual($perms, '0777'); + $this->assertEquals($perms, '0777'); $perms = substr(sprintf('%o', fileperms($new . DS . 'test2')), -4); - $this->assertEqual($perms, '0755'); + $this->assertEquals($perms, '0755'); $perms = substr(sprintf('%o', fileperms($new . DS . 'test1.php')), -4); - $this->assertEqual($perms, '0777'); + $this->assertEquals($perms, '0777'); $perms = substr(sprintf('%o', fileperms($new . DS . 'skip_me.php')), -4); - $this->assertEqual($perms, '0755'); + $this->assertEquals($perms, '0755'); $Folder->delete($new); } @@ -298,7 +298,7 @@ class FolderTest extends CakeTestCase { */ public function testRealPathForWebroot() { $Folder = new Folder('files/'); - $this->assertEqual(realpath('files/'), $Folder->path); + $this->assertEquals(realpath('files/'), $Folder->path); } /** @@ -313,11 +313,11 @@ class FolderTest extends CakeTestCase { $result = $Folder->read(true, true); $expected = array('0', 'cache', 'logs', 'sessions', 'tests'); - $this->assertEqual($expected, $result[0]); + $this->assertEquals($expected, $result[0]); $result = $Folder->read(true, array('logs')); $expected = array('0', 'cache', 'sessions', 'tests'); - $this->assertEqual($expected, $result[0]); + $this->assertEquals($expected, $result[0]); $result = $Folder->delete($new); $this->assertTrue($result); @@ -330,10 +330,10 @@ class FolderTest extends CakeTestCase { */ public function testAddPathElement() { $result = Folder::addPathElement(DS . 'some' . DS . 'dir', 'another_path'); - $this->assertEqual($result, DS . 'some' . DS . 'dir' . DS . 'another_path'); + $this->assertEquals($result, DS . 'some' . DS . 'dir' . DS . 'another_path'); $result = Folder::addPathElement(DS . 'some' . DS . 'dir' . DS, 'another_path'); - $this->assertEqual($result, DS . 'some' . DS . 'dir' . DS . 'another_path'); + $this->assertEquals($result, DS . 'some' . DS . 'dir' . DS . 'another_path'); } /** * testFolderRead method @@ -345,12 +345,12 @@ class FolderTest extends CakeTestCase { $expected = array('cache', 'logs', 'sessions', 'tests'); $result = $Folder->read(true, true); - $this->assertEqual($result[0], $expected); + $this->assertEquals($result[0], $expected); $Folder->path = TMP . 'non-existent'; $expected = array(array(), array()); $result = $Folder->read(true, true); - $this->assertEqual($expected, $result); + $this->assertEquals($expected, $result); } /** @@ -453,7 +453,7 @@ class FolderTest extends CakeTestCase { */ public function testSlashTerm() { $result = Folder::slashTerm('/path/to/file'); - $this->assertEqual($result, '/path/to/file/'); + $this->assertEquals($result, '/path/to/file/'); } /** @@ -464,15 +464,15 @@ class FolderTest extends CakeTestCase { public function testNormalizePath() { $path = '/path/to/file'; $result = Folder::normalizePath($path); - $this->assertEqual($result, '/'); + $this->assertEquals($result, '/'); $path = '\\path\\\to\\\file'; $result = Folder::normalizePath($path); - $this->assertEqual($result, '/'); + $this->assertEquals($result, '/'); $path = 'C:\\path\\to\\file'; $result = Folder::normalizePath($path); - $this->assertEqual($result, '\\'); + $this->assertEquals($result, '\\'); } /** @@ -483,15 +483,15 @@ class FolderTest extends CakeTestCase { public function testCorrectSlashFor() { $path = '/path/to/file'; $result = Folder::correctSlashFor($path); - $this->assertEqual($result, '/'); + $this->assertEquals($result, '/'); $path = '\\path\\to\\file'; $result = Folder::correctSlashFor($path); - $this->assertEqual($result, '/'); + $this->assertEquals($result, '/'); $path = 'C:\\path\to\\file'; $result = Folder::correctSlashFor($path); - $this->assertEqual($result, '\\'); + $this->assertEquals($result, '\\'); } /** @@ -645,13 +645,13 @@ class FolderTest extends CakeTestCase { */ public function testDirSize() { $Folder = new Folder(TMP . 'config_non_existant', true); - $this->assertEqual($Folder->dirSize(), 0); + $this->assertEquals($Folder->dirSize(), 0); $File = new File($Folder->pwd() . DS . 'my.php', true, 0777); $File->create(); $File->write('something here'); $File->close(); - $this->assertEqual($Folder->dirSize(), 14); + $this->assertEquals($Folder->dirSize(), 14); $Folder->cd(TMP); $Folder->delete($Folder->pwd() . 'config_non_existant'); @@ -681,7 +681,7 @@ class FolderTest extends CakeTestCase { $path . DS . 'file2 removed', $path . ' removed' ); - $this->assertEqual($expected, $messages); + $this->assertEquals($expected, $messages); } /** @@ -735,7 +735,7 @@ class FolderTest extends CakeTestCase { $result = $Folder->copy($folder3); $this->assertTrue($result); $this->assertTrue(file_exists($folder3 . DS . 'file1.php')); - $this->assertEqual(file_get_contents($folder3 . DS . 'folder2' . DS . 'file2.php'), 'untouched'); + $this->assertEquals(file_get_contents($folder3 . DS . 'folder2' . DS . 'file2.php'), 'untouched'); $Folder = new Folder($path); $Folder->delete(); @@ -809,7 +809,7 @@ class FolderTest extends CakeTestCase { $result = $Folder->move($folder3); $this->assertTrue($result); $this->assertTrue(file_exists($folder3 . DS . 'file1.php')); - $this->assertEqual(file_get_contents($folder3 . DS . 'folder2' . DS . 'file2.php'), 'untouched'); + $this->assertEquals(file_get_contents($folder3 . DS . 'folder2' . DS . 'file2.php'), 'untouched'); $this->assertFalse(file_exists($file1)); $this->assertFalse(file_exists($folder2)); $this->assertFalse(file_exists($file2));