Skip to content
Permalink
Browse files

Fix failing tests in ErrorHandler and Folder on windows.

Windows does not support all the logging levels that unix does, and DS
needs to be used when referring to file paths.
  • Loading branch information...
markstory committed Jul 26, 2014
1 parent 6b9c4b6 commit 2fffc88fdd29ee6e5f0d7741638ced21b1eb3a37
Showing with 31 additions and 25 deletions.
  1. +12 −6 tests/TestCase/Error/ErrorHandlerTest.php
  2. +19 −19 tests/TestCase/Utility/FolderTest.php
@@ -150,7 +150,10 @@ public function testHandleErrorDebugOff() {
$this->_logger->expects($this->once())
->method('write')
->with('notice', 'Notice (8): Undefined variable: out in [' . __FILE__ . ', line ' . (__LINE__ + 2) . ']');
->with(
$this->matchesRegularExpression('(notice|debug)'),
'Notice (8): Undefined variable: out in [' . __FILE__ . ', line ' . (__LINE__ + 3) . ']'
);
$out .= '';
}
@@ -168,11 +171,14 @@ public function testHandleErrorLoggingTrace() {
$this->_logger->expects($this->once())
->method('write')
->with('notice', $this->logicalAnd(
$this->stringContains('Notice (8): Undefined variable: out in '),
$this->stringContains('Trace:'),
$this->stringContains(__NAMESPACE__ . '\ErrorHandlerTest::testHandleErrorLoggingTrace()')
));
->with(
$this->matchesRegularExpression('(notice|debug)'),
$this->logicalAnd(
$this->stringContains('Notice (8): Undefined variable: out in '),
$this->stringContains('Trace:'),
$this->stringContains(__NAMESPACE__ . '\ErrorHandlerTest::testHandleErrorLoggingTrace()')
)
);
$out .= '';
}
@@ -45,7 +45,7 @@ public function tearDown() {
$cleaner = function ($dir) use (&$cleaner) {
$files = array_diff(scandir($dir), ['.', '..']);
foreach ($files as $file) {
$path = $dir . '/' . $file;
$path = $dir . DS . $file;
if (is_dir($path)) {
$cleaner($path);
} else {
@@ -101,7 +101,7 @@ public function testInPath() {
$result = Folder::isSlashTerm($inside);
$this->assertTrue($result);
$result = $Folder->realpath('tests/');
$result = $Folder->realpath('tests' . DS);
$this->assertEquals($path . DS . 'tests' . DS, $result);
$result = $Folder->inPath('tests' . DS);
@@ -124,9 +124,9 @@ public function testCreation() {
$result = $Folder->create(TMP . 'tests' . DS . 'first' . DS . 'second' . DS . 'third');
$this->assertTrue($result);
rmdir(TMP . 'tests/first/second/third');
rmdir(TMP . 'tests/first/second');
rmdir(TMP . 'tests/first');
rmdir(TMP . 'tests' . DS . 'first' . DS . 'second' . DS . 'third');
rmdir(TMP . 'tests' . DS . 'first' . DS . 'second');
rmdir(TMP . 'tests' . DS . 'first');
$Folder = new Folder(TMP . 'tests');
$result = $Folder->create(TMP . 'tests' . DS . 'first');
@@ -146,7 +146,7 @@ public function testCreateWithTrailingDs() {
$this->assertTrue(is_dir($path), 'Folder was not made');
$Folder = new Folder(TMP . 'tests/trailing');
$Folder = new Folder(TMP . 'tests' . DS . 'trailing');
$this->assertTrue($Folder->delete());
}
@@ -186,30 +186,30 @@ public function testOperations() {
$result = is_dir($Folder->pwd());
$this->assertTrue($result);
$new = TMP . 'tests/test_folder_new';
$new = TMP . 'tests' . DS . 'test_folder_new';
$result = $Folder->create($new);
$this->assertTrue($result);
$copy = TMP . 'tests/test_folder_copy';
$copy = TMP . 'tests' . DS . 'test_folder_copy';
$result = $Folder->copy($copy);
$this->assertTrue($result);
$copy = TMP . 'tests/test_folder_copy';
$copy = TMP . 'tests' . DS . 'test_folder_copy';
$result = $Folder->copy($copy);
$this->assertTrue($result);
$copy = TMP . 'tests/test_folder_copy';
$copy = TMP . 'tests' . DS . 'test_folder_copy';
$result = $Folder->chmod($copy, 0755, false);
$this->assertTrue($result);
$result = $Folder->cd($copy);
$this->assertTrue((bool)$result);
$mv = TMP . 'tests/test_folder_mv';
$mv = TMP . 'tests' . DS . 'test_folder_mv';
$result = $Folder->move($mv);
$this->assertTrue($result);
$mv = TMP . 'tests/test_folder_mv_2';
$mv = TMP . 'tests' . DS . 'test_folder_mv_2';
$result = $Folder->move($mv);
$this->assertTrue($result);
@@ -230,7 +230,7 @@ public function testOperations() {
$result = $Folder->errors();
$this->assertEquals($expected, $result[0]);
$new = TMP . 'tests/test_folder_new';
$new = TMP . 'tests' . DS . 'test_folder_new';
$result = $Folder->create($new);
$this->assertTrue($result);
@@ -290,8 +290,8 @@ public function testChmod() {
* @return void
*/
public function testRealPathForWebroot() {
$Folder = new Folder('files/');
$this->assertEquals(realpath('files/'), $Folder->path);
$Folder = new Folder('files' . DS);
$this->assertEquals(realpath('files' . DS), $Folder->path);
}
/**
@@ -366,7 +366,7 @@ public function testFolderRead() {
*/
public function testFolderReadWithHiddenFiles() {
$this->skipIf(!is_writable(TMP), 'Cant test Folder::read with hidden files unless the tmp folder is writable.');
$path = TMP . 'tests/';
$path = TMP . 'tests' . DS;
$Folder = new Folder($path . 'folder_tree_hidden', true, 0777);
mkdir($Folder->path . DS . '.svn');
@@ -431,7 +431,7 @@ public function testFolderTree() {
*/
public function testFolderTreeWithHiddenFiles() {
$this->skipIf(!is_writable(TMP), 'Can\'t test Folder::tree with hidden files unless the tmp folder is writable.');
$path = TMP . 'tests/';
$path = TMP . 'tests' . DS;
$Folder = new Folder($path . 'folder_tree_hidden', true, 0777);
mkdir($Folder->path . DS . '.svn', 0777, true);
@@ -712,7 +712,7 @@ public function testFindRecursive() {
* @return void
*/
public function testConstructWithNonExistentPath() {
$path = TMP . 'tests/';
$path = TMP . 'tests' . DS;
$Folder = new Folder($path . 'config_non_existent', true);
$this->assertTrue(is_dir($path . 'config_non_existent'));
$Folder->cd($path);
@@ -724,7 +724,7 @@ public function testConstructWithNonExistentPath() {
* @return void
*/
public function testDirSize() {
$path = TMP . 'tests/';
$path = TMP . 'tests' . DS;
$Folder = new Folder($path . 'config_non_existent', true);
$this->assertEquals(0, $Folder->dirSize());

0 comments on commit 2fffc88

Please sign in to comment.
You can’t perform that action at this time.