2010-10-04 03:42:24 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* CommandList file
|
|
|
|
*
|
|
|
|
* PHP 5
|
|
|
|
*
|
|
|
|
* CakePHP : Rapid Development Framework (http://cakephp.org)
|
2011-05-29 21:31:39 +00:00
|
|
|
* Copyright 2005-2011, Cake Software Foundation, Inc.
|
2010-10-04 03:42:24 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2011-05-29 21:31:39 +00:00
|
|
|
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc.
|
2010-10-04 03:42:24 +00:00
|
|
|
* @link http://cakephp.org CakePHP Project
|
2010-12-24 18:57:20 +00:00
|
|
|
* @package cake.tests.cases.console.libs
|
2010-10-04 03:42:24 +00:00
|
|
|
* @since CakePHP v 2.0
|
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
|
|
|
*/
|
2010-12-09 05:13:11 +00:00
|
|
|
|
|
|
|
App::uses('CommandListShell', 'Console/Command');
|
2011-03-08 18:45:44 +00:00
|
|
|
App::uses('ConsoleOutput', 'Console');
|
|
|
|
App::uses('ConsoleInput', 'Console');
|
|
|
|
App::uses('Shell', 'Console');
|
2010-10-04 03:42:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
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(
|
2011-04-17 10:35:21 +00:00
|
|
|
CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS
|
2010-10-04 03:42:24 +00:00
|
|
|
),
|
2011-03-08 18:45:44 +00:00
|
|
|
'Console/Command' => array(
|
2011-04-17 10:35:21 +00:00
|
|
|
CAKE . 'Test' . DS . 'test_app' . DS . 'Console' . DS . 'Command' . DS
|
2010-10-04 03:42:24 +00:00
|
|
|
)
|
|
|
|
), true);
|
2011-05-12 04:54:45 +00:00
|
|
|
CakePlugin::loadAll();
|
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
|
|
|
|
*/
|
2011-05-30 20:02:32 +00:00
|
|
|
public function tearDown() {
|
2010-10-17 21:32:37 +00:00
|
|
|
parent::tearDown();
|
2010-10-24 19:11:30 +00:00
|
|
|
unset($this->Shell);
|
2011-05-12 04:54:45 +00:00
|
|
|
CakePlugin::unload();
|
2010-10-04 03:42:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* test that main finds core shells.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2011-05-30 20:02:32 +00:00
|
|
|
public function testMain() {
|
2010-10-04 03:42:24 +00:00
|
|
|
$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
|
|
|
|
2011-03-08 18:45:44 +00:00
|
|
|
|
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
|
|
|
|
*/
|
2011-05-30 20:02:32 +00:00
|
|
|
public function testSortPlugin() {
|
2010-10-27 02:34:27 +00:00
|
|
|
$this->Shell->params['sort'] = true;
|
|
|
|
$this->Shell->main();
|
|
|
|
|
|
|
|
$output = $this->Shell->stdout->output;
|
|
|
|
|
2011-06-21 16:44:36 +00:00
|
|
|
$expected = "/\[.*App.*\]\\v*[ ]+sample/";
|
2010-10-27 02:34:27 +00:00
|
|
|
$this->assertPattern($expected, $output);
|
|
|
|
|
2011-06-21 16:44:36 +00:00
|
|
|
$expected = "/\[.*TestPluginTwo.*\]\\v*[ ]+example, welcome/";
|
2010-10-27 02:34:27 +00:00
|
|
|
$this->assertPattern($expected, $output);
|
|
|
|
|
2011-06-21 16:44:36 +00:00
|
|
|
$expected = "/\[.*TestPlugin.*\]\\v*[ ]+example/";
|
2010-10-27 02:34:27 +00:00
|
|
|
$this->assertPattern($expected, $output);
|
2011-04-17 10:35:21 +00:00
|
|
|
|
2011-06-21 16:44:36 +00:00
|
|
|
$expected = "/\[.*Core.*\]\\v*[ ]+acl, api, bake, command_list, console, i18n, schema, testsuite/";
|
2010-10-27 02:34:27 +00:00
|
|
|
$this->assertPattern($expected, $output);
|
|
|
|
}
|
|
|
|
|
2010-10-20 03:21:24 +00:00
|
|
|
/**
|
|
|
|
* test xml output.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2011-05-30 20:02:32 +00:00
|
|
|
public function testMainXml() {
|
2010-10-20 03:21:24 +00:00
|
|
|
$this->Shell->params['xml'] = true;
|
|
|
|
$this->Shell->main();
|
|
|
|
|
|
|
|
$output = $this->Shell->stdout->output;
|
|
|
|
|
2011-06-21 16:44:36 +00:00
|
|
|
$find = '<shell name="sample" call_as="sample" provider="app" help="sample -h"/>';
|
2010-10-20 03:21:24 +00:00
|
|
|
$this->assertContains($find, $output);
|
|
|
|
|
|
|
|
$find = '<shell name="bake" call_as="bake" provider="CORE" help="bake -h"/>';
|
|
|
|
$this->assertContains($find, $output);
|
2011-05-12 04:54:45 +00:00
|
|
|
|
|
|
|
$find = '<shell name="welcome" call_as="TestPluginTwo.welcome" provider="TestPluginTwo" help="TestPluginTwo.welcome -h"/>';
|
2010-10-20 03:21:24 +00:00
|
|
|
$this->assertContains($find, $output);
|
|
|
|
}
|
2010-10-04 03:42:24 +00:00
|
|
|
}
|