2010-10-04 03:42:24 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* CommandList file
|
|
|
|
*
|
|
|
|
* PHP 5
|
|
|
|
*
|
|
|
|
* CakePHP : Rapid Development Framework (http://cakephp.org)
|
|
|
|
* Copyright 2006-2010, Cake Software Foundation, Inc.
|
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
|
|
|
* @copyright Copyright 2006-2010, Cake Software Foundation, Inc.
|
|
|
|
* @link http://cakephp.org CakePHP Project
|
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.tests.cases.console.libs
|
|
|
|
* @since CakePHP v 2.0
|
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
|
|
|
*/
|
|
|
|
App::import('Shell', 'CommandList', false);
|
|
|
|
|
|
|
|
|
|
|
|
class TestStringOutput extends ConsoleOutput {
|
|
|
|
public $output = '';
|
|
|
|
|
|
|
|
protected function _write($message) {
|
|
|
|
$this->output .= $message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class CommandListTest extends CakeTestCase {
|
|
|
|
/**
|
|
|
|
* setUp method
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
App::build(array(
|
|
|
|
'plugins' => array(
|
|
|
|
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
|
|
|
|
),
|
|
|
|
'shells' => array(
|
2010-10-17 21:32:37 +00:00
|
|
|
CORE_PATH ?
|
|
|
|
CORE_PATH . CAKE . 'console' . DS . 'shells' . DS :
|
|
|
|
CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'console' . DS . 'shells' .DS,
|
|
|
|
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'console' . DS . 'shells' . DS
|
2010-10-04 03:42:24 +00:00
|
|
|
)
|
|
|
|
), true);
|
2010-10-20 03:21:24 +00:00
|
|
|
App::objects('plugin', null, false);
|
2010-10-04 03:42:24 +00:00
|
|
|
|
2010-10-06 03:51:08 +00:00
|
|
|
$out = new TestStringOutput();
|
2010-10-07 02:52:42 +00:00
|
|
|
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
2010-10-04 03:42:24 +00:00
|
|
|
|
|
|
|
$this->Shell = $this->getMock(
|
|
|
|
'CommandListShell',
|
2010-10-06 03:51:08 +00:00
|
|
|
array('in', '_stop', 'clear'),
|
2010-10-24 19:11:30 +00:00
|
|
|
array($out, $out, $in)
|
2010-10-04 03:42:24 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* teardown
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function tearDown() {
|
2010-10-17 21:32:37 +00:00
|
|
|
parent::tearDown();
|
2010-10-24 19:11:30 +00:00
|
|
|
unset($this->Shell);
|
2010-10-04 03:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* test that main finds core shells.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testMain() {
|
|
|
|
$this->Shell->main();
|
2010-10-06 03:51:08 +00:00
|
|
|
$output = $this->Shell->stdout->output;
|
2010-10-24 19:11:30 +00:00
|
|
|
|
2010-10-04 03:42:24 +00:00
|
|
|
$expected = "/example \[.*TestPlugin, TestPluginTwo.*\]/";
|
2010-10-17 21:32:37 +00:00
|
|
|
$this->assertPattern($expected, $output);
|
2010-10-04 03:42:24 +00:00
|
|
|
|
|
|
|
$expected = "/welcome \[.*TestPluginTwo.*\]/";
|
2010-10-17 21:32:37 +00:00
|
|
|
$this->assertPattern($expected, $output);
|
2010-10-04 03:42:24 +00:00
|
|
|
|
|
|
|
$expected = "/acl \[.*CORE.*\]/";
|
2010-10-17 21:32:37 +00:00
|
|
|
$this->assertPattern($expected, $output);
|
2010-10-04 03:42:24 +00:00
|
|
|
|
|
|
|
$expected = "/api \[.*CORE.*\]/";
|
2010-10-17 21:32:37 +00:00
|
|
|
$this->assertPattern($expected, $output);
|
2010-10-04 03:42:24 +00:00
|
|
|
|
|
|
|
$expected = "/bake \[.*CORE.*\]/";
|
2010-10-17 21:32:37 +00:00
|
|
|
$this->assertPattern($expected, $output);
|
2010-10-04 03:42:24 +00:00
|
|
|
|
|
|
|
$expected = "/console \[.*CORE.*\]/";
|
2010-10-17 21:32:37 +00:00
|
|
|
$this->assertPattern($expected, $output);
|
2010-10-04 03:42:24 +00:00
|
|
|
|
|
|
|
$expected = "/i18n \[.*CORE.*\]/";
|
2010-10-17 21:32:37 +00:00
|
|
|
$this->assertPattern($expected, $output);
|
2010-10-04 03:42:24 +00:00
|
|
|
|
|
|
|
$expected = "/schema \[.*CORE.*\]/";
|
2010-10-17 21:32:37 +00:00
|
|
|
$this->assertPattern($expected, $output);
|
2010-10-04 03:42:24 +00:00
|
|
|
|
|
|
|
$expected = "/testsuite \[.*CORE.*\]/";
|
2010-10-17 21:32:37 +00:00
|
|
|
$this->assertPattern($expected, $output);
|
2010-10-04 03:42:24 +00:00
|
|
|
|
2010-10-17 21:32:37 +00:00
|
|
|
$expected = "/sample \[.*app.*\]/";
|
2010-10-04 03:42:24 +00:00
|
|
|
$this->assertPattern($expected, $output);
|
|
|
|
}
|
2010-10-20 03:21:24 +00:00
|
|
|
|
2010-10-27 02:34:27 +00:00
|
|
|
/**
|
|
|
|
* Test the sort param
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testSortPlugin() {
|
|
|
|
$this->Shell->params['sort'] = true;
|
|
|
|
$this->Shell->main();
|
|
|
|
|
|
|
|
$output = $this->Shell->stdout->output;
|
|
|
|
|
|
|
|
$expected = "/\[.*App.*\]\n[ ]+sample/";
|
|
|
|
$this->assertPattern($expected, $output);
|
|
|
|
|
|
|
|
$expected = "/\[.*TestPluginTwo.*\]\n[ ]+example, welcome/";
|
|
|
|
$this->assertPattern($expected, $output);
|
|
|
|
|
|
|
|
$expected = "/\[.*TestPlugin.*\]\n[ ]+example/";
|
|
|
|
$this->assertPattern($expected, $output);
|
|
|
|
|
|
|
|
$expected = "/\[.*Core.*\]\n[ ]+acl, api, bake, command_list, console, i18n, schema, testsuite/";
|
|
|
|
$this->assertPattern($expected, $output);
|
|
|
|
}
|
|
|
|
|
2010-10-20 03:21:24 +00:00
|
|
|
/**
|
|
|
|
* test xml output.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testMainXml() {
|
|
|
|
$this->Shell->params['xml'] = true;
|
|
|
|
$this->Shell->main();
|
|
|
|
|
|
|
|
$output = $this->Shell->stdout->output;
|
|
|
|
|
|
|
|
$find = '<shell name="sample" call_as="sample" provider="app" help="sample -h"/>';
|
|
|
|
$this->assertContains($find, $output);
|
|
|
|
|
|
|
|
$find = '<shell name="bake" call_as="bake" provider="CORE" help="bake -h"/>';
|
|
|
|
$this->assertContains($find, $output);
|
|
|
|
|
|
|
|
$find = '<shell name="welcome" call_as="test_plugin_two.welcome" provider="TestPluginTwo" help="test_plugin_two.welcome -h"/>';
|
|
|
|
$this->assertContains($find, $output);
|
|
|
|
}
|
2010-10-04 03:42:24 +00:00
|
|
|
}
|