From dedb2e4191f7ed8b9104953d2a1801308029a3c7 Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 16 Jan 2015 14:30:28 +0100 Subject: [PATCH 1/4] Added short plugin alias in shells --- lib/Cake/Console/ShellDispatcher.php | 5 +++ .../Test/Case/Console/ShellDispatcherTest.php | 8 +++++ .../Console/Command/TestPluginShell.php | 33 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/TestPluginShell.php diff --git a/lib/Cake/Console/ShellDispatcher.php b/lib/Cake/Console/ShellDispatcher.php index 30f37aa09..a385dc12b 100644 --- a/lib/Cake/Console/ShellDispatcher.php +++ b/lib/Cake/Console/ShellDispatcher.php @@ -246,6 +246,11 @@ class ShellDispatcher { 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 diff --git a/lib/Cake/Test/Case/Console/ShellDispatcherTest.php b/lib/Cake/Test/Case/Console/ShellDispatcherTest.php index 2d3aa5bf5..20473db63 100644 --- a/lib/Cake/Test/Case/Console/ShellDispatcherTest.php +++ b/lib/Cake/Test/Case/Console/ShellDispatcherTest.php @@ -427,6 +427,14 @@ class ShellDispatcherTest extends CakeTestCase { $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); } /** diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/TestPluginShell.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/TestPluginShell.php new file mode 100644 index 000000000..30ce333c5 --- /dev/null +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/TestPluginShell.php @@ -0,0 +1,33 @@ + + * 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'); + } +} From f4933b29a89252b9da853aeaea0df470425157a4 Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 16 Jan 2015 14:38:00 +0100 Subject: [PATCH 2/4] CS fix --- lib/Cake/Console/ShellDispatcher.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Console/ShellDispatcher.php b/lib/Cake/Console/ShellDispatcher.php index a385dc12b..08df24940 100644 --- a/lib/Cake/Console/ShellDispatcher.php +++ b/lib/Cake/Console/ShellDispatcher.php @@ -247,9 +247,9 @@ class ShellDispatcher { App::uses($class, $plugin . 'Console/Command'); if (!class_exists($class)) { - $plugin = Inflector::camelize($shell) . '.'; - App::uses($class, $plugin . 'Console/Command'); - } + $plugin = Inflector::camelize($shell) . '.'; + App::uses($class, $plugin . 'Console/Command'); + } if (!class_exists($class)) { throw new MissingShellException(array( From db1442573dba65a29cd230d0b9eeddd223e7e37c Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 16 Jan 2015 15:07:08 +0100 Subject: [PATCH 3/4] Fix failing tests --- lib/Cake/Test/Case/Console/Command/CompletionShellTest.php | 2 +- lib/Cake/Test/Case/Console/Command/Task/CommandTaskTest.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Test/Case/Console/Command/CompletionShellTest.php b/lib/Cake/Test/Case/Console/Command/CompletionShellTest.php index 7ef3ef53a..b28db0c65 100644 --- a/lib/Cake/Test/Case/Console/Command/CompletionShellTest.php +++ b/lib/Cake/Test/Case/Console/Command/CompletionShellTest.php @@ -125,7 +125,7 @@ class CompletionShellTest extends CakeTestCase { $this->Shell->runCommand('commands', array()); $output = $this->Shell->stdout->output; - $expected = "TestPlugin.example TestPluginTwo.example TestPluginTwo.welcome acl api bake command_list completion console i18n schema server test testsuite upgrade sample\n"; + $expected = "TestPlugin.example TestPlugin.test_plugin TestPluginTwo.example TestPluginTwo.welcome acl api bake command_list completion console i18n schema server test testsuite upgrade sample\n"; $this->assertEquals($expected, $output); } diff --git a/lib/Cake/Test/Case/Console/Command/Task/CommandTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/CommandTaskTest.php index 6a1293259..1aa91ffd7 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/CommandTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/CommandTaskTest.php @@ -85,9 +85,10 @@ class CommandTaskTest extends CakeTestCase { 'upgrade' ), 'TestPlugin' => array( - 'example' + 'example', + 'test_plugin' ), - 'TestPluginTwo' => array( + 'TestPluginTwo' => array( 'example', 'welcome' ), @@ -108,6 +109,7 @@ class CommandTaskTest extends CakeTestCase { $expected = array( 'TestPlugin.example', + 'TestPlugin.test_plugin', 'TestPluginTwo.example', 'TestPluginTwo.welcome', 'acl', From c755d9b5e5e220558c3d020578be02d9ace92e68 Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 19 Jan 2015 08:55:40 +0100 Subject: [PATCH 4/4] Updated comments --- .../Plugin/TestPlugin/Console/Command/TestPluginShell.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/TestPluginShell.php b/lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/TestPluginShell.php index 30ce333c5..b756c643a 100644 --- a/lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/TestPluginShell.php +++ b/lib/Cake/Test/test_app/Plugin/TestPlugin/Console/Command/TestPluginShell.php @@ -1,7 +1,5 @@ * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) * @@ -12,7 +10,7 @@ * @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 + * @since CakePHP(tm) v 2.7.0 * @license http://www.opensource.org/licenses/mit-license.php MIT License */