Skip to content

Commit

Permalink
Fix failing tests in ErrorHandler and Folder on windows.
Browse files Browse the repository at this point in the history
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 2fffc88
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
18 changes: 12 additions & 6 deletions tests/TestCase/Error/ErrorHandlerTest.php
Expand Up @@ -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 .= '';
}
Expand All @@ -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 .= '';
}
Expand Down
38 changes: 19 additions & 19 deletions tests/TestCase/Utility/FolderTest.php
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand All @@ -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');
Expand All @@ -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());
}

Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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());

Expand Down

0 comments on commit 2fffc88

Please sign in to comment.