Navigation Menu

Skip to content

Commit

Permalink
Update PluginTask to use the App.pluginPath configure variable.
Browse files Browse the repository at this point in the history
This fixes PluginTask and the related tests.
  • Loading branch information
markstory committed Sep 10, 2013
1 parent f654541 commit 5ce87df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 30 deletions.
8 changes: 3 additions & 5 deletions lib/Cake/Console/Command/Task/PluginTask.php
@@ -1,7 +1,5 @@
<?php
/**
* The Plugin Task handles creating an empty plugin, ready to be used
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
Expand All @@ -20,14 +18,14 @@

use Cake\Console\Shell;
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Utility\File;
use Cake\Utility\Folder;
use Cake\Utility\Inflector;

/**
* The Plugin Task handles creating an empty plugin, ready to be used
*
* @package Cake.Console.Command.Task
*/
class PluginTask extends Shell {

Expand All @@ -51,7 +49,7 @@ class PluginTask extends Shell {
* @return void
*/
public function initialize() {
$this->path = current(App::path('Plugin'));
$this->path = Configure::read('App.pluginPath');
$this->bootstrap = APP . 'Config/bootstrap.php';
}

Expand Down Expand Up @@ -98,7 +96,7 @@ protected function _interactive($plugin = null) {
* @return boolean
*/
public function bake($plugin) {
$pathOptions = App::path('Plugin');
$pathOptions = (array)Configure::read('App.pluginPath');
if (count($pathOptions) > 1) {
$this->findPath($pathOptions);
}
Expand Down
36 changes: 11 additions & 25 deletions lib/Cake/Test/TestCase/Console/Command/Task/PluginTaskTest.php
Expand Up @@ -23,6 +23,7 @@

use Cake\Console\Command\Task\DbConfigTask;
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\TestSuite\TestCase;
use Cake\Utility\Folder;
Expand Down Expand Up @@ -52,13 +53,7 @@ public function setUp() {
$this->Task->bootstrap = TMP . 'tests/bootstrap.php';
touch($this->Task->bootstrap);

$this->_paths = $paths = App::path('Plugin');
foreach ($paths as $i => $p) {
if (!is_dir($p)) {
array_splice($paths, $i, 1);
}
}
$this->_testPath = array_push($paths, TMP . 'tests/');
$this->_path = Configure::read('App.pluginPath');
}

/**
Expand All @@ -79,24 +74,22 @@ public function tearDown() {
* @return void
*/
public function testBakeFoldersAndFiles() {
$this->markTestIncomplete('This halts the execution for some reason');
$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(0))->method('in')->will($this->returnValue('y'));

$path = $this->Task->path . 'BakeTestPlugin';

$file = $path . DS . 'Controller/BakeTestPluginAppController.php';
$this->Task->expects($this->at(2))->method('createFile')
$this->Task->expects($this->at(1))->method('createFile')
->with($file, new \PHPUnit_Framework_Constraint_IsAnything());

$file = $path . DS . 'Model/BakeTestPluginAppModel.php';
$this->Task->expects($this->at(3))->method('createFile')
$this->Task->expects($this->at(2))->method('createFile')
->with($file, new \PHPUnit_Framework_Constraint_IsAnything());

$this->Task->bake('BakeTestPlugin');

$path = $this->Task->path . 'BakeTestPlugin';
$this->assertTrue(is_dir($path), 'No plugin dir %s');
$this->assertTrue(is_dir($path), 'No plugin dir');

$directories = array(
'Config/Schema',
Expand Down Expand Up @@ -127,20 +120,17 @@ public function testBakeFoldersAndFiles() {
* @return void
*/
public function testExecuteWithNoArgs() {
$this->markTestIncomplete('This halts the execution for some reason');

$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('TestPlugin'));
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue($this->_testPath));
$this->Task->expects($this->at(2))->method('in')->will($this->returnValue('y'));
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('y'));

$path = $this->Task->path . 'TestPlugin';
$file = $path . DS . 'Controller/TestPluginAppController.php';

$this->Task->expects($this->at(3))->method('createFile')
$this->Task->expects($this->at(2))->method('createFile')
->with($file, new \PHPUnit_Framework_Constraint_IsAnything());

$file = $path . DS . 'Model/TestPluginAppModel.php';
$this->Task->expects($this->at(4))->method('createFile')
$this->Task->expects($this->at(3))->method('createFile')
->with($file, new \PHPUnit_Framework_Constraint_IsAnything());

$this->Task->args = array();
Expand All @@ -156,21 +146,17 @@ public function testExecuteWithNoArgs() {
* @return void
*/
public function testExecuteWithOneArg() {
$this->markTestIncomplete('This halts the execution for some reason');

$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'));

$path = $this->Task->path . 'BakeTestPlugin';
$file = $path . DS . 'Controller/BakeTestPluginAppController.php';
$this->Task->expects($this->at(2))->method('createFile')
$this->Task->expects($this->at(1))->method('createFile')
->with($file, new \PHPUnit_Framework_Constraint_IsAnything());

$path = $this->Task->path . 'BakeTestPlugin';
$file = $path . DS . 'Model/BakeTestPluginAppModel.php';
$this->Task->expects($this->at(3))->method('createFile')
$this->Task->expects($this->at(2))->method('createFile')
->with($file, new \PHPUnit_Framework_Constraint_IsAnything());

$this->Task->args = array('BakeTestPlugin');
Expand Down

0 comments on commit 5ce87df

Please sign in to comment.