Skip to content

Commit 5ce87df

Browse files
committed
Update PluginTask to use the App.pluginPath configure variable.
This fixes PluginTask and the related tests.
1 parent f654541 commit 5ce87df

File tree

2 files changed

+14
-30
lines changed

2 files changed

+14
-30
lines changed

lib/Cake/Console/Command/Task/PluginTask.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22
/**
3-
* The Plugin Task handles creating an empty plugin, ready to be used
4-
*
53
* PHP 5
64
*
75
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
@@ -20,14 +18,14 @@
2018

2119
use Cake\Console\Shell;
2220
use Cake\Core\App;
21+
use Cake\Core\Configure;
2322
use Cake\Utility\File;
2423
use Cake\Utility\Folder;
2524
use Cake\Utility\Inflector;
2625

2726
/**
2827
* The Plugin Task handles creating an empty plugin, ready to be used
2928
*
30-
* @package Cake.Console.Command.Task
3129
*/
3230
class PluginTask extends Shell {
3331

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

@@ -98,7 +96,7 @@ protected function _interactive($plugin = null) {
9896
* @return boolean
9997
*/
10098
public function bake($plugin) {
101-
$pathOptions = App::path('Plugin');
99+
$pathOptions = (array)Configure::read('App.pluginPath');
102100
if (count($pathOptions) > 1) {
103101
$this->findPath($pathOptions);
104102
}

lib/Cake/Test/TestCase/Console/Command/Task/PluginTaskTest.php

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
use Cake\Console\Command\Task\DbConfigTask;
2525
use Cake\Core\App;
26+
use Cake\Core\Configure;
2627
use Cake\Core\Plugin;
2728
use Cake\TestSuite\TestCase;
2829
use Cake\Utility\Folder;
@@ -52,13 +53,7 @@ public function setUp() {
5253
$this->Task->bootstrap = TMP . 'tests/bootstrap.php';
5354
touch($this->Task->bootstrap);
5455

55-
$this->_paths = $paths = App::path('Plugin');
56-
foreach ($paths as $i => $p) {
57-
if (!is_dir($p)) {
58-
array_splice($paths, $i, 1);
59-
}
60-
}
61-
$this->_testPath = array_push($paths, TMP . 'tests/');
56+
$this->_path = Configure::read('App.pluginPath');
6257
}
6358

6459
/**
@@ -79,24 +74,22 @@ public function tearDown() {
7974
* @return void
8075
*/
8176
public function testBakeFoldersAndFiles() {
82-
$this->markTestIncomplete('This halts the execution for some reason');
83-
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue($this->_testPath));
84-
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('y'));
77+
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y'));
8578

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

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

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

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

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

10194
$directories = array(
10295
'Config/Schema',
@@ -127,20 +120,17 @@ public function testBakeFoldersAndFiles() {
127120
* @return void
128121
*/
129122
public function testExecuteWithNoArgs() {
130-
$this->markTestIncomplete('This halts the execution for some reason');
131-
132123
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('TestPlugin'));
133-
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue($this->_testPath));
134-
$this->Task->expects($this->at(2))->method('in')->will($this->returnValue('y'));
124+
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue('y'));
135125

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

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

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

146136
$this->Task->args = array();
@@ -156,21 +146,17 @@ public function testExecuteWithNoArgs() {
156146
* @return void
157147
*/
158148
public function testExecuteWithOneArg() {
159-
$this->markTestIncomplete('This halts the execution for some reason');
160-
161149
$this->Task->expects($this->at(0))->method('in')
162-
->will($this->returnValue($this->_testPath));
163-
$this->Task->expects($this->at(1))->method('in')
164150
->will($this->returnValue('y'));
165151

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

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

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

0 commit comments

Comments
 (0)