Fixing PluginTask tests

This commit is contained in:
Jose Lorenzo Rodriguez 2011-05-11 23:48:51 -04:30
parent 35ebd29ac3
commit 2be486844e
3 changed files with 13 additions and 11 deletions

View file

@ -76,7 +76,7 @@ class PluginTask extends Shell {
} }
if (!$this->bake($plugin)) { if (!$this->bake($plugin)) {
$this->error(__d('cake_console', "An error occured trying to bake: %s in %s", $plugin, $this->path . Inflector::underscore($pluginPath))); $this->error(__d('cake_console', "An error occured trying to bake: %s in %s", $plugin, $this->path . Inflector::camelize($pluginPath)));
} }
} }
@ -88,8 +88,7 @@ class PluginTask extends Shell {
* @return bool * @return bool
*/ */
public function bake($plugin) { public function bake($plugin) {
$pluginPath = Inflector::underscore($plugin); $pluginPath = Inflector::camelize($plugin);
$pathOptions = App::path('plugins'); $pathOptions = App::path('plugins');
if (count($pathOptions) > 1) { if (count($pathOptions) > 1) {
$this->findPath($pathOptions); $this->findPath($pathOptions);

View file

@ -756,6 +756,9 @@ class Shell extends Object {
* @return string $path path to the correct plugin. * @return string $path path to the correct plugin.
*/ */
function _pluginPath($pluginName) { function _pluginPath($pluginName) {
return App::pluginPath($pluginName); if (CakePlugin::loaded($pluginName)) {
return CakePlugin::path($pluginName);
}
return current(App::path('plugins')) . $pluginName . DS;
} }
} }

View file

@ -65,7 +65,7 @@ class PluginTaskTest extends CakeTestCase {
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue($this->_testPath)); $this->Task->expects($this->at(0))->method('in')->will($this->returnValue($this->_testPath));
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('y')); $this->Task->expects($this->at(1))->method('in')->will($this->returnValue('y'));
$path = $this->Task->path . 'bake_test_plugin'; $path = $this->Task->path . 'BakeTestPlugin';
$file = $path . DS . 'Controller' . DS .'BakeTestPluginAppController.php'; $file = $path . DS . 'Controller' . DS .'BakeTestPluginAppController.php';
$this->Task->expects($this->at(2))->method('createFile') $this->Task->expects($this->at(2))->method('createFile')
@ -77,7 +77,7 @@ class PluginTaskTest extends CakeTestCase {
$this->Task->bake('BakeTestPlugin'); $this->Task->bake('BakeTestPlugin');
$path = $this->Task->path . 'bake_test_plugin'; $path = $this->Task->path . 'BakeTestPlugin';
$this->assertTrue(is_dir($path), 'No plugin dir %s'); $this->assertTrue(is_dir($path), 'No plugin dir %s');
$directories = array( $directories = array(
@ -99,7 +99,7 @@ class PluginTaskTest extends CakeTestCase {
$this->assertTrue(is_dir($path . DS . $dir), 'Missing directory for ' . $dir); $this->assertTrue(is_dir($path . DS . $dir), 'Missing directory for ' . $dir);
} }
$Folder = new Folder($this->Task->path . 'bake_test_plugin'); $Folder = new Folder($this->Task->path . 'BakeTestPlugin');
$Folder->delete(); $Folder->delete();
} }
@ -113,7 +113,7 @@ class PluginTaskTest extends CakeTestCase {
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('3')); $this->Task->expects($this->at(1))->method('in')->will($this->returnValue('3'));
$this->Task->expects($this->at(2))->method('in')->will($this->returnValue('y')); $this->Task->expects($this->at(2))->method('in')->will($this->returnValue('y'));
$path = $this->Task->path . 'test_plugin'; $path = $this->Task->path . 'TestPlugin';
$file = $path . DS . 'Controller' . DS . 'TestPluginAppController.php'; $file = $path . DS . 'Controller' . DS . 'TestPluginAppController.php';
$this->Task->expects($this->at(3))->method('createFile') $this->Task->expects($this->at(3))->method('createFile')
->with($file, new PHPUnit_Framework_Constraint_IsAnything()); ->with($file, new PHPUnit_Framework_Constraint_IsAnything());
@ -140,12 +140,12 @@ class PluginTaskTest extends CakeTestCase {
$this->Task->expects($this->at(1))->method('in') $this->Task->expects($this->at(1))->method('in')
->will($this->returnValue('y')); ->will($this->returnValue('y'));
$path = $this->Task->path . 'bake_test_plugin'; $path = $this->Task->path . 'BakeTestPlugin';
$file = $path . DS . 'Controller' . DS . 'BakeTestPluginAppController.php'; $file = $path . DS . 'Controller' . DS . 'BakeTestPluginAppController.php';
$this->Task->expects($this->at(2))->method('createFile') $this->Task->expects($this->at(2))->method('createFile')
->with($file, new PHPUnit_Framework_Constraint_IsAnything()); ->with($file, new PHPUnit_Framework_Constraint_IsAnything());
$path = $this->Task->path . 'bake_test_plugin'; $path = $this->Task->path . 'BakeTestPlugin';
$file = $path . DS . 'Model' . DS . 'BakeTestPluginAppModel.php'; $file = $path . DS . 'Model' . DS . 'BakeTestPluginAppModel.php';
$this->Task->expects($this->at(3))->method('createFile') $this->Task->expects($this->at(3))->method('createFile')
->with($file, new PHPUnit_Framework_Constraint_IsAnything()); ->with($file, new PHPUnit_Framework_Constraint_IsAnything());
@ -154,7 +154,7 @@ class PluginTaskTest extends CakeTestCase {
$this->Task->execute(); $this->Task->execute();
$Folder = new Folder($this->Task->path . 'bake_test_plugin'); $Folder = new Folder($this->Task->path . 'BakeTestPlugin');
$Folder->delete(); $Folder->delete();
} }