2008-05-30 11:40:08 +00:00
|
|
|
<?php
|
|
|
|
/* SVN FILE: $Id$ */
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2009-03-18 17:55:58 +00:00
|
|
|
* ShellDispatcherTest file
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
|
|
|
* Long description for file
|
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
|
|
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
|
|
|
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
|
|
|
*
|
|
|
|
* Licensed under The Open Group Test Suite License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
|
|
|
* @filesource
|
2008-10-30 17:30:26 +00:00
|
|
|
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
|
|
|
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
2009-03-18 17:55:58 +00:00
|
|
|
* @package cake
|
2008-10-30 17:30:26 +00:00
|
|
|
* @subpackage cake.tests.cases.console
|
|
|
|
* @since CakePHP(tm) v 1.2.0.5432
|
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
|
|
|
if (!defined('DISABLE_AUTO_DISPATCH')) {
|
|
|
|
define('DISABLE_AUTO_DISPATCH', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!class_exists('ShellDispatcher')) {
|
|
|
|
ob_start();
|
|
|
|
$argv = false;
|
|
|
|
require CAKE . 'console' . DS . 'cake.php';
|
|
|
|
ob_end_clean();
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-07-30 18:26:23 +00:00
|
|
|
|
2009-04-30 17:25:58 +00:00
|
|
|
require_once CONSOLE_LIBS . 'shell.php';
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* TestShellDispatcher class
|
2008-06-26 03:50:11 +00:00
|
|
|
*
|
2008-10-30 17:30:26 +00:00
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.tests.cases.console
|
2008-06-02 19:22:55 +00:00
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
class TestShellDispatcher extends ShellDispatcher {
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* params property
|
2008-06-26 03:50:11 +00:00
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @var array
|
|
|
|
* @access public
|
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
var $params = array();
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
2008-11-13 00:33:53 +00:00
|
|
|
* stdout property
|
2008-06-26 03:50:11 +00:00
|
|
|
*
|
2008-11-13 00:33:53 +00:00
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
var $stdout = '';
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-11-13 00:33:53 +00:00
|
|
|
/**
|
|
|
|
* stderr property
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
var $stderr = '';
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-11-13 00:33:53 +00:00
|
|
|
/**
|
|
|
|
* stopped property
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
var $stopped = null;
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-04-30 17:25:58 +00:00
|
|
|
/**
|
|
|
|
* TestShell
|
|
|
|
*
|
|
|
|
* @var mixed
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
var $TestShell;
|
2008-11-13 00:33:53 +00:00
|
|
|
/**
|
|
|
|
* _initEnvironment method
|
|
|
|
*
|
|
|
|
* @access protected
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function _initEnvironment() {
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-11-13 00:33:53 +00:00
|
|
|
/**
|
|
|
|
* stderr method
|
|
|
|
*
|
|
|
|
* @access public
|
2008-06-02 19:22:55 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2008-11-13 00:33:53 +00:00
|
|
|
function stderr($string) {
|
|
|
|
$this->stderr .= rtrim($string, ' ');
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-11-13 00:33:53 +00:00
|
|
|
/**
|
|
|
|
* stdout method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function stdout($string, $newline = true) {
|
|
|
|
if ($newline) {
|
|
|
|
$this->stdout .= rtrim($string, ' ') . "\n";
|
|
|
|
} else {
|
|
|
|
$this->stdout .= rtrim($string, ' ');
|
|
|
|
}
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-07-26 01:27:02 +00:00
|
|
|
/**
|
|
|
|
* clear method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function clear() {
|
2009-07-26 09:59:51 +00:00
|
|
|
|
2009-07-26 01:27:02 +00:00
|
|
|
}
|
|
|
|
|
2008-11-13 00:33:53 +00:00
|
|
|
/**
|
|
|
|
* _stop method
|
|
|
|
*
|
|
|
|
* @access protected
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function _stop($status = 0) {
|
|
|
|
$this->stopped = 'Stopped with status: ' . $status;
|
2009-04-30 17:25:58 +00:00
|
|
|
return $status;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* getShell
|
|
|
|
*
|
|
|
|
* @param mixed $plugin
|
|
|
|
* @access public
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
function getShell($plugin = null) {
|
|
|
|
return $this->_getShell($plugin);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* _getShell
|
|
|
|
*
|
|
|
|
* @param mixed $plugin
|
|
|
|
* @access protected
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
function _getShell($plugin = null) {
|
|
|
|
if (isset($this->TestShell)) {
|
|
|
|
return $this->TestShell;
|
|
|
|
}
|
|
|
|
return parent::_getShell($plugin);
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2009-03-18 17:55:58 +00:00
|
|
|
* ShellDispatcherTest
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2009-03-18 17:55:58 +00:00
|
|
|
* @package cake
|
2008-10-30 17:30:26 +00:00
|
|
|
* @subpackage cake.tests.cases.libs
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2009-04-30 17:25:58 +00:00
|
|
|
class ShellDispatcherTest extends CakeTestCase {
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-11-13 00:33:53 +00:00
|
|
|
/**
|
|
|
|
* setUp method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function setUp() {
|
2009-06-11 16:13:16 +00:00
|
|
|
App::build(array(
|
|
|
|
'plugins' => array(
|
|
|
|
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
|
|
|
|
),
|
|
|
|
'shells' => array(
|
|
|
|
CORE_PATH ? CONSOLE_LIBS : ROOT . DS . CONSOLE_LIBS,
|
|
|
|
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS . 'shells' . DS
|
|
|
|
)
|
|
|
|
), true);
|
2008-11-13 00:33:53 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-11-13 00:33:53 +00:00
|
|
|
/**
|
|
|
|
* tearDown method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function tearDown() {
|
2009-06-11 16:13:16 +00:00
|
|
|
App::build();
|
2008-11-13 00:33:53 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* testParseParams method
|
2008-06-26 03:50:11 +00:00
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
function testParseParams() {
|
|
|
|
$Dispatcher =& new TestShellDispatcher();
|
|
|
|
|
|
|
|
$params = array(
|
|
|
|
'/cake/1.2.x.x/cake/console/cake.php',
|
|
|
|
'bake',
|
|
|
|
'-app',
|
|
|
|
'new',
|
|
|
|
'-working',
|
|
|
|
'/var/www/htdocs'
|
|
|
|
);
|
|
|
|
$expected = array(
|
|
|
|
'app' => 'new',
|
|
|
|
'webroot' => 'webroot',
|
|
|
|
'working' => '/var/www/htdocs/new',
|
|
|
|
'root' => '/var/www/htdocs'
|
|
|
|
);
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
|
|
|
|
|
|
|
$params = array('cake.php');
|
|
|
|
$expected = array(
|
|
|
|
'app' => 'app',
|
|
|
|
'webroot' => 'webroot',
|
2008-11-13 00:33:53 +00:00
|
|
|
'working' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH . DS . 'app'),
|
|
|
|
'root' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH),
|
2008-05-30 11:40:08 +00:00
|
|
|
);
|
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
|
|
|
|
|
|
|
$params = array(
|
|
|
|
'cake.php',
|
|
|
|
'-app',
|
|
|
|
'new',
|
|
|
|
);
|
|
|
|
$expected = array(
|
|
|
|
'app' => 'new',
|
|
|
|
'webroot' => 'webroot',
|
2008-11-13 00:33:53 +00:00
|
|
|
'working' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH . DS . 'new'),
|
|
|
|
'root' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH)
|
2008-05-30 11:40:08 +00:00
|
|
|
);
|
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
|
|
|
|
|
|
|
$params = array(
|
|
|
|
'./cake.php',
|
|
|
|
'bake',
|
|
|
|
'-app',
|
|
|
|
'new',
|
|
|
|
'-working',
|
|
|
|
'/cake/1.2.x.x/cake/console'
|
|
|
|
);
|
|
|
|
|
|
|
|
$expected = array(
|
|
|
|
'app' => 'new',
|
|
|
|
'webroot' => 'webroot',
|
2008-11-13 00:33:53 +00:00
|
|
|
'working' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH . DS . 'new'),
|
|
|
|
'root' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH)
|
2008-05-30 11:40:08 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
|
|
|
|
|
|
|
$params = array(
|
|
|
|
'./console/cake.php',
|
|
|
|
'bake',
|
|
|
|
'-app',
|
|
|
|
'new',
|
|
|
|
'-working',
|
|
|
|
'/cake/1.2.x.x/cake'
|
|
|
|
);
|
|
|
|
$expected = array(
|
|
|
|
'app' => 'new',
|
|
|
|
'webroot' => 'webroot',
|
2008-11-13 00:33:53 +00:00
|
|
|
'working' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH . DS . 'new'),
|
|
|
|
'root' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH)
|
2008-05-30 11:40:08 +00:00
|
|
|
);
|
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
|
|
|
|
|
|
|
$params = array(
|
|
|
|
'./console/cake.php',
|
|
|
|
'bake',
|
|
|
|
'-app',
|
|
|
|
'new',
|
|
|
|
'-dry',
|
|
|
|
'-working',
|
|
|
|
'/cake/1.2.x.x/cake'
|
|
|
|
);
|
|
|
|
$expected = array(
|
|
|
|
'app' => 'new',
|
|
|
|
'webroot' => 'webroot',
|
2008-11-13 00:33:53 +00:00
|
|
|
'working' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH . DS . 'new'),
|
|
|
|
'root' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH),
|
2008-05-30 11:40:08 +00:00
|
|
|
'dry' => 1
|
|
|
|
);
|
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
|
|
|
|
|
|
|
$params = array(
|
|
|
|
'./console/cake.php',
|
|
|
|
'-working',
|
|
|
|
'/cake/1.2.x.x/cake',
|
|
|
|
'schema',
|
|
|
|
'run',
|
|
|
|
'create',
|
|
|
|
'-dry',
|
|
|
|
'-f',
|
|
|
|
'-name',
|
|
|
|
'DbAcl'
|
|
|
|
);
|
|
|
|
$expected = array(
|
|
|
|
'app' => 'app',
|
|
|
|
'webroot' => 'webroot',
|
2008-11-13 00:33:53 +00:00
|
|
|
'working' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH . DS . 'app'),
|
|
|
|
'root' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH),
|
2008-05-30 11:40:08 +00:00
|
|
|
'dry' => 1,
|
|
|
|
'f' => 1,
|
|
|
|
'name' => 'DbAcl'
|
|
|
|
);
|
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
|
|
|
|
|
|
|
$expected = array('./console/cake.php', 'schema', 'run', 'create');
|
|
|
|
$this->assertEqual($expected, $Dispatcher->args);
|
|
|
|
|
|
|
|
$params = array(
|
|
|
|
'/cake/1.2.x.x/cake/console/cake.php',
|
|
|
|
'-working',
|
|
|
|
'/cake/1.2.x.x/app',
|
|
|
|
'schema',
|
|
|
|
'run',
|
|
|
|
'create',
|
|
|
|
'-dry',
|
|
|
|
'-name',
|
|
|
|
'DbAcl'
|
|
|
|
);
|
|
|
|
$expected = array(
|
|
|
|
'app' => 'app',
|
|
|
|
'webroot' => 'webroot',
|
|
|
|
'working' => '/cake/1.2.x.x/app',
|
|
|
|
'root' => '/cake/1.2.x.x',
|
|
|
|
'dry' => 1,
|
|
|
|
'name' => 'DbAcl'
|
|
|
|
);
|
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
|
|
|
|
|
|
|
$expected = array('/cake/1.2.x.x/cake/console/cake.php', 'schema', 'run', 'create');
|
|
|
|
$this->assertEqual($expected, $Dispatcher->args);
|
|
|
|
$params = array(
|
|
|
|
'cake.php',
|
|
|
|
'-working',
|
|
|
|
'C:/wamp/www/cake/app',
|
|
|
|
'bake',
|
|
|
|
'-app',
|
|
|
|
'C:/wamp/www/apps/cake/app',
|
|
|
|
);
|
|
|
|
$expected = array(
|
|
|
|
'app' => 'app',
|
|
|
|
'webroot' => 'webroot',
|
|
|
|
'working' => 'C:\wamp\www\apps\cake\app',
|
|
|
|
'root' => 'C:\wamp\www\apps\cake'
|
|
|
|
);
|
|
|
|
|
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
|
|
|
|
|
|
|
$params = array(
|
|
|
|
'cake.php',
|
|
|
|
'-working',
|
|
|
|
'C:\wamp\www\cake\app',
|
|
|
|
'bake',
|
|
|
|
'-app',
|
|
|
|
'C:\wamp\www\apps\cake\app',
|
|
|
|
);
|
|
|
|
$expected = array(
|
|
|
|
'app' => 'app',
|
|
|
|
'webroot' => 'webroot',
|
|
|
|
'working' => 'C:\wamp\www\apps\cake\app',
|
|
|
|
'root' => 'C:\wamp\www\apps\cake'
|
|
|
|
);
|
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
2008-06-26 03:50:11 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$params = array(
|
|
|
|
'cake.php',
|
|
|
|
'-working',
|
|
|
|
'C:\wamp\www\apps',
|
|
|
|
'bake',
|
|
|
|
'-app',
|
|
|
|
'cake\app',
|
|
|
|
'-url',
|
|
|
|
'http://example.com/some/url/with/a/path'
|
|
|
|
);
|
|
|
|
$expected = array(
|
|
|
|
'app' => 'app',
|
|
|
|
'webroot' => 'webroot',
|
|
|
|
'working' => 'C:\wamp\www\apps\cake\app',
|
|
|
|
'root' => 'C:\wamp\www\apps\cake',
|
|
|
|
'url' => 'http://example.com/some/url/with/a/path'
|
|
|
|
);
|
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
|
|
|
|
2008-06-26 03:50:11 +00:00
|
|
|
$params = array(
|
|
|
|
'/home/amelo/dev/cake-common/cake/console/cake.php',
|
|
|
|
'-root',
|
|
|
|
'/home/amelo/dev/lsbu-vacancy',
|
|
|
|
'-working',
|
|
|
|
'/home/amelo/dev/lsbu-vacancy',
|
|
|
|
'-app',
|
|
|
|
'app',
|
|
|
|
);
|
|
|
|
$expected = array(
|
|
|
|
'app' => 'app',
|
|
|
|
'webroot' => 'webroot',
|
|
|
|
'working' => '/home/amelo/dev/lsbu-vacancy/app',
|
|
|
|
'root' => '/home/amelo/dev/lsbu-vacancy',
|
|
|
|
);
|
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
2009-07-27 16:57:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
$params = array(
|
|
|
|
'cake.php',
|
|
|
|
'-working',
|
|
|
|
'D:\www',
|
|
|
|
'bake',
|
|
|
|
'my_app',
|
|
|
|
);
|
|
|
|
$expected = array(
|
|
|
|
'working' => 'D:\www',
|
|
|
|
'app' => 'www',
|
|
|
|
'root' => 'D:',
|
|
|
|
'webroot' => 'webroot'
|
|
|
|
);
|
|
|
|
|
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
2008-06-26 03:50:11 +00:00
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
2008-11-13 00:33:53 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-11-13 00:33:53 +00:00
|
|
|
/**
|
|
|
|
* testBuildPaths method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testBuildPaths() {
|
|
|
|
$Dispatcher =& new TestShellDispatcher();
|
2009-03-16 22:54:22 +00:00
|
|
|
|
|
|
|
$result = $Dispatcher->shellPaths;
|
2009-06-11 16:13:16 +00:00
|
|
|
|
2009-03-16 22:54:22 +00:00
|
|
|
$expected = array(
|
2008-11-13 00:33:53 +00:00
|
|
|
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'vendors' . DS . 'shells' . DS,
|
|
|
|
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin_two' . DS . 'vendors' . DS . 'shells' . DS,
|
|
|
|
APP . 'vendors' . DS . 'shells' . DS,
|
|
|
|
VENDORS . 'shells' . DS,
|
2009-03-16 22:54:22 +00:00
|
|
|
CORE_PATH ? CONSOLE_LIBS : ROOT . DS . CONSOLE_LIBS,
|
2008-11-13 00:33:53 +00:00
|
|
|
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS . 'shells' . DS,
|
2009-03-16 22:54:22 +00:00
|
|
|
);
|
|
|
|
$this->assertIdentical(array_diff($result, $expected), array());
|
|
|
|
$this->assertIdentical(array_diff($expected, $result), array());
|
2008-11-13 00:33:53 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-11-13 00:33:53 +00:00
|
|
|
/**
|
2009-04-30 17:25:58 +00:00
|
|
|
* Verify loading of (plugin-) shells
|
2008-11-13 00:33:53 +00:00
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2009-04-30 17:25:58 +00:00
|
|
|
function testGetShell() {
|
|
|
|
$this->skipIf(class_exists('SampleShell'), '%s SampleShell Class already loaded');
|
|
|
|
$this->skipIf(class_exists('ExampleShell'), '%s ExampleShell Class already loaded');
|
|
|
|
|
|
|
|
$Dispatcher =& new TestShellDispatcher();
|
|
|
|
|
|
|
|
$Dispatcher->shell = 'sample';
|
|
|
|
$Dispatcher->shellName = 'Sample';
|
|
|
|
$Dispatcher->shellClass = 'SampleShell';
|
2008-11-13 00:33:53 +00:00
|
|
|
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->getShell();
|
|
|
|
$this->assertIsA($result, 'SampleShell');
|
2008-11-13 00:33:53 +00:00
|
|
|
|
2009-04-30 17:25:58 +00:00
|
|
|
$Dispatcher =& new TestShellDispatcher();
|
|
|
|
|
|
|
|
$Dispatcher->shell = 'example';
|
|
|
|
$Dispatcher->shellName = 'Example';
|
|
|
|
$Dispatcher->shellClass = 'ExampleShell';
|
|
|
|
|
|
|
|
$result = $Dispatcher->getShell('test_plugin');
|
|
|
|
$this->assertIsA($result, 'ExampleShell');
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Verify correct dispatch of Shell subclasses with a main method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testDispatchShellWithMain() {
|
|
|
|
Mock::generate('Shell', 'MockWithMainShell', array('main', '_secret'));
|
|
|
|
|
|
|
|
$Dispatcher =& new TestShellDispatcher();
|
|
|
|
|
|
|
|
$Shell = new MockWithMainShell();
|
|
|
|
$Shell->setReturnValue('main', true);
|
|
|
|
$Shell->expectOnce('initialize');
|
|
|
|
$Shell->expectOnce('loadTasks');
|
|
|
|
$Shell->expectOnce('startup');
|
|
|
|
$Shell->expectOnce('main');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_with_main');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertTrue($result);
|
2009-05-01 10:08:56 +00:00
|
|
|
$this->assertEqual($Dispatcher->args, array());
|
2009-04-30 17:25:58 +00:00
|
|
|
|
|
|
|
$Shell = new MockWithMainShell();
|
|
|
|
$Shell->setReturnValue('main', true);
|
|
|
|
$Shell->expectOnce('startup');
|
|
|
|
$Shell->expectOnce('main');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_with_main', 'initdb');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertTrue($result);
|
2009-05-01 10:08:56 +00:00
|
|
|
$this->assertEqual($Dispatcher->args, array('initdb'));
|
2009-04-30 17:25:58 +00:00
|
|
|
|
2009-05-02 21:34:39 +00:00
|
|
|
$Shell = new MockWithMainShell();
|
|
|
|
$Shell->setReturnValue('main', true);
|
|
|
|
$Shell->expectOnce('startup');
|
|
|
|
$Shell->expectOnce('help');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
|
|
|
$Dispatcher->args = array('mock_with_main', 'help');
|
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertNull($result);
|
|
|
|
$this->assertEqual($Dispatcher->args, array());
|
|
|
|
|
2009-04-30 17:25:58 +00:00
|
|
|
$Shell = new MockWithMainShell();
|
|
|
|
$Shell->setReturnValue('main', true);
|
|
|
|
$Shell->expectNever('hr');
|
|
|
|
$Shell->expectOnce('startup');
|
|
|
|
$Shell->expectOnce('main');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_with_main', 'hr');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertTrue($result);
|
2009-05-01 10:08:56 +00:00
|
|
|
$this->assertEqual($Dispatcher->args, array('hr'));
|
2009-04-30 17:25:58 +00:00
|
|
|
|
|
|
|
$Shell = new MockWithMainShell();
|
|
|
|
$Shell->setReturnValue('main', true);
|
|
|
|
$Shell->expectOnce('startup');
|
|
|
|
$Shell->expectOnce('main');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_with_main', 'dispatch');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertTrue($result);
|
2009-05-01 10:08:56 +00:00
|
|
|
$this->assertEqual($Dispatcher->args, array('dispatch'));
|
2009-04-30 17:25:58 +00:00
|
|
|
|
|
|
|
$Shell = new MockWithMainShell();
|
|
|
|
$Shell->setReturnValue('main', true);
|
|
|
|
$Shell->expectOnce('startup');
|
|
|
|
$Shell->expectOnce('main');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_with_main', 'idontexist');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertTrue($result);
|
2009-05-01 10:08:56 +00:00
|
|
|
$this->assertEqual($Dispatcher->args, array('idontexist'));
|
2009-04-30 17:25:58 +00:00
|
|
|
|
|
|
|
$Shell = new MockWithMainShell();
|
|
|
|
$Shell->expectNever('startup');
|
|
|
|
$Shell->expectNever('main');
|
|
|
|
$Shell->expectNever('_secret');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_with_main', '_secret');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertFalse($result);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Verify correct dispatch of Shell subclasses without a main method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testDispatchShellWithoutMain() {
|
|
|
|
Mock::generate('Shell', 'MockWithoutMainShell', array('initDb', '_secret'));
|
|
|
|
|
|
|
|
$Dispatcher =& new TestShellDispatcher();
|
|
|
|
|
|
|
|
$Shell = new MockWithoutMainShell();
|
|
|
|
$Shell->setReturnValue('initDb', true);
|
|
|
|
$Shell->expectOnce('initialize');
|
|
|
|
$Shell->expectOnce('loadTasks');
|
|
|
|
$Shell->expectNever('startup');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_without_main');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertFalse($result);
|
2009-05-01 10:08:56 +00:00
|
|
|
$this->assertEqual($Dispatcher->args, array());
|
2009-04-30 17:25:58 +00:00
|
|
|
|
|
|
|
$Shell = new MockWithoutMainShell();
|
|
|
|
$Shell->setReturnValue('initDb', true);
|
|
|
|
$Shell->expectOnce('startup');
|
|
|
|
$Shell->expectOnce('initDb');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_without_main', 'initdb');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertTrue($result);
|
2009-05-01 10:08:56 +00:00
|
|
|
$this->assertEqual($Dispatcher->args, array());
|
2009-04-30 17:25:58 +00:00
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Shell = new MockWithoutMainShell();
|
2009-04-30 17:25:58 +00:00
|
|
|
$Shell->setReturnValue('initDb', true);
|
|
|
|
$Shell->expectNever('startup');
|
|
|
|
$Shell->expectNever('hr');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_without_main', 'hr');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
2009-05-01 10:08:56 +00:00
|
|
|
$this->assertFalse($result);
|
|
|
|
$this->assertEqual($Dispatcher->args, array('hr'));
|
2009-04-30 17:25:58 +00:00
|
|
|
|
|
|
|
$Shell = new MockWithoutMainShell();
|
|
|
|
$Shell->setReturnValue('initDb', true);
|
|
|
|
$Shell->expectNever('startup');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_without_main', 'dispatch');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertFalse($result);
|
|
|
|
|
|
|
|
$Shell = new MockWithoutMainShell();
|
|
|
|
$Shell->expectNever('startup');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_without_main', 'idontexist');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertFalse($result);
|
|
|
|
|
|
|
|
$Shell = new MockWithoutMainShell();
|
|
|
|
$Shell->expectNever('startup');
|
|
|
|
$Shell->expectNever('_secret');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_without_main', '_secret');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertFalse($result);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Verify correct dispatch of custom classes with a main method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testDispatchNotAShellWithMain() {
|
|
|
|
Mock::generate('Object', 'MockWithMainNotAShell',
|
|
|
|
array('main', 'initialize', 'loadTasks', 'startup', '_secret'));
|
|
|
|
|
|
|
|
$Dispatcher =& new TestShellDispatcher();
|
|
|
|
|
|
|
|
$Shell = new MockWithMainNotAShell();
|
|
|
|
$Shell->setReturnValue('main', true);
|
|
|
|
$Shell->expectNever('initialize');
|
|
|
|
$Shell->expectNever('loadTasks');
|
|
|
|
$Shell->expectOnce('startup');
|
|
|
|
$Shell->expectOnce('main');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_with_main_not_a');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertTrue($result);
|
2009-05-01 10:08:56 +00:00
|
|
|
$this->assertEqual($Dispatcher->args, array());
|
2009-04-30 17:25:58 +00:00
|
|
|
|
|
|
|
$Shell = new MockWithMainNotAShell();
|
|
|
|
$Shell->setReturnValue('main', true);
|
|
|
|
$Shell->expectOnce('startup');
|
|
|
|
$Shell->expectOnce('main');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_with_main_not_a', 'initdb');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertTrue($result);
|
2009-05-01 10:08:56 +00:00
|
|
|
$this->assertEqual($Dispatcher->args, array('initdb'));
|
2009-04-30 17:25:58 +00:00
|
|
|
|
|
|
|
$Shell = new MockWithMainNotAShell();
|
|
|
|
$Shell->setReturnValue('main', true);
|
|
|
|
$Shell->expectOnce('startup');
|
|
|
|
$Shell->expectOnce('main');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_with_main_not_a', 'hr');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertTrue($result);
|
2009-05-01 10:08:56 +00:00
|
|
|
$this->assertEqual($Dispatcher->args, array('hr'));
|
2009-04-30 17:25:58 +00:00
|
|
|
|
|
|
|
$Shell = new MockWithMainNotAShell();
|
|
|
|
$Shell->setReturnValue('main', true);
|
|
|
|
$Shell->expectOnce('startup');
|
|
|
|
$Shell->expectOnce('main');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_with_main_not_a', 'dispatch');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertTrue($result);
|
2009-05-01 10:08:56 +00:00
|
|
|
$this->assertEqual($Dispatcher->args, array('dispatch'));
|
2009-04-30 17:25:58 +00:00
|
|
|
|
|
|
|
$Shell = new MockWithMainNotAShell();
|
|
|
|
$Shell->setReturnValue('main', true);
|
|
|
|
$Shell->expectOnce('startup');
|
|
|
|
$Shell->expectOnce('main');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_with_main_not_a', 'idontexist');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertTrue($result);
|
2009-05-01 10:08:56 +00:00
|
|
|
$this->assertEqual($Dispatcher->args, array('idontexist'));
|
2009-04-30 17:25:58 +00:00
|
|
|
|
|
|
|
$Shell = new MockWithMainNotAShell();
|
|
|
|
$Shell->expectNever('startup');
|
|
|
|
$Shell->expectNever('main');
|
|
|
|
$Shell->expectNever('_secret');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_with_main_not_a', '_secret');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertFalse($result);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Verify correct dispatch of custom classes without a main method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testDispatchNotAShellWithoutMain() {
|
|
|
|
Mock::generate('Object', 'MockWithoutMainNotAShell',
|
|
|
|
array('initDb', 'initialize', 'loadTasks', 'startup', '_secret'));
|
|
|
|
|
|
|
|
$Dispatcher =& new TestShellDispatcher();
|
|
|
|
|
|
|
|
$Shell = new MockWithoutMainNotAShell();
|
|
|
|
$Shell->setReturnValue('initDb', true);
|
|
|
|
$Shell->expectNever('initialize');
|
|
|
|
$Shell->expectNever('loadTasks');
|
|
|
|
$Shell->expectNever('startup');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_without_main_not_a');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertFalse($result);
|
|
|
|
|
|
|
|
$Shell = new MockWithoutMainNotAShell();
|
|
|
|
$Shell->setReturnValue('initDb', true);
|
|
|
|
$Shell->expectOnce('startup');
|
|
|
|
$Shell->expectOnce('initDb');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_without_main_not_a', 'initdb');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertTrue($result);
|
2009-05-01 10:08:56 +00:00
|
|
|
$this->assertEqual($Dispatcher->args, array());
|
2009-04-30 17:25:58 +00:00
|
|
|
|
|
|
|
$Shell = new MockWithoutMainNotAShell();
|
|
|
|
$Shell->setReturnValue('initDb', true);
|
|
|
|
$Shell->expectNever('startup');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_without_main_not_a', 'hr');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertFalse($result);
|
|
|
|
|
|
|
|
$Shell = new MockWithoutMainNotAShell();
|
|
|
|
$Shell->setReturnValue('initDb', true);
|
|
|
|
$Shell->expectNever('startup');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_without_main_not_a', 'dispatch');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertFalse($result);
|
|
|
|
|
|
|
|
$Shell = new MockWithoutMainNotAShell();
|
|
|
|
$Shell->expectNever('startup');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_without_main_not_a', 'idontexist');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertFalse($result);
|
|
|
|
|
|
|
|
$Shell = new MockWithoutMainNotAShell();
|
|
|
|
$Shell->expectNever('startup');
|
|
|
|
$Shell->expectNever('_secret');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
2009-05-01 10:08:56 +00:00
|
|
|
$Dispatcher->args = array('mock_without_main_not_a', '_secret');
|
2009-04-30 17:25:58 +00:00
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertFalse($result);
|
2008-11-13 00:33:53 +00:00
|
|
|
}
|
2009-05-01 10:08:56 +00:00
|
|
|
/**
|
|
|
|
* Verify that a task is called instead of the shell if the first arg equals
|
|
|
|
* the name of the task
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testDispatchTask() {
|
|
|
|
Mock::generate('Shell', 'MockWeekShell', array('main'));
|
|
|
|
Mock::generate('Shell', 'MockOnSundayTask', array('execute'));
|
|
|
|
|
|
|
|
$Dispatcher =& new TestShellDispatcher();
|
|
|
|
|
|
|
|
$Shell = new MockWeekShell();
|
|
|
|
$Shell->expectOnce('initialize');
|
|
|
|
$Shell->expectOnce('loadTasks');
|
|
|
|
$Shell->expectNever('startup');
|
|
|
|
$Shell->expectNever('main');
|
|
|
|
|
|
|
|
$Task = new MockOnSundayTask();
|
|
|
|
$Task->setReturnValue('execute', true);
|
|
|
|
$Task->expectOnce('initialize');
|
|
|
|
$Task->expectOnce('loadTasks');
|
|
|
|
$Task->expectOnce('startup');
|
|
|
|
$Task->expectOnce('execute');
|
|
|
|
|
|
|
|
$Shell->MockOnSunday =& $Task;
|
|
|
|
$Shell->taskNames = array('MockOnSunday');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
|
|
|
$Dispatcher->args = array('mock_week', 'mock_on_sunday');
|
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertTrue($result);
|
|
|
|
$this->assertEqual($Dispatcher->args, array());
|
2009-05-02 21:34:39 +00:00
|
|
|
|
|
|
|
$Shell = new MockWeekShell();
|
|
|
|
$Task = new MockOnSundayTask();
|
|
|
|
$Task->expectNever('execute');
|
|
|
|
$Task->expectOnce('help');
|
|
|
|
|
|
|
|
$Shell->MockOnSunday =& $Task;
|
|
|
|
$Shell->taskNames = array('MockOnSunday');
|
|
|
|
$Dispatcher->TestShell =& $Shell;
|
|
|
|
|
|
|
|
$Dispatcher->args = array('mock_week', 'mock_on_sunday', 'help');
|
|
|
|
$result = $Dispatcher->dispatch();
|
|
|
|
$this->assertTrue($result);
|
2009-05-01 10:08:56 +00:00
|
|
|
}
|
2009-05-01 01:47:33 +00:00
|
|
|
/**
|
|
|
|
* Verify shifting of arguments
|
2008-11-13 00:33:53 +00:00
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2009-05-01 01:47:33 +00:00
|
|
|
function testShiftArgs() {
|
|
|
|
$Dispatcher =& new TestShellDispatcher();
|
|
|
|
|
|
|
|
$Dispatcher->args = array('a', 'b', 'c');
|
|
|
|
$this->assertEqual($Dispatcher->shiftArgs(), 'a');
|
|
|
|
$this->assertIdentical($Dispatcher->args, array('b', 'c'));
|
|
|
|
|
|
|
|
$Dispatcher->args = array('a' => 'b', 'c', 'd');
|
|
|
|
$this->assertEqual($Dispatcher->shiftArgs(), 'b');
|
|
|
|
$this->assertIdentical($Dispatcher->args, array('c', 'd'));
|
2008-11-13 00:33:53 +00:00
|
|
|
|
2009-05-01 01:47:33 +00:00
|
|
|
$Dispatcher->args = array('a', 'b' => 'c', 'd');
|
|
|
|
$this->assertEqual($Dispatcher->shiftArgs(), 'a');
|
|
|
|
$this->assertIdentical($Dispatcher->args, array('b' => 'c', 'd'));
|
2008-11-13 00:33:53 +00:00
|
|
|
|
2009-05-01 01:47:33 +00:00
|
|
|
$Dispatcher->args = array(0 => 'a', 2 => 'b', 30 => 'c');
|
|
|
|
$this->assertEqual($Dispatcher->shiftArgs(), 'a');
|
|
|
|
$this->assertIdentical($Dispatcher->args, array(0 => 'b', 1 => 'c'));
|
|
|
|
|
|
|
|
$Dispatcher->args = array();
|
|
|
|
$this->assertNull($Dispatcher->shiftArgs());
|
|
|
|
$this->assertIdentical($Dispatcher->args, array());
|
2008-11-13 00:33:53 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-11-13 00:33:53 +00:00
|
|
|
/**
|
|
|
|
* testHelpCommand method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testHelpCommand() {
|
|
|
|
$Dispatcher =& new TestShellDispatcher();
|
|
|
|
|
2009-03-16 22:54:22 +00:00
|
|
|
$expected = "/ CORE(\\\|\/)tests(\\\|\/)test_app(\\\|\/)plugins(\\\|\/)test_plugin(\\\|\/)vendors(\\\|\/)shells:";
|
2008-11-13 00:33:53 +00:00
|
|
|
$expected .= "\n\t example";
|
|
|
|
$expected .= "\n/";
|
|
|
|
$this->assertPattern($expected, $Dispatcher->stdout);
|
|
|
|
|
2009-03-16 22:54:22 +00:00
|
|
|
$expected = "/ CORE(\\\|\/)tests(\\\|\/)test_app(\\\|\/)plugins(\\\|\/)test_plugin_two(\\\|\/)vendors(\\\|\/)shells:";
|
2008-11-13 00:33:53 +00:00
|
|
|
$expected .= "\n\t example";
|
|
|
|
$expected .= "\n\t welcome";
|
|
|
|
$expected .= "\n/";
|
|
|
|
$this->assertPattern($expected, $Dispatcher->stdout);
|
|
|
|
|
2009-03-16 22:54:22 +00:00
|
|
|
$expected = "/ APP(\\\|\/)vendors(\\\|\/)shells:";
|
2008-11-13 00:33:53 +00:00
|
|
|
$expected .= "\n/";
|
|
|
|
$this->assertPattern($expected, $Dispatcher->stdout);
|
|
|
|
|
|
|
|
$expected = "/ ROOT(\\\|\/)vendors(\\\|\/)shells:";
|
|
|
|
$expected .= "\n/";
|
|
|
|
$this->assertPattern($expected, $Dispatcher->stdout);
|
|
|
|
|
2009-03-16 22:54:22 +00:00
|
|
|
$expected = "/ CORE(\\\|\/)console(\\\|\/)libs:";
|
2008-11-13 00:33:53 +00:00
|
|
|
$expected .= "\n\t acl";
|
|
|
|
$expected .= "\n\t api";
|
|
|
|
$expected .= "\n\t bake";
|
|
|
|
$expected .= "\n\t console";
|
|
|
|
$expected .= "\n\t i18n";
|
|
|
|
$expected .= "\n\t schema";
|
|
|
|
$expected .= "\n\t testsuite";
|
|
|
|
$expected .= "\n/";
|
|
|
|
$this->assertPattern($expected, $Dispatcher->stdout);
|
2008-06-26 03:50:11 +00:00
|
|
|
|
2009-03-16 22:54:22 +00:00
|
|
|
$expected = "/ CORE(\\\|\/)tests(\\\|\/)test_app(\\\|\/)vendors(\\\|\/)shells:";
|
2008-11-13 00:33:53 +00:00
|
|
|
$expected .= "\n\t sample";
|
|
|
|
$expected .= "\n/";
|
2009-04-30 17:25:58 +00:00
|
|
|
$this->assertPattern($expected, $Dispatcher->stdout);
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
}
|
2008-06-26 03:50:11 +00:00
|
|
|
?>
|