Merge remote-tracking branch 'origin/2.0' into 2.0

This commit is contained in:
Jose Lorenzo Rodriguez 2011-05-22 21:55:07 -04:30
commit 8d52907be7
3 changed files with 42 additions and 6 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::camelize($pluginPath))); $this->error(__d('cake_console', "An error occured trying to bake: %s in %s", $plugin, $this->path . Inflector::camelize($plugin)));
} }
} }
@ -163,6 +163,11 @@ class PluginTask extends Shell {
*/ */
public function findPath($pathOptions) { public function findPath($pathOptions) {
$valid = false; $valid = false;
foreach ($pathOptions as $i =>$path) {
if(!is_dir($path)) {
array_splice($pathOptions, $i, 1);
}
}
$max = count($pathOptions); $max = count($pathOptions);
while (!$valid) { while (!$valid) {
foreach ($pathOptions as $i => $option) { foreach ($pathOptions as $i => $option) {

View file

@ -314,8 +314,8 @@ class App {
'vendors' => array('%s' . 'Vendor' . DS, VENDORS), 'vendors' => array('%s' . 'Vendor' . DS, VENDORS),
'plugins' => array( 'plugins' => array(
APP . 'Plugin' . DS, APP . 'Plugin' . DS,
APP . 'plugin' . DS, APP . 'plugins' . DS,
dirname(dirname(CAKE)) . DS . 'Plugin' . DS, dirname(dirname(CAKE)) . DS . 'plugins' . DS,
) )
); );
} }

View file

@ -42,16 +42,21 @@ class PluginTaskTest extends CakeTestCase {
*/ */
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$out = $this->getMock('ConsoleOutput', array(), array(), '', false); $this->out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false); $this->in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Task = $this->getMock('PluginTask', $this->Task = $this->getMock('PluginTask',
array('in', 'err', 'createFile', '_stop', 'clear'), array('in', 'err', 'createFile', '_stop', 'clear'),
array($out, $out, $in) array($this->out, $this->out, $this->in)
); );
$this->Task->path = TMP . 'tests' . DS; $this->Task->path = TMP . 'tests' . DS;
$this->_paths = $paths = App::path('plugins'); $this->_paths = $paths = App::path('plugins');
foreach ($paths as $i => $p) {
if (!is_dir($p)) {
array_splice($paths, $i, 1);
}
}
$this->_testPath = array_push($paths, TMP . 'tests' . DS); $this->_testPath = array_push($paths, TMP . 'tests' . DS);
App::build(array('plugins' => $paths)); App::build(array('plugins' => $paths));
} }
@ -159,4 +164,30 @@ class PluginTaskTest extends CakeTestCase {
$Folder->delete(); $Folder->delete();
} }
/**
* Test that findPath ignores paths that don't exist.
*
* @return void
*/
public function testFindPathNonExistant() {
$paths = App::path('plugins');
$last = count($paths);
$paths[] = '/fake/path';
$this->Task = $this->getMock('PluginTask',
array('in', 'out', 'err', 'createFile', '_stop'),
array($this->out, $this->out, $this->in)
);
$this->Task->path = TMP . 'tests' . DS;
// Make sure the added path is filtered out.
$this->Task->expects($this->exactly($last))
->method('out');
$this->Task->expects($this->once())
->method('in')
->will($this->returnValue($last));
$this->Task->findPath($paths);
}
} }