Skip to content

Commit

Permalink
preventing the possibility of trying to delete / if the test dir wasn…
Browse files Browse the repository at this point in the history
…'t created correctly

And the ensuing exception if permission is denied
  • Loading branch information
AD7six committed Jul 29, 2009
1 parent b7b27e3 commit 803d19c
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions cake/tests/cases/console/libs/tasks/plugin.test.php
Expand Up @@ -38,7 +38,6 @@
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'plugin.php';
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'model.php';


Mock::generatePartial(
'ShellDispatcher', 'TestPluginTaskMockShellDispatcher',
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
Expand Down Expand Up @@ -187,8 +186,7 @@ function testBakeFoldersAndFiles() {
$file = $path . DS . 'bake_test_plugin_app_model.php';
$this->Task->expectAt(1, 'createFile', array($file, '*'), 'No AppModel %s');

$Folder =& new Folder($this->Task->path . 'bake_test_plugin');
$Folder->delete();
$this->_rmDir($this->Task->path . 'bake_test_plugin');
}

/**
Expand All @@ -212,8 +210,7 @@ function testExecuteWithNoArgs() {
$this->Task->args = array();
$this->Task->execute();

$Folder =& new Folder($path);
$Folder->delete();
$this->_rmDir($path);
}

/**
Expand All @@ -236,8 +233,7 @@ function testExecuteWithOneArg() {

$this->Task->execute();

$Folder =& new Folder($this->Task->path . 'bake_test_plugin');
$Folder->delete();
$this->_rmDir($this->Task->path . 'bake_test_plugin');
}

/**
Expand All @@ -258,7 +254,24 @@ function testExecuteWithTwoArgs() {
$this->Task->Model->expectOnce('loadTasks');
$this->Task->Model->expectOnce('execute');
$this->Task->execute();
$Folder->delete();

$this->_rmDir($this->Task->path . 'bake_test_plugin');
}

/**
* rmDir method
*
* If the folder exists - delete it
*
* @param mixed $path
* @return void
* @access protected
*/
function _rmDir($path) {
if (is_dir($path)) {
$Folder =& new Folder($path);
$Folder->delete();
}
}
}
?>

0 comments on commit 803d19c

Please sign in to comment.