Skip to content

Commit

Permalink
Use the correct function to rm directories.
Browse files Browse the repository at this point in the history
Use correct functions and fix failing tests on travis.ci. Directories
were being left behind after tests were complete as parent::tearDown()
restores debug which allows directory to be created in teardown. Shuffle
parent and clear() calls to prevent this.
  • Loading branch information
markstory committed Aug 17, 2013
1 parent 7cf7901 commit 4d3d54f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/Cake/Test/TestCase/Cache/Engine/FileEngineTest.php
Expand Up @@ -45,10 +45,12 @@ class FileEngineTest extends TestCase {
public function setUp() {
parent::setUp();
Cache::enable();
Cache::drop('file_test');
Cache::config('file_test', [
'engine' => 'File',
'path' => TMP . 'tests',
]);
Cache::clear(false, 'file_test');
}

/**
Expand All @@ -57,12 +59,11 @@ public function setUp() {
* @return void
*/
public function tearDown() {
parent::tearDown();
Cache::clear(false, 'file_test');
Cache::drop('file_test');
Cache::drop('file_groups');
Cache::drop('file_groups2');
Cache::drop('file_groups3');
parent::tearDown();
}

/**
Expand Down Expand Up @@ -377,6 +378,7 @@ public function testWriteQuotedString() {
*/
public function testPathDoesNotExist() {
$this->skipIf(is_dir(TMP . 'tests' . DS . 'autocreate'), 'Cannot run if test directory exists.');
Configure::write('debug', 2);

Cache::drop('file_test');
Cache::config('file_test', array(
Expand All @@ -386,7 +388,9 @@ public function testPathDoesNotExist() {
Cache::read('Test', 'file_test');

$this->assertTrue(file_exists(TMP . 'tests/autocreate'), 'Dir should exist.');
unlink(TMP . 'tests/autocreate');

// Cleanup
rmdir(TMP . 'tests/autocreate');
}

/**
Expand All @@ -399,14 +403,15 @@ public function testPathDoesNotExistDebugOff() {
$this->skipIf(is_dir(TMP . 'tests/autocreate'), 'Cannot run if test directory exists.');
Configure::write('debug', 0);

Cache::drop('file_test');
Cache::config('file_test', array(
Cache::drop('file_groups');
Cache::config('file_groups', array(
'engine' => 'File',
'duration' => '+1 year',
'prefix' => 'testing_invalid_',
'path' => TMP . 'tests/autocreate',
));
Cache::read('Test', 'test');
Cache::read('Test', 'file_groups');
Cache::drop('file_groups');
}

/**
Expand Down

0 comments on commit 4d3d54f

Please sign in to comment.