Skip to content
Permalink
Browse files

Adding tests for plugin shell auto aliasing

  • Loading branch information...
lorenzo committed Sep 13, 2014
1 parent e7357f9 commit 8f21eba7d55db4cd60962f22789cf0df25bb9f0a
@@ -169,7 +169,7 @@ public function testDispatchShellWithoutMain() {
}
/**
* Verify you can dispatch a plugin's main shell with the plugin name alone
* Verify you can dispatch a plugin's main shell with the shell name alone
*
* @return void
*/
@@ -182,15 +182,15 @@ public function testDispatchShortPluginAlias() {
$dispatcher->expects($this->at(1))
->method('_shellExists')
->with('TestPlugin.TestPlugin')
->with('TestPlugin.Example')
->will($this->returnValue('TestPlugin\Console\Command\TestPluginShell'));
$dispatcher->expects($this->at(2))
->method('_createShell')
->with('TestPlugin\Console\Command\TestPluginShell', 'TestPlugin.TestPlugin')
->with('TestPlugin\Console\Command\TestPluginShell', 'TestPlugin.Example')
->will($this->returnValue($Shell));
$dispatcher->args = array('test_plugin');
$dispatcher->args = array('example');
$result = $dispatcher->dispatch();
$this->assertEquals(1, $result);
}
@@ -209,15 +209,42 @@ public function testDispatchShortPluginAliasCamelized() {
$dispatcher->expects($this->at(1))
->method('_shellExists')
->with('TestPlugin.TestPlugin')
->with('TestPlugin.Example')
->will($this->returnValue('TestPlugin\Console\Command\TestPluginShell'));
$dispatcher->expects($this->at(2))
->method('_createShell')
->with('TestPlugin\Console\Command\TestPluginShell', 'TestPlugin.TestPlugin')
->with('TestPlugin\Console\Command\TestPluginShell', 'TestPlugin.Example')
->will($this->returnValue($Shell));
$dispatcher->args = ['TestPlugin'];
$dispatcher->args = ['Example'];
$result = $dispatcher->dispatch();
$this->assertEquals(1, $result);
}
/**
* Verify that in case of conflict, app shells take precedence in alias list
*
* @return void
*/
public function testDispatchShortPluginAliasConflict() {
$dispatcher = $this->getMock(
'Cake\Console\ShellDispatcher',
['_shellExists', '_createShell']
);
$Shell = $this->getMock('Cake\Console\Shell');
$dispatcher->expects($this->at(1))
->method('_shellExists')
->with('Sample')
->will($this->returnValue('App\Shell\SampleShell'));
$dispatcher->expects($this->at(2))
->method('_createShell')
->with('App\Shell\SampleShell', 'Sample')
->will($this->returnValue($Shell));
$dispatcher->args = array('sample');
$result = $dispatcher->dispatch();
$this->assertEquals(1, $result);
}
@@ -0,0 +1,35 @@
<?php
/**
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* 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://cakephp.org CakePHP(tm) Project
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* Class SampleShell
*
*/
namespace TestPlugin\Shell;
use Cake\Console\Shell;
class SampleShell extends Shell {
/**
* main method
*
* @return void
*/
public function main() {
$this->out('This is the main method called from SampleShell');
}
}

0 comments on commit 8f21eba

Please sign in to comment.
You can’t perform that action at this time.