Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

preventing the possibility of trying to delete / if the test dir wasn…

…'t created correctly

And the ensuing exception if permission is denied
  • Loading branch information...
commit 803d19c80ec735d515104bfdc29f390dba4eb4f1 1 parent b7b27e3
@AD7six AD7six authored
Showing with 21 additions and 8 deletions.
  1. +21 −8 cake/tests/cases/console/libs/tasks/plugin.test.php
View
29 cake/tests/cases/console/libs/tasks/plugin.test.php
@@ -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')
@@ -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');
}
/**
@@ -212,8 +210,7 @@ function testExecuteWithNoArgs() {
$this->Task->args = array();
$this->Task->execute();
- $Folder =& new Folder($path);
- $Folder->delete();
+ $this->_rmDir($path);
}
/**
@@ -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');
}
/**
@@ -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();
+ }
}
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.