2008-04-28 14:39:52 +00:00
|
|
|
<?php
|
|
|
|
/* SVN FILE: $Id$ */
|
|
|
|
/**
|
|
|
|
* Short description for file.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
|
|
* Las Vegas, Nevada 89104
|
|
|
|
*
|
|
|
|
* Licensed under The Open Group Test Suite License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
|
|
|
* @filesource
|
|
|
|
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
2008-05-13 23:13:31 +00:00
|
|
|
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
2008-04-28 14:39:52 +00:00
|
|
|
* @package cake.tests
|
2008-05-13 23:13:31 +00:00
|
|
|
* @subpackage cake.tests.cases.console
|
2008-04-28 14:39:52 +00:00
|
|
|
* @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-13 23:13:31 +00:00
|
|
|
if (!defined('DISABLE_AUTO_DISPATCH')) {
|
|
|
|
define('DISABLE_AUTO_DISPATCH', true);
|
|
|
|
}
|
2008-04-28 14:39:52 +00:00
|
|
|
|
2008-05-13 23:13:31 +00:00
|
|
|
ob_start();
|
|
|
|
$argv = false;
|
|
|
|
require CAKE . 'console' . DS . 'cake.php';
|
|
|
|
$out = ob_get_clean();
|
2008-04-28 14:39:52 +00:00
|
|
|
|
|
|
|
|
2008-05-13 23:13:31 +00:00
|
|
|
class TestShellDispatcher extends ShellDispatcher {
|
2008-04-28 14:39:52 +00:00
|
|
|
|
2008-05-13 23:13:31 +00:00
|
|
|
var $params = array();
|
|
|
|
|
|
|
|
function __construct($args = array()) {
|
|
|
|
set_time_limit(0);
|
|
|
|
$this->__initConstants();
|
|
|
|
$this->parseParams($args);
|
2008-04-28 14:39:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs
|
|
|
|
*/
|
|
|
|
class ShellDispatcherTest extends UnitTestCase {
|
|
|
|
|
2008-05-13 23:13:31 +00:00
|
|
|
function testParseParams() {
|
|
|
|
$Dispatcher =& new TestShellDispatcher();
|
2008-04-28 14:39:52 +00:00
|
|
|
|
|
|
|
$params = array('/cake/1.2.x.x/cake/console/cake.php',
|
|
|
|
'bake',
|
|
|
|
'-app',
|
|
|
|
'new',
|
|
|
|
'-working',
|
|
|
|
'/var/www/htdocs'
|
|
|
|
);
|
|
|
|
|
|
|
|
$expected = array('app' => 'new',
|
|
|
|
'working' => '/var/www/htdocs/new',
|
|
|
|
'root' => '/var/www/htdocs'
|
|
|
|
);
|
2008-05-13 23:13:31 +00:00
|
|
|
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
2008-04-28 14:39:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
$params = array('cake.php');
|
|
|
|
|
|
|
|
$expected = array('app' => 'app',
|
|
|
|
'working' => ROOT . DS . 'app',
|
2008-05-13 23:13:31 +00:00
|
|
|
'root' => ROOT,
|
2008-04-28 14:39:52 +00:00
|
|
|
);
|
2008-05-13 23:13:31 +00:00
|
|
|
|
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
2008-04-28 14:39:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
$params = array('cake.php',
|
|
|
|
'-app',
|
|
|
|
'new',
|
|
|
|
);
|
|
|
|
|
|
|
|
$expected = array('app' => 'new',
|
|
|
|
'working' => ROOT . DS . 'new',
|
|
|
|
'root' => ROOT
|
|
|
|
);
|
2008-05-13 23:13:31 +00:00
|
|
|
|
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
2008-04-28 14:39:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
$params = array('./cake.php',
|
|
|
|
'bake',
|
|
|
|
'-app',
|
|
|
|
'new',
|
|
|
|
'-working',
|
|
|
|
' /cake/1.2.x.x/cake/console'
|
|
|
|
);
|
|
|
|
|
|
|
|
$expected = array('app' => 'new',
|
|
|
|
'working' => ROOT . DS . 'new',
|
|
|
|
'root' => ROOT
|
|
|
|
);
|
|
|
|
|
2008-05-13 23:13:31 +00:00
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
2008-04-28 14:39:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
$params = array('./console/cake.php',
|
|
|
|
'bake',
|
|
|
|
'-app',
|
|
|
|
'new',
|
|
|
|
'-working',
|
|
|
|
' /cake/1.2.x.x/cake'
|
|
|
|
);
|
|
|
|
|
|
|
|
$expected = array('app' => 'new',
|
|
|
|
'working' => ROOT . DS . 'new',
|
|
|
|
'root' => ROOT
|
|
|
|
);
|
2008-05-13 23:13:31 +00:00
|
|
|
|
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
2008-04-28 14:39:52 +00:00
|
|
|
|
|
|
|
$params = array('./console/cake.php',
|
|
|
|
'bake',
|
|
|
|
'-app',
|
|
|
|
'new',
|
|
|
|
'-dry',
|
|
|
|
'-working',
|
|
|
|
' /cake/1.2.x.x/cake'
|
|
|
|
);
|
|
|
|
|
|
|
|
$expected = array('app' => 'new',
|
|
|
|
'working' => ROOT . DS . 'new',
|
|
|
|
'root' => ROOT,
|
|
|
|
'dry' => 1
|
|
|
|
);
|
2008-05-13 23:13:31 +00:00
|
|
|
|
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
2008-04-28 14:39:52 +00:00
|
|
|
|
|
|
|
$params = array('./console/cake.php',
|
|
|
|
'-working',
|
|
|
|
'/cake/1.2.x.x/cake',
|
|
|
|
'schema',
|
|
|
|
'run',
|
|
|
|
'create',
|
|
|
|
'-dry',
|
|
|
|
'-f',
|
|
|
|
'-name',
|
|
|
|
'DbAcl'
|
|
|
|
);
|
|
|
|
$expected = array('app' => 'app',
|
|
|
|
'working' => ROOT . DS . 'app',
|
|
|
|
'root' => ROOT,
|
|
|
|
'dry' => 1,
|
|
|
|
'f' => 1,
|
|
|
|
'name' => 'DbAcl'
|
|
|
|
);
|
|
|
|
|
2008-05-13 23:13:31 +00:00
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
2008-04-28 14:39:52 +00:00
|
|
|
|
|
|
|
$expected = array('./console/cake.php', 'schema', 'run', 'create');
|
2008-05-13 23:13:31 +00:00
|
|
|
$this->assertEqual($expected, $Dispatcher->args);
|
2008-04-28 14:39:52 +00:00
|
|
|
|
|
|
|
$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',
|
|
|
|
'working' => '/cake/1.2.x.x/app',
|
|
|
|
'root' => '/cake/1.2.x.x',
|
|
|
|
'dry' => 1,
|
|
|
|
'name' => 'DbAcl'
|
|
|
|
);
|
|
|
|
|
2008-05-13 23:13:31 +00:00
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
2008-04-28 14:39:52 +00:00
|
|
|
|
2008-05-13 23:13:31 +00:00
|
|
|
$expected = array('/cake/1.2.x.x/cake/console/cake.php', 'schema', 'run', 'create');
|
|
|
|
$this->assertEqual($expected, $Dispatcher->args);
|
2008-05-14 01:10:24 +00:00
|
|
|
|
|
|
|
$params = array('cake.php',
|
|
|
|
'-working',
|
|
|
|
'C:\wamp\www\cake\app',
|
|
|
|
'bake',
|
|
|
|
'-app',
|
|
|
|
'C:\wamp\www\apps\cake\app',
|
|
|
|
);
|
|
|
|
|
|
|
|
$expected = array('app' => 'C:\wamp\www\apps\cake\app',
|
|
|
|
'working' => 'C:\wamp\www\cake\app',
|
|
|
|
'root' => ROOT
|
|
|
|
);
|
|
|
|
|
|
|
|
$Dispatcher->params = $Dispatcher->args = array();
|
|
|
|
$Dispatcher->parseParams($params);
|
|
|
|
$this->assertEqual($expected, $Dispatcher->params);
|
|
|
|
|
2008-04-28 14:39:52 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-14 01:10:24 +00:00
|
|
|
?>
|