mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge pull request #5681 from robertpustulka/2.7-short-plugin-shell
2.7 - Short plugin alias in shells
This commit is contained in:
commit
3cc3db8380
5 changed files with 49 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* 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 2.7.0
|
||||
* @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');
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue