Skip to content

Commit

Permalink
Added short plugin alias in shells
Browse files Browse the repository at this point in the history
  • Loading branch information
robertpustulka committed Jan 19, 2015
1 parent 3078a1e commit dedb2e4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/Cake/Console/ShellDispatcher.php
Expand Up @@ -246,6 +246,11 @@ protected function _getShell($shell) {
App::uses('AppShell', 'Console/Command');
App::uses($class, $plugin . 'Console/Command');

if (!class_exists($class)) {
$plugin = Inflector::camelize($shell) . '.';
App::uses($class, $plugin . 'Console/Command');
}

if (!class_exists($class)) {
throw new MissingShellException(array(
'class' => $class
Expand Down
8 changes: 8 additions & 0 deletions lib/Cake/Test/Case/Console/ShellDispatcherTest.php
Expand Up @@ -427,6 +427,14 @@ public function testGetShell() {
$Dispatcher = new TestShellDispatcher();
$result = $Dispatcher->getShell('TestPlugin.example');
$this->assertInstanceOf('ExampleShell', $result);

$Dispatcher = new TestShellDispatcher();
$result = $Dispatcher->getShell('test_plugin');
$this->assertInstanceOf('TestPluginShell', $result);

$Dispatcher = new TestShellDispatcher();
$result = $Dispatcher->getShell('TestPlugin');
$this->assertInstanceOf('TestPluginShell', $result);
}

/**
Expand Down
@@ -0,0 +1,33 @@
<?php
/**
* Short description for file.
*
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.TestApp.Plugin.TestPlugin.Console.Command
* @since CakePHP(tm) v 1.2.0.7871
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/

/**
* Class TestPluginShell
* @package Cake.Test.TestApp.Plugin.TestPlugin.Console.Command
*/
class TestPluginShell extends Shell {

/**
* main method
*
* @return void
*/
public function main() {
$this->out('This is the main method called from TestPlugin.TestPluginShell');
}
}

0 comments on commit dedb2e4

Please sign in to comment.