mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
Refactoring dispatcher.
Added test for changes to Dispatcher. Updating Model::_ _saveMulti(), moved the insert statement to DboSource::insertMulti() this will allow database that do not support multiple inserts in one statement to save data. git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5460 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
31c3447682
commit
549d86ac23
76 changed files with 812 additions and 409 deletions
|
@ -78,6 +78,7 @@
|
||||||
trigger_error("Can't find CakePHP core. Check the value of CAKE_CORE_INCLUDE_PATH in app/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
|
trigger_error("Can't find CakePHP core. Check the value of CAKE_CORE_INCLUDE_PATH in app/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
|
||||||
}
|
}
|
||||||
if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
|
if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
$Dispatcher = new Dispatcher();
|
$Dispatcher = new Dispatcher();
|
||||||
$Dispatcher->dispatch($url);
|
$Dispatcher->dispatch($url);
|
||||||
|
|
|
@ -74,10 +74,11 @@ if (empty( $_GET['output'])) {
|
||||||
$_GET['output'] = 'html';
|
$_GET['output'] = 'html';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defined('BASE_URL')) {
|
|
||||||
$dispatch =& new Dispatcher();
|
$dispatch =& new Dispatcher();
|
||||||
define('BASE_URL', $dispatch->baseUrl());
|
$dispatch->base = env('SCRIPT_NAME');
|
||||||
}
|
$dispatch->baseUrl();
|
||||||
|
define('BASE', $dispatch->webroot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Used to determine output to display
|
* Used to determine output to display
|
||||||
|
@ -179,7 +180,7 @@ if (!vendor('simpletest' . DS . 'reporter')) {
|
||||||
function CakePHPTestHeader() {
|
function CakePHPTestHeader() {
|
||||||
switch (CAKE_TEST_OUTPUT) {
|
switch (CAKE_TEST_OUTPUT) {
|
||||||
case CAKE_TEST_OUTPUT_HTML:
|
case CAKE_TEST_OUTPUT_HTML:
|
||||||
$baseUrl = BASE_URL;
|
$baseUrl = BASE;
|
||||||
$characterSet = 'ISO-8859-1';
|
$characterSet = 'ISO-8859-1';
|
||||||
include CAKE . 'tests' . DS . 'lib' . DS . 'header.php';
|
include CAKE . 'tests' . DS . 'lib' . DS . 'header.php';
|
||||||
break;
|
break;
|
||||||
|
@ -203,7 +204,7 @@ if (!vendor('simpletest' . DS . 'reporter')) {
|
||||||
function CakePHPTestSuiteFooter() {
|
function CakePHPTestSuiteFooter() {
|
||||||
switch ( CAKE_TEST_OUTPUT) {
|
switch ( CAKE_TEST_OUTPUT) {
|
||||||
case CAKE_TEST_OUTPUT_HTML:
|
case CAKE_TEST_OUTPUT_HTML:
|
||||||
$baseUrl = BASE_URL;
|
$baseUrl = BASE;
|
||||||
include CAKE . 'tests' . DS . 'lib' . DS . 'footer.php';
|
include CAKE . 'tests' . DS . 'lib' . DS . 'footer.php';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,6 +320,7 @@
|
||||||
if ($name === null) {
|
if ($name === null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($name, '.') !== false) {
|
if (strpos($name, '.') !== false) {
|
||||||
list($plugin, $name) = explode('.', $name);
|
list($plugin, $name) = explode('.', $name);
|
||||||
|
|
||||||
|
@ -364,7 +365,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$className = $name . 'Controller';
|
$className = $name . 'Controller';
|
||||||
if (!class_exists($className)) {
|
if (class_exists($className)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
$name = Inflector::underscore($className);
|
$name = Inflector::underscore($className);
|
||||||
$controllers = Configure::read('Controllers');
|
$controllers = Configure::read('Controllers');
|
||||||
if (is_array($controllers)) {
|
if (is_array($controllers)) {
|
||||||
|
@ -1003,7 +1006,50 @@
|
||||||
$uri = env('PHP_SELF') . '/' . env('QUERY_STRING');
|
$uri = env('PHP_SELF') . '/' . env('QUERY_STRING');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return preg_replace('/\?url=\//', '', $uri);
|
return str_replace('//', '/', preg_replace('/\?url=/', '/', $uri));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Returns and sets the $_GET[url] derived from the REQUEST_INFO
|
||||||
|
*
|
||||||
|
* @param string $uri
|
||||||
|
* @return string URL
|
||||||
|
*/
|
||||||
|
function setUrl($uri = null, $script = null) {
|
||||||
|
if ($uri == null) {
|
||||||
|
$uri = setUri();
|
||||||
|
}
|
||||||
|
if ($script == null) {
|
||||||
|
if (defined('BASE_URL')) {
|
||||||
|
$script = BASE_URL;
|
||||||
|
} else {
|
||||||
|
$script = env('SCRIPT_NAME');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$url = null;
|
||||||
|
if ($uri === '/' || $uri === $script || $uri === '/'.APP_DIR.'/') {
|
||||||
|
$url = $_GET['url'] = '/';
|
||||||
|
} else {
|
||||||
|
if (strpos($uri, $script) !== false) {
|
||||||
|
$elements = explode($script, $uri);
|
||||||
|
} elseif (strpos($uri, APP_DIR) !== false) {
|
||||||
|
$elements = explode(APP_DIR, $uri);
|
||||||
|
} elseif (preg_match('/^[\/\?\/|\/\?|\?\/]/', $uri)) {
|
||||||
|
$elements = array(1 => preg_replace('/^[\/\?\/|\/\?|\?\/]/', '', $uri));
|
||||||
|
} else {
|
||||||
|
$elements = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($elements[1])) {
|
||||||
|
$_GET['url'] = $elements[1];
|
||||||
|
$url = $elements[1];
|
||||||
|
} else {
|
||||||
|
$url = $_GET['url'] = '/';
|
||||||
|
}
|
||||||
|
if (strpos($url, '/') === 0 && $url != '/') {
|
||||||
|
$url = $_GET['url'] = substr($url, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $url;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets an environment variable from available sources, and provides emulation
|
* Gets an environment variable from available sources, and provides emulation
|
||||||
|
|
|
@ -36,14 +36,14 @@ if (!defined('PHP5')) {
|
||||||
require CORE_PATH . 'cake' . DS . 'basics.php';
|
require CORE_PATH . 'cake' . DS . 'basics.php';
|
||||||
require APP_PATH . 'config' . DS . 'core.php';
|
require APP_PATH . 'config' . DS . 'core.php';
|
||||||
require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
|
require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
|
||||||
|
require LIBS . 'object.php';
|
||||||
|
require LIBS . 'configure.php';
|
||||||
}
|
}
|
||||||
$TIME_START = getMicrotime();
|
$TIME_START = getMicrotime();
|
||||||
require LIBS . 'object.php';
|
|
||||||
require LIBS . 'cache.php';
|
require LIBS . 'cache.php';
|
||||||
require LIBS . 'session.php';
|
require LIBS . 'session.php';
|
||||||
require LIBS . 'security.php';
|
require LIBS . 'security.php';
|
||||||
require LIBS . 'inflector.php';
|
require LIBS . 'inflector.php';
|
||||||
require LIBS . 'configure.php';
|
|
||||||
$paths = Configure::getInstance();
|
$paths = Configure::getInstance();
|
||||||
|
|
||||||
if (isset($cakeCache)) {
|
if (isset($cakeCache)) {
|
||||||
|
@ -73,31 +73,7 @@ if (!defined('PHP5')) {
|
||||||
* Get the application path and request URL
|
* Get the application path and request URL
|
||||||
*/
|
*/
|
||||||
if (empty($uri) && defined('BASE_URL')) {
|
if (empty($uri) && defined('BASE_URL')) {
|
||||||
$uri = setUri();
|
$url = setUrl();
|
||||||
|
|
||||||
if ($uri === '/' || $uri === '/index.php' || $uri === '/'.APP_DIR.'/') {
|
|
||||||
$_GET['url'] = '/';
|
|
||||||
$url = '/';
|
|
||||||
} else {
|
|
||||||
if (strpos($uri, 'index.php') !== false) {
|
|
||||||
$uri = r('?', '', $uri);
|
|
||||||
$elements = explode('/index.php', $uri);
|
|
||||||
} elseif (preg_match('/^[\/\?\/|\/\?|\?\/]/', $uri)) {
|
|
||||||
$elements = array(1 => preg_replace('/^[\/\?\/|\/\?|\?\/]/', '', $uri));
|
|
||||||
} else {
|
|
||||||
$elements = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($elements[1])) {
|
|
||||||
$_GET['url'] = $elements[1];
|
|
||||||
$url = $elements[1];
|
|
||||||
} else {
|
|
||||||
$url = $_GET['url'] = '/';
|
|
||||||
}
|
|
||||||
if (strpos($url, '/') === 0 && $url != '/') {
|
|
||||||
$url = $_GET['url'] = substr($url, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (empty($_GET['url'])) {
|
if (empty($_GET['url'])) {
|
||||||
$url = null;
|
$url = null;
|
||||||
|
|
|
@ -74,8 +74,11 @@
|
||||||
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
|
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
require CORE_PATH . 'cake' . DS . 'bootstrap.php';
|
if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) {
|
||||||
|
trigger_error("Can't find CakePHP core. Check the value of CAKE_CORE_INCLUDE_PATH in app/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
|
||||||
|
}
|
||||||
if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
|
if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
$Dispatcher = new Dispatcher();
|
$Dispatcher = new Dispatcher();
|
||||||
$Dispatcher->dispatch($url);
|
$Dispatcher->dispatch($url);
|
||||||
|
|
|
@ -74,10 +74,11 @@ if (empty( $_GET['output'])) {
|
||||||
$_GET['output'] = 'html';
|
$_GET['output'] = 'html';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defined('BASE_URL')) {
|
|
||||||
$dispatch =& new Dispatcher();
|
$dispatch =& new Dispatcher();
|
||||||
define('BASE_URL', $dispatch->baseUrl());
|
$dispatch->base = env('SCRIPT_NAME');
|
||||||
}
|
$dispatch->baseUrl();
|
||||||
|
define('BASE', $dispatch->webroot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Used to determine output to display
|
* Used to determine output to display
|
||||||
|
@ -179,7 +180,7 @@ if (!vendor('simpletest' . DS . 'reporter')) {
|
||||||
function CakePHPTestHeader() {
|
function CakePHPTestHeader() {
|
||||||
switch (CAKE_TEST_OUTPUT) {
|
switch (CAKE_TEST_OUTPUT) {
|
||||||
case CAKE_TEST_OUTPUT_HTML:
|
case CAKE_TEST_OUTPUT_HTML:
|
||||||
$baseUrl = BASE_URL;
|
$baseUrl = BASE;
|
||||||
$characterSet = 'ISO-8859-1';
|
$characterSet = 'ISO-8859-1';
|
||||||
include CAKE . 'tests' . DS . 'lib' . DS . 'header.php';
|
include CAKE . 'tests' . DS . 'lib' . DS . 'header.php';
|
||||||
break;
|
break;
|
||||||
|
@ -203,7 +204,7 @@ if (!vendor('simpletest' . DS . 'reporter')) {
|
||||||
function CakePHPTestSuiteFooter() {
|
function CakePHPTestSuiteFooter() {
|
||||||
switch ( CAKE_TEST_OUTPUT) {
|
switch ( CAKE_TEST_OUTPUT) {
|
||||||
case CAKE_TEST_OUTPUT_HTML:
|
case CAKE_TEST_OUTPUT_HTML:
|
||||||
$baseUrl = BASE_URL;
|
$baseUrl = BASE;
|
||||||
include CAKE . 'tests' . DS . 'lib' . DS . 'footer.php';
|
include CAKE . 'tests' . DS . 'lib' . DS . 'footer.php';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,8 +78,11 @@ class Dispatcher extends Object {
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
function __construct() {
|
function __construct($url = null) {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
if ($url !== null) {
|
||||||
|
return $this->dispatch($url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Dispatches and invokes given URL, handing over control to the involved controllers, and then renders the results (if autoRender is set).
|
* Dispatches and invokes given URL, handing over control to the involved controllers, and then renders the results (if autoRender is set).
|
||||||
|
@ -96,62 +99,41 @@ class Dispatcher extends Object {
|
||||||
*/
|
*/
|
||||||
function dispatch($url, $additionalParams = array()) {
|
function dispatch($url, $additionalParams = array()) {
|
||||||
$params = array_merge($this->parseParams($url), $additionalParams);
|
$params = array_merge($this->parseParams($url), $additionalParams);
|
||||||
$missingController = false;
|
$missingAction = $missingView = $privateAction = false;
|
||||||
$missingAction = false;
|
|
||||||
$missingView = false;
|
|
||||||
$privateAction = false;
|
|
||||||
$this->base = $this->baseUrl();
|
$this->base = $this->baseUrl();
|
||||||
|
|
||||||
if (empty($params['controller'])) {
|
$pluginPath = null;
|
||||||
$missingController = true;
|
if (!empty($params['plugin'])) {
|
||||||
} else {
|
$this->plugin = $params['plugin'];
|
||||||
|
$pluginPath = Inflector::camelize($this->plugin).'.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($params['controller'])) {
|
||||||
$ctrlName = Inflector::camelize($params['controller']);
|
$ctrlName = Inflector::camelize($params['controller']);
|
||||||
$ctrlClass = $ctrlName.'Controller';
|
$ctrlClass = $ctrlName.'Controller';
|
||||||
|
}
|
||||||
|
|
||||||
if (!loadController($ctrlName)) {
|
if (!loadController($pluginPath . $ctrlName)) {
|
||||||
$pluginName = Inflector::camelize($params['action']);
|
|
||||||
if (!loadController($ctrlName . '.' . $pluginName)) {
|
|
||||||
if (preg_match('/([\\.]+)/', $ctrlName)) {
|
if (preg_match('/([\\.]+)/', $ctrlName)) {
|
||||||
Router::setRequestInfo(array($params, array('base' => $this->base, 'webroot' => $this->webroot)));
|
Router::setRequestInfo(array($params, array('base' => $this->base, 'webroot' => $this->webroot)));
|
||||||
|
|
||||||
return $this->cakeError('error404',
|
return $this->cakeError('error404', array(array('url' => strtolower($ctrlName),
|
||||||
array(array('url' => strtolower($ctrlName),
|
|
||||||
'message' => 'Was not found on this server',
|
'message' => 'Was not found on this server',
|
||||||
'base' => $this->base)));
|
'base' => $this->base)));
|
||||||
} elseif (!class_exists($ctrlClass)) {
|
|
||||||
$missingController = true;
|
|
||||||
} else {
|
} else {
|
||||||
$params['plugin'] = null;
|
Router::setRequestInfo(array($params, array('base' => $this->base, 'webroot' => $this->webroot)));
|
||||||
$this->plugin = null;
|
return $this->cakeError('missingController', array(
|
||||||
|
array(
|
||||||
|
'className' => Inflector::camelize($params['controller']."Controller"),
|
||||||
|
'webroot' => $this->webroot,
|
||||||
|
'url' => $url,
|
||||||
|
'base' => $this->base
|
||||||
|
)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$params['plugin'] = Inflector::underscore($ctrlName);
|
$controller =& new $ctrlClass();
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$params['plugin'] = null;
|
|
||||||
$this->plugin = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($params['plugin'])) {
|
|
||||||
$plugin = $params['plugin'];
|
|
||||||
$pluginName = Inflector::camelize($params['action']);
|
|
||||||
$pluginClass = $pluginName.'Controller';
|
|
||||||
$ctrlClass = $pluginClass;
|
|
||||||
$oldAction = $params['action'];
|
|
||||||
$params = $this->_restructureParams($params);
|
|
||||||
$this->plugin = $plugin;
|
|
||||||
loadPluginModels($plugin);
|
|
||||||
$this->base = $this->base.'/'.Inflector::underscore($ctrlName);
|
|
||||||
|
|
||||||
if (empty($params['controller']) || !class_exists($pluginClass)) {
|
|
||||||
$params['controller'] = Inflector::underscore($ctrlName);
|
|
||||||
$ctrlClass = $ctrlName.'Controller';
|
|
||||||
if (!is_null($params['action'])) {
|
|
||||||
array_unshift($params['pass'], $params['action']);
|
|
||||||
}
|
|
||||||
$params['action'] = $oldAction;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($params['action'])) {
|
if (empty($params['action'])) {
|
||||||
|
@ -167,42 +149,22 @@ class Dispatcher extends Object {
|
||||||
$privateAction = true;
|
$privateAction = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$base = Router::stripPlugin($this->base, $this->plugin);
|
|
||||||
if (defined('BASE_URL')) {
|
|
||||||
$this->here = $base . $this->admin . $url;
|
|
||||||
} else {
|
|
||||||
$this->here = $base . $this->admin . '/' . $url;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($missingController) {
|
$this->here = $this->base . $this->admin . '/' . $url;
|
||||||
Router::setRequestInfo(array($params, array('base' => $this->base, 'webroot' => $this->webroot)));
|
|
||||||
return $this->cakeError('missingController', array(
|
|
||||||
array(
|
|
||||||
'className' => Inflector::camelize($params['controller']."Controller"),
|
|
||||||
'webroot' => $this->webroot,
|
|
||||||
'url' => $url,
|
|
||||||
'base' => $this->base
|
|
||||||
)
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
$controller =& new $ctrlClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
$classMethods = get_class_methods($controller);
|
|
||||||
$classVars = get_object_vars($controller);
|
|
||||||
|
|
||||||
if ((in_array($params['action'], $classMethods) || in_array(strtolower($params['action']), $classMethods)) && strpos($params['action'], '_', 0) === 0) {
|
$protected = array('constructclasses', 'redirect', 'set', 'setAction', 'isauthorized', 'validate', 'validateerrors',
|
||||||
|
'render', 'referer', 'disablecache', 'flash', 'generatefieldnames', 'postconditions', 'cleanupfields',
|
||||||
|
'paginate', 'beforefilter', 'beforerender', 'afterfilter', 'object', 'tostring', 'requestaction', 'log',
|
||||||
|
'cakeerror');
|
||||||
|
|
||||||
|
$classMethods = array_map("low", get_class_methods($controller));
|
||||||
|
|
||||||
|
if (in_array(low($params['action']), $protected) || strpos($params['action'], '_', 0) === 0) {
|
||||||
$privateAction = true;
|
$privateAction = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array($params['action'], $classMethods) && !in_array(strtolower($params['action']), $classMethods)) {
|
if (!in_array(low($params['action']), $classMethods)) {
|
||||||
$missingAction = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(strtolower($params['action']), array(
|
|
||||||
'object', 'tostring', 'requestaction', 'log', 'cakeerror', 'constructclasses', 'redirect', 'set', 'setaction',
|
|
||||||
'validate', 'validateerrors', 'render', 'referer', 'flash', 'flashout', 'generatefieldnames',
|
|
||||||
'postconditions', 'cleanupfields', 'beforefilter', 'beforerender', 'afterfilter', 'disablecache', 'paginate'))) {
|
|
||||||
$missingAction = true;
|
$missingAction = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +176,13 @@ class Dispatcher extends Object {
|
||||||
$controller->here = $this->here;
|
$controller->here = $this->here;
|
||||||
$controller->webroot = $this->webroot;
|
$controller->webroot = $this->webroot;
|
||||||
$controller->params = $params;
|
$controller->params = $params;
|
||||||
|
$controller->plugin = $this->plugin;
|
||||||
$controller->action = $params['action'];
|
$controller->action = $params['action'];
|
||||||
|
$controller->webservices = $params['webservices'];
|
||||||
|
|
||||||
|
list($passedArgs, $namedArgs) = Router::getArgs($params, $controller->namedArgs, $controller->argSeparator);
|
||||||
|
$controller->passedArgs = $passedArgs;
|
||||||
|
$controller->namedArgs = $namedArgs;
|
||||||
|
|
||||||
if (!empty($controller->params['data'])) {
|
if (!empty($controller->params['data'])) {
|
||||||
$controller->data =& $controller->params['data'];
|
$controller->data =& $controller->params['data'];
|
||||||
|
@ -222,65 +190,10 @@ class Dispatcher extends Object {
|
||||||
$controller->data = null;
|
$controller->data = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$namedArgs = array();
|
|
||||||
if (is_array($controller->namedArgs)) {
|
|
||||||
if (array_key_exists($params['action'], $controller->namedArgs)) {
|
|
||||||
$namedArgs = $controller->namedArgs[$params['action']];
|
|
||||||
} else {
|
|
||||||
$namedArgs = $controller->namedArgs;
|
|
||||||
}
|
|
||||||
$controller->namedArgs = true;
|
|
||||||
}
|
|
||||||
if (!empty($controller->params['pass'])) {
|
|
||||||
$controller->passedArgs =& $controller->params['pass'];
|
|
||||||
if ($controller->namedArgs === true) {
|
|
||||||
$controller->namedArgs = array();
|
|
||||||
$c = count($controller->passedArgs);
|
|
||||||
for ($i = 0; $i <= $c; $i++) {
|
|
||||||
if (isset($controller->passedArgs[$i]) && strpos($controller->passedArgs[$i], $controller->argSeparator) !== false) {
|
|
||||||
list($argKey, $argVal) = explode($controller->argSeparator, $controller->passedArgs[$i]);
|
|
||||||
if (empty($namedArgs) || (!empty($namedArgs) && in_array($argKey, array_keys($namedArgs)))) {
|
|
||||||
$controller->passedArgs[$argKey] = $argVal;
|
|
||||||
$controller->namedArgs[$argKey] = $argVal;
|
|
||||||
unset($controller->passedArgs[$i]);
|
|
||||||
unset($params['pass'][$i]);
|
|
||||||
}
|
|
||||||
} elseif ($controller->argSeparator === '/') {
|
|
||||||
$ii = $i + 1;
|
|
||||||
if (isset($controller->passedArgs[$i]) && isset($controller->passedArgs[$ii])) {
|
|
||||||
$argKey = $controller->passedArgs[$i];
|
|
||||||
$argVal = $controller->passedArgs[$ii];
|
|
||||||
if (empty($namedArgs) || (!empty($namedArgs) && in_array($argKey, array_keys($namedArgs)))) {
|
|
||||||
$controller->passedArgs[$argKey] = $argVal;
|
|
||||||
$controller->namedArgs[$argKey] = $argVal;
|
|
||||||
unset($controller->passedArgs[$i], $controller->passedArgs[$ii]);
|
|
||||||
unset($params['pass'][$i], $params['pass'][$ii]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$controller->passedArgs = am($namedArgs, $controller->passedArgs);
|
|
||||||
$controller->namedArgs = am($namedArgs, $controller->namedArgs);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$controller->passedArgs = null;
|
|
||||||
if ($controller->namedArgs === true) {
|
|
||||||
$controller->passedArgs = array();
|
|
||||||
$controller->namedArgs = array();
|
|
||||||
$controller->passedArgs = am($namedArgs, $controller->passedArgs);
|
|
||||||
$controller->namedArgs = am($namedArgs, $controller->namedArgs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($params['bare'])) {
|
if (!empty($params['bare'])) {
|
||||||
$controller->autoLayout = !$params['bare'];
|
$controller->autoLayout = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$controller->webservices = $params['webservices'];
|
|
||||||
$controller->plugin = $this->plugin;
|
|
||||||
if (isset($params['viewPath'])) {
|
|
||||||
$controller->viewPath = $params['viewPath'];
|
|
||||||
}
|
|
||||||
if (isset($params['layout'])) {
|
if (isset($params['layout'])) {
|
||||||
if ($params['layout'] === '') {
|
if ($params['layout'] === '') {
|
||||||
$controller->autoLayout = false;
|
$controller->autoLayout = false;
|
||||||
|
@ -289,6 +202,10 @@ class Dispatcher extends Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($params['viewPath'])) {
|
||||||
|
$controller->viewPath = $params['viewPath'];
|
||||||
|
}
|
||||||
|
|
||||||
foreach (array('components', 'helpers') as $var) {
|
foreach (array('components', 'helpers') as $var) {
|
||||||
if (isset($params[$var]) && !empty($params[$var]) && is_array($controller->{$var})) {
|
if (isset($params[$var]) && !empty($params[$var]) && is_array($controller->{$var})) {
|
||||||
$diff = array_diff($params[$var], $controller->{$var});
|
$diff = array_diff($params[$var], $controller->{$var});
|
||||||
|
@ -304,19 +221,6 @@ class Dispatcher extends Object {
|
||||||
$controller->_initComponents();
|
$controller->_initComponents();
|
||||||
$controller->constructClasses();
|
$controller->constructClasses();
|
||||||
|
|
||||||
if ($missingAction && !in_array('scaffold', array_keys($classVars))) {
|
|
||||||
$this->start($controller);
|
|
||||||
return $this->cakeError('missingAction', array(
|
|
||||||
array(
|
|
||||||
'className' => Inflector::camelize($params['controller']."Controller"),
|
|
||||||
'action' => $params['action'],
|
|
||||||
'webroot' => $this->webroot,
|
|
||||||
'url' => $url,
|
|
||||||
'base' => $this->base
|
|
||||||
)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($privateAction) {
|
if ($privateAction) {
|
||||||
$this->start($controller);
|
$this->start($controller);
|
||||||
return $this->cakeError('privateAction', array(
|
return $this->cakeError('privateAction', array(
|
||||||
|
@ -349,12 +253,24 @@ class Dispatcher extends Object {
|
||||||
if ($missingAction && in_array('scaffold', array_keys($classVars))) {
|
if ($missingAction && in_array('scaffold', array_keys($classVars))) {
|
||||||
uses('controller'. DS . 'scaffold');
|
uses('controller'. DS . 'scaffold');
|
||||||
return new Scaffold($controller, $params);
|
return new Scaffold($controller, $params);
|
||||||
|
} elseif ($missingAction && !in_array('scaffold', array_keys($classVars))) {
|
||||||
|
return $this->cakeError('missingAction', array(
|
||||||
|
array(
|
||||||
|
'className' => Inflector::camelize($params['controller']."Controller"),
|
||||||
|
'action' => $params['action'],
|
||||||
|
'webroot' => $this->webroot,
|
||||||
|
'url' => $this->here,
|
||||||
|
'base' => $this->base
|
||||||
|
)
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
$output = call_user_func_array(array(&$controller, $params['action']), empty($params['pass'])? null: $params['pass']);
|
$output = call_user_func_array(array(&$controller, $params['action']), empty($params['pass'])? null: $params['pass']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($controller->autoRender) {
|
if ($controller->autoRender) {
|
||||||
$output = $controller->render();
|
$output = $controller->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
$controller->output =& $output;
|
$controller->output =& $output;
|
||||||
|
|
||||||
foreach ($controller->components as $c) {
|
foreach ($controller->components as $c) {
|
||||||
|
@ -417,13 +333,13 @@ class Dispatcher extends Object {
|
||||||
include CONFIGS.'routes.php';
|
include CONFIGS.'routes.php';
|
||||||
$params = Router::parse($fromUrl);
|
$params = Router::parse($fromUrl);
|
||||||
|
|
||||||
|
if (isset($_POST)) {
|
||||||
if (ini_get('magic_quotes_gpc') == 1) {
|
if (ini_get('magic_quotes_gpc') == 1) {
|
||||||
if (!empty($_POST)) {
|
|
||||||
$params['form'] = stripslashes_deep($_POST);
|
$params['form'] = stripslashes_deep($_POST);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$params['form'] = $_POST;
|
$params['form'] = $_POST;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($params['form']['data'])) {
|
if (isset($params['form']['data'])) {
|
||||||
$params['data'] = Router::stripEscape($params['form']['data']);
|
$params['data'] = Router::stripEscape($params['form']['data']);
|
||||||
|
@ -463,61 +379,66 @@ class Dispatcher extends Object {
|
||||||
return $params;
|
return $params;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns a base URL.
|
* Returns a base URL and sets the proper webroot
|
||||||
*
|
*
|
||||||
* @return string Base URL
|
* @return string Base URL
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function baseUrl() {
|
function baseUrl() {
|
||||||
$htaccess = null;
|
$base = $this->base;
|
||||||
$base = $this->admin;
|
|
||||||
$this->webroot = '';
|
|
||||||
|
|
||||||
if (defined('BASE_URL')) {
|
|
||||||
$base = BASE_URL.$this->admin;
|
|
||||||
}
|
|
||||||
|
|
||||||
$docRoot = env('DOCUMENT_ROOT');
|
|
||||||
$scriptName = env('PHP_SELF');
|
|
||||||
$r = null;
|
|
||||||
$appDirName = str_replace('/','\/',preg_quote(APP_DIR));
|
|
||||||
$webrootDirName = str_replace('/', '\/', preg_quote(WEBROOT_DIR));
|
|
||||||
|
|
||||||
if (preg_match('/'.$appDirName.'\\'.DS.$webrootDirName.'/', $docRoot)) {
|
|
||||||
$this->webroot = '/';
|
$this->webroot = '/';
|
||||||
|
|
||||||
if (preg_match('/^(.*)\/index\.php$/', $scriptName, $r)) {
|
$baseUrl = Configure::read('baseUrl');
|
||||||
|
$app = Configure::read('app');
|
||||||
|
$webroot = Configure::read('webroot');
|
||||||
|
|
||||||
if (!empty($r[1])) {
|
$file = $script = null;
|
||||||
return $base.$r[1];
|
if (!$baseUrl && $this->base == false) {
|
||||||
}
|
$docRoot = env('DOCUMENT_ROOT');
|
||||||
}
|
$script = env('SCRIPT_FILENAME');
|
||||||
} else {
|
$base = r($docRoot, '', $script);
|
||||||
if (defined('BASE_URL')) {
|
} elseif ($baseUrl && $this->base == false) {
|
||||||
$webroot = setUri();
|
$base = $baseUrl;
|
||||||
$htaccess = preg_replace('/(?:'.APP_DIR.'\\/(.*)|index\\.php(.*))/i', '', $webroot).APP_DIR.'/'.$webrootDirName.'/';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('/^(.*)\\/'.$appDirName.'\\/'.$webrootDirName.'\\/index\\.php$/', $scriptName, $regs)) {
|
$file = basename($base);
|
||||||
|
if (($baseUrl || $this->base) && strpos($file, '.php') !== false) {
|
||||||
if (APP_DIR === 'app') {
|
$baseUrl = true;
|
||||||
$appDir = null;
|
$file = '/'. $file;
|
||||||
} else {
|
|
||||||
$appDir = '/'.APP_DIR;
|
|
||||||
}
|
}
|
||||||
!empty($htaccess)? $this->webroot = $htaccess : $this->webroot = $regs[1].$appDir.'/';
|
|
||||||
return $base.$regs[1].$appDir;
|
|
||||||
|
|
||||||
} elseif (preg_match('/^(.*)\\/'.$webrootDirName.'([^\/i]*)|index\\\.php$/', $scriptName, $regs)) {
|
$base = dirname($base);
|
||||||
!empty($htaccess)? $this->webroot = $htaccess : $this->webroot = $regs[0].'/';
|
|
||||||
return $base.$regs[0];
|
|
||||||
|
|
||||||
} else {
|
if ($base == '/' || $base == '.') {
|
||||||
!empty($htaccess)? $this->webroot = $htaccess : $this->webroot = '/';
|
$base = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$baseUrl && strpos($script, $app) !== false && $app === 'app') {
|
||||||
|
$base = str_replace($app.'/', '', $base);
|
||||||
|
}
|
||||||
|
|
||||||
|
$base = str_replace('//', '/', str_replace('/'.$webroot, '', $base));
|
||||||
|
|
||||||
|
$this->webroot = $base .'/';
|
||||||
|
|
||||||
|
if (!$baseUrl) {
|
||||||
return $base;
|
return $base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($baseUrl && $base == '') {
|
||||||
|
return $file;
|
||||||
}
|
}
|
||||||
return $base;
|
|
||||||
|
if (strpos($base, $app) === false) {
|
||||||
|
$this->webroot .= '/' . $app . '/' ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($baseUrl && strpos($this->webroot, $webroot) === false) {
|
||||||
|
$this->webroot .= $webroot . '/';
|
||||||
|
}
|
||||||
|
$this->webroot = str_replace('//', '/', $this->webroot);
|
||||||
|
|
||||||
|
return $base . $file;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Restructure params in case we're serving a plugin.
|
* Restructure params in case we're serving a plugin.
|
||||||
|
|
|
@ -452,6 +452,14 @@ class Configure extends Object {
|
||||||
$_this->__buildHelperPaths($helperPaths);
|
$_this->__buildHelperPaths($helperPaths);
|
||||||
$_this->__buildComponentPaths($componentPaths);
|
$_this->__buildComponentPaths($componentPaths);
|
||||||
$_this->__buildBehaviorPaths($behaviorPaths);
|
$_this->__buildBehaviorPaths($behaviorPaths);
|
||||||
|
|
||||||
|
$_this->write('app', APP_DIR);
|
||||||
|
$_this->write('webroot', WEBROOT_DIR);
|
||||||
|
$baseUrl = false;
|
||||||
|
if (defined('BASE_URL')) {
|
||||||
|
$baseUrl = BASE_URL;
|
||||||
|
}
|
||||||
|
$_this->write('baseUrl', $baseUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -421,6 +421,18 @@ class DboAdodb extends DboSource {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Inserts multiple values into a join table
|
||||||
|
*
|
||||||
|
* @param string $table
|
||||||
|
* @param string $fields
|
||||||
|
* @param array $values
|
||||||
|
*/
|
||||||
|
function insertMulti($table, $fields, $values) {
|
||||||
|
$count = count($values);
|
||||||
|
for ($x = 0; $x < $count; $x++) {
|
||||||
|
$this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -496,5 +496,18 @@ class DboFirebird extends DboSource {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Inserts multiple values into a join table
|
||||||
|
*
|
||||||
|
* @param string $table
|
||||||
|
* @param string $fields
|
||||||
|
* @param array $values
|
||||||
|
*/
|
||||||
|
function insertMulti($table, $fields, $values) {
|
||||||
|
$count = count($values);
|
||||||
|
for ($x = 0; $x < $count; $x++) {
|
||||||
|
$this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -585,6 +585,18 @@ class DboMssql extends DboSource {
|
||||||
$query = trim(r($search, $replace, $schema));
|
$query = trim(r($search, $replace, $schema));
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Inserts multiple values into a join table
|
||||||
|
*
|
||||||
|
* @param string $table
|
||||||
|
* @param string $fields
|
||||||
|
* @param array $values
|
||||||
|
*/
|
||||||
|
function insertMulti($table, $fields, $values) {
|
||||||
|
$count = count($values);
|
||||||
|
for ($x = 0; $x < $count; $x++) {
|
||||||
|
$this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -667,6 +667,18 @@ class DboOracle extends DboSource {
|
||||||
}
|
}
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Inserts multiple values into a join table
|
||||||
|
*
|
||||||
|
* @param string $table
|
||||||
|
* @param string $fields
|
||||||
|
* @param array $values
|
||||||
|
*/
|
||||||
|
function insertMulti($table, $fields, $values) {
|
||||||
|
$count = count($values);
|
||||||
|
for ($x = 0; $x < $count; $x++) {
|
||||||
|
$this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -224,5 +224,18 @@ class DboPear extends DboSource{
|
||||||
function selectLimit($limit, $offset = '0') {
|
function selectLimit($limit, $offset = '0') {
|
||||||
return ' ' . $this->_pear->modifyLimitQuery('', $offset, $limit);
|
return ' ' . $this->_pear->modifyLimitQuery('', $offset, $limit);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Inserts multiple values into a join table
|
||||||
|
*
|
||||||
|
* @param string $table
|
||||||
|
* @param string $fields
|
||||||
|
* @param array $values
|
||||||
|
*/
|
||||||
|
function insertMulti($table, $fields, $values) {
|
||||||
|
$count = count($values);
|
||||||
|
for ($x = 0; $x < $count; $x++) {
|
||||||
|
$this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -393,6 +393,18 @@ class DboSqlite extends DboSource {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Inserts multiple values into a join table
|
||||||
|
*
|
||||||
|
* @param string $table
|
||||||
|
* @param string $fields
|
||||||
|
* @param array $values
|
||||||
|
*/
|
||||||
|
function insertMulti($table, $fields, $values) {
|
||||||
|
$count = count($values);
|
||||||
|
for ($x = 0; $x < $count; $x++) {
|
||||||
|
$this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -392,5 +392,18 @@ class DboSybase extends DboSource {
|
||||||
$query = trim(r($search, $replace, $schema));
|
$query = trim(r($search, $replace, $schema));
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Inserts multiple values into a join table
|
||||||
|
*
|
||||||
|
* @param string $table
|
||||||
|
* @param string $fields
|
||||||
|
* @param array $values
|
||||||
|
*/
|
||||||
|
function insertMulti($table, $fields, $values) {
|
||||||
|
$count = count($values);
|
||||||
|
for ($x = 0; $x < $count; $x++) {
|
||||||
|
$this->query("INSERT INTO {$table} ({$fields}) VALUES {$values[$x]}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -1814,6 +1814,16 @@ class DboSource extends DataSource {
|
||||||
$this->close();
|
$this->close();
|
||||||
parent::__destruct();
|
parent::__destruct();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Inserts multiple values into a join table
|
||||||
|
*
|
||||||
|
* @param string $table
|
||||||
|
* @param string $fields
|
||||||
|
* @param array $values
|
||||||
|
*/
|
||||||
|
function insertMulti($table, $fields, $values) {
|
||||||
|
$values = implode(', ', $values);
|
||||||
|
$this->query("INSERT INTO {$table} ({$fields}) VALUES {$values}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -1111,8 +1111,7 @@ class Model extends Overloadable {
|
||||||
$db->query("DELETE FROM {$table} WHERE {$mainKey[$loopAssoc]} = '{$id}'");
|
$db->query("DELETE FROM {$table} WHERE {$mainKey[$loopAssoc]} = '{$id}'");
|
||||||
|
|
||||||
if (!empty($newValue[$loopAssoc])) {
|
if (!empty($newValue[$loopAssoc])) {
|
||||||
$insertValues = implode(', ', $newValue[$loopAssoc]);
|
$db->insertMulti($table, $fields[$loopAssoc], $newValue[$loopAssoc]);
|
||||||
$db->query("INSERT INTO {$table} ({$fields[$loopAssoc]}) VALUES {$insertValues};");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,61 @@
|
||||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
*/
|
*/
|
||||||
require_once CAKE.'dispatcher.php';
|
require_once CAKE.'dispatcher.php';
|
||||||
|
|
||||||
|
class TestDispatcher extends Dispatcher {
|
||||||
|
|
||||||
|
function _invoke(&$controller, $params, $missingAction) {
|
||||||
|
$this->start($controller);
|
||||||
|
$classVars = get_object_vars($controller);
|
||||||
|
if ($missingAction && in_array('scaffold', array_keys($classVars))) {
|
||||||
|
uses('controller'. DS . 'scaffold');
|
||||||
|
return new Scaffold($controller, $params);
|
||||||
|
} elseif ($missingAction && !in_array('scaffold', array_keys($classVars))) {
|
||||||
|
return $this->cakeError('missingAction', array(
|
||||||
|
array(
|
||||||
|
'className' => Inflector::camelize($params['controller']."Controller"),
|
||||||
|
'action' => $params['action'],
|
||||||
|
'webroot' => $this->webroot,
|
||||||
|
'url' => $this->here,
|
||||||
|
'base' => $this->base
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return $controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
function start(&$controller) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
function cakeError($filename) {
|
||||||
|
return $filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyPluginAppController extends Controller {
|
||||||
|
|
||||||
|
}
|
||||||
|
class SomePagesController extends MyPluginAppController {
|
||||||
|
|
||||||
|
var $name = 'SomePages';
|
||||||
|
var $uses = array();
|
||||||
|
|
||||||
|
function display($page = null) {
|
||||||
|
return $page;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestDispatchPagesController extends Controller {
|
||||||
|
|
||||||
|
var $name = 'TestDispatchPages';
|
||||||
|
var $uses = array();
|
||||||
|
|
||||||
|
function admin_index() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
|
@ -35,6 +90,15 @@
|
||||||
*/
|
*/
|
||||||
class DispatcherTest extends UnitTestCase {
|
class DispatcherTest extends UnitTestCase {
|
||||||
|
|
||||||
|
function setUp() {
|
||||||
|
$this->_get = $_GET;
|
||||||
|
$_GET = array();
|
||||||
|
Configure::write('baseUrl', false);
|
||||||
|
Configure::write('app', 'app');
|
||||||
|
Configure::write('webroot', 'webroot');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function testParseParamsWithoutZerosAndEmptyPost() {
|
function testParseParamsWithoutZerosAndEmptyPost() {
|
||||||
$dispatcher =& new Dispatcher();
|
$dispatcher =& new Dispatcher();
|
||||||
$test = $dispatcher->parseParams("/testcontroller/testaction/params1/params2/params3");
|
$test = $dispatcher->parseParams("/testcontroller/testaction/params1/params2/params3");
|
||||||
|
@ -96,5 +160,304 @@ class DispatcherTest extends UnitTestCase {
|
||||||
$this->assertPattern('/\\A(?:000030)\\z/', $test['pass'][4]);
|
$this->assertPattern('/\\A(?:000030)\\z/', $test['pass'][4]);
|
||||||
$this->assertPattern('/\\A(?:0000400)\\z/', $test['pass'][5]);
|
$this->assertPattern('/\\A(?:0000400)\\z/', $test['pass'][5]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testSetUrl() {
|
||||||
|
$uri = '/app/webroot/index.php/posts/add';
|
||||||
|
$_SERVER['SCRIPT_NAME'] = '/app/webroot/index.php';
|
||||||
|
$result = setUrl($uri);
|
||||||
|
$expected = 'posts/add';
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
|
||||||
|
$uri = APP_DIR . '/posts/add';
|
||||||
|
$_SERVER['SCRIPT_NAME'] = APP_DIR . '/webroot/index.php';
|
||||||
|
$result = setUrl($uri);
|
||||||
|
$expected = 'posts/add';
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
|
||||||
|
$uri = '/posts/add';
|
||||||
|
$_SERVER['SCRIPT_NAME'] = '/app/webroot/index.php';
|
||||||
|
$result = setUrl($uri);
|
||||||
|
$expected = 'posts/add';
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testBaseUrlAndWebrootWithModRewrite() {
|
||||||
|
$dispatcher =& new Dispatcher();
|
||||||
|
|
||||||
|
Configure::write('app', 'app');
|
||||||
|
Configure::write('webroot', 'webroot');
|
||||||
|
Configure::write('baseUrl', false);
|
||||||
|
|
||||||
|
$dispatcher->base = false;
|
||||||
|
$_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches';
|
||||||
|
$_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/app/webroot/index.php';
|
||||||
|
$result = $dispatcher->baseUrl();
|
||||||
|
$expected = '/1.2.x.x';
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
$expectedWebroot = '/1.2.x.x/';
|
||||||
|
$this->assertEqual($expectedWebroot, $dispatcher->webroot);
|
||||||
|
|
||||||
|
$dispatcher->base = false;
|
||||||
|
$_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches/1.2.x.x/app/webroot';
|
||||||
|
$_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/app/webroot/index.php';
|
||||||
|
$result = $dispatcher->baseUrl();
|
||||||
|
$expected = '';
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
$expectedWebroot = '/';
|
||||||
|
$this->assertEqual($expectedWebroot, $dispatcher->webroot);
|
||||||
|
|
||||||
|
|
||||||
|
Configure::write('app', 'auth');
|
||||||
|
|
||||||
|
$dispatcher->base = false;;
|
||||||
|
$_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches';
|
||||||
|
$_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/demos/auth/webroot/index.php';
|
||||||
|
$result = $dispatcher->baseUrl();
|
||||||
|
$expected = '/demos/auth';
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
$expectedWebroot = '/demos/auth/';
|
||||||
|
$this->assertEqual($expectedWebroot, $dispatcher->webroot);
|
||||||
|
|
||||||
|
Configure::write('app', 'code');
|
||||||
|
|
||||||
|
$dispatcher->base = false;;
|
||||||
|
$_SERVER['DOCUMENT_ROOT'] = '/Library/WebServer/Documents';
|
||||||
|
$_SERVER['SCRIPT_FILENAME'] = '/Library/WebServer/Documents/clients/PewterReport/code/webroot/index.php';
|
||||||
|
$result = $dispatcher->baseUrl();
|
||||||
|
$expected = '/clients/PewterReport/code';
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
$expectedWebroot = '/clients/PewterReport/code/';
|
||||||
|
$this->assertEqual($expectedWebroot, $dispatcher->webroot);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function testBaseUrlAndWebrootWithBaseUrl() {
|
||||||
|
$dispatcher =& new Dispatcher();
|
||||||
|
|
||||||
|
Configure::write('app', 'app');
|
||||||
|
|
||||||
|
Configure::write('baseUrl', '/app/webroot/index.php');
|
||||||
|
$result = $dispatcher->baseUrl();
|
||||||
|
$expected = '/app/index.php';
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
$expectedWebroot = '/app/webroot/';
|
||||||
|
$this->assertEqual($expectedWebroot, $dispatcher->webroot);
|
||||||
|
|
||||||
|
Configure::write('baseUrl', '/app/webroot/test.php');
|
||||||
|
$result = $dispatcher->baseUrl();
|
||||||
|
$expected = '/app/test.php';
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
$expectedWebroot = '/app/webroot/';
|
||||||
|
$this->assertEqual($expectedWebroot, $dispatcher->webroot);
|
||||||
|
|
||||||
|
Configure::write('baseUrl', '/app/index.php');
|
||||||
|
$result = $dispatcher->baseUrl();
|
||||||
|
$expected = '/app/index.php';
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
$expectedWebroot = '/app/webroot/';
|
||||||
|
$this->assertEqual($expectedWebroot, $dispatcher->webroot);
|
||||||
|
|
||||||
|
Configure::write('baseUrl', '/index.php');
|
||||||
|
$result = $dispatcher->baseUrl();
|
||||||
|
$expected = '/index.php';
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
$expectedWebroot = '/';
|
||||||
|
$this->assertEqual($expectedWebroot, $dispatcher->webroot);
|
||||||
|
|
||||||
|
Configure::write('baseUrl', '/CakeBB/app/webroot/index.php');
|
||||||
|
$result = $dispatcher->baseUrl();
|
||||||
|
$expected = '/CakeBB/app/index.php';
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
$expectedWebroot = '/CakeBB/app/webroot/';
|
||||||
|
$this->assertEqual($expectedWebroot, $dispatcher->webroot);
|
||||||
|
|
||||||
|
Configure::write('baseUrl', '/CakeBB/app/index.php');
|
||||||
|
$result = $dispatcher->baseUrl();
|
||||||
|
$expected = '/CakeBB/app/index.php';
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
$expectedWebroot = '/CakeBB/app/webroot/';
|
||||||
|
$this->assertEqual($expectedWebroot, $dispatcher->webroot);
|
||||||
|
|
||||||
|
|
||||||
|
Configure::write('baseUrl', '/CakeBB/index.php');
|
||||||
|
$result = $dispatcher->baseUrl();
|
||||||
|
$expected = '/CakeBB/index.php';
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
$expectedWebroot = '/CakeBB/app/webroot/';
|
||||||
|
$this->assertEqual($expectedWebroot, $dispatcher->webroot);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function testBaseUrlAndWebrootWithBase() {
|
||||||
|
$dispatcher =& new Dispatcher();
|
||||||
|
Configure::write('baseUrl',false);
|
||||||
|
$dispatcher->base = '/app/webroot';
|
||||||
|
$result = $dispatcher->baseUrl();
|
||||||
|
$expected = '/app';
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
$expectedWebroot = '/app/';
|
||||||
|
$this->assertEqual($expectedWebroot, $dispatcher->webroot);
|
||||||
|
|
||||||
|
$dispatcher->base = '/app';
|
||||||
|
$result = $dispatcher->baseUrl();
|
||||||
|
$expected = '';
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
$expectedWebroot = '/';
|
||||||
|
$this->assertEqual($expectedWebroot, $dispatcher->webroot);
|
||||||
|
|
||||||
|
Configure::write('app', 'testbed');
|
||||||
|
$dispatcher->base = '/cake/testbed/webroot/test.php';
|
||||||
|
$result = $dispatcher->baseUrl();
|
||||||
|
$expected = '/cake/testbed/test.php';
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
$expectedWebroot = '/cake/testbed/webroot/';
|
||||||
|
$this->assertEqual($expectedWebroot, $dispatcher->webroot);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testMissingController() {
|
||||||
|
$dispatcher =& new TestDispatcher();
|
||||||
|
$dispatcher->base = '/index.php';
|
||||||
|
$url = setUrl('/some_controller/home/param:value/param2:value2');
|
||||||
|
|
||||||
|
restore_error_handler();
|
||||||
|
@$controller = $dispatcher->dispatch($url, array('return'=> 1));
|
||||||
|
set_error_handler('simpleTestErrorHandler');
|
||||||
|
|
||||||
|
$expected = 'missingController';
|
||||||
|
$this->assertEqual($expected, $controller);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testPrivate() {
|
||||||
|
$dispatcher =& new TestDispatcher();
|
||||||
|
$dispatcher->base = '/index.php';
|
||||||
|
$url = setUrl('/some_pages/redirect/param:value/param2:value2');
|
||||||
|
|
||||||
|
restore_error_handler();
|
||||||
|
@$controller = $dispatcher->dispatch($url, array('return'=> 1));
|
||||||
|
set_error_handler('simpleTestErrorHandler');
|
||||||
|
|
||||||
|
$expected = 'privateAction';
|
||||||
|
$this->assertEqual($expected, $controller);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testMissingAction() {
|
||||||
|
$dispatcher =& new TestDispatcher();
|
||||||
|
$dispatcher->base = '/index.php';
|
||||||
|
$url = setUrl('/some_pages/home/param:value/param2:value2');
|
||||||
|
|
||||||
|
restore_error_handler();
|
||||||
|
@$controller = $dispatcher->dispatch($url, array('return'=> 1));
|
||||||
|
set_error_handler('simpleTestErrorHandler');
|
||||||
|
$expected = 'missingAction';
|
||||||
|
$this->assertEqual($expected, $controller);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testDispatch() {
|
||||||
|
$dispatcher =& new TestDispatcher();
|
||||||
|
$dispatcher->base = '/index.php';
|
||||||
|
$url = setUrl('/pages/home/param:value/param2:value2');
|
||||||
|
|
||||||
|
restore_error_handler();
|
||||||
|
@$controller = $dispatcher->dispatch($url, array('return'=> 1));
|
||||||
|
set_error_handler('simpleTestErrorHandler');
|
||||||
|
|
||||||
|
$expected = 'Pages';
|
||||||
|
$this->assertEqual($expected, $controller->name);
|
||||||
|
|
||||||
|
$expected = array('param'=>'value', 'param2'=>'value2');
|
||||||
|
$this->assertIdentical($expected, $controller->namedArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testAdminDispatch() {
|
||||||
|
$_POST = array();
|
||||||
|
|
||||||
|
if (!defined('CAKE_ADMIN')) {
|
||||||
|
define('CAKE_ADMIN', 'admin');
|
||||||
|
}
|
||||||
|
$_SERVER['DOCUMENT_ROOT'] = '';
|
||||||
|
$_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/app/webroot/index.php';
|
||||||
|
|
||||||
|
$dispatcher =& new TestDispatcher();
|
||||||
|
$dispatcher->base = false;
|
||||||
|
$url = setUrl('/admin/test_dispatch_pages/index/param:value/param2:value2');
|
||||||
|
|
||||||
|
Router::reload();
|
||||||
|
$Router =& Router::getInstance();
|
||||||
|
if (defined('CAKE_ADMIN')) {
|
||||||
|
$admin = CAKE_ADMIN;
|
||||||
|
if (!empty($admin)) {
|
||||||
|
$Router->__admin = array(
|
||||||
|
'/:' . $admin . '/:controller/:action/*',
|
||||||
|
'/^(?:\/(?:(' . $admin . ')(?:\\/([a-zA-Z0-9_\\-\\.\\;\\:]+)(?:\\/([a-zA-Z0-9_\\-\\.\\;\\:]+)(?:[\\/\\?](.*))?)?)?))[\/]*$/',
|
||||||
|
array($admin, 'controller', 'action'), array()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
restore_error_handler();
|
||||||
|
@$controller = $dispatcher->dispatch($url, array('return'=> 1));
|
||||||
|
set_error_handler('simpleTestErrorHandler');
|
||||||
|
|
||||||
|
$expected = 'TestDispatchPages';
|
||||||
|
$this->assertEqual($expected, $controller->name);
|
||||||
|
|
||||||
|
$expected = array('param'=>'value', 'param2'=>'value2');
|
||||||
|
$this->assertIdentical($expected, $controller->namedArgs);
|
||||||
|
|
||||||
|
$expected = 'admin';
|
||||||
|
$this->assertIdentical($expected, $controller->params['admin']);
|
||||||
|
|
||||||
|
$expected = '/cake/repo/branches/1.2.x.x/admin/test_dispatch_pages/index/param:value/param2:value2';
|
||||||
|
$this->assertIdentical($expected, $controller->here);
|
||||||
|
|
||||||
|
$expected = '/cake/repo/branches/1.2.x.x';
|
||||||
|
$this->assertIdentical($expected, $controller->base);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function testPluginDispatch() {
|
||||||
|
$_POST = array();
|
||||||
|
$_SERVER['DOCUMENT_ROOT'] = '';
|
||||||
|
$_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/app/webroot/index.php';
|
||||||
|
|
||||||
|
Router::reload();
|
||||||
|
$dispatcher =& new TestDispatcher();
|
||||||
|
Router::connect('/my_plugin/:controller/*', array('plugin'=>'my_plugin', 'controller'=>'pages', 'action'=>'display'));
|
||||||
|
|
||||||
|
$dispatcher->base = false;
|
||||||
|
$url = setUrl('/my_plugin/some_pages/home/param:value/param2:value2');
|
||||||
|
|
||||||
|
restore_error_handler();
|
||||||
|
@$controller = $dispatcher->dispatch($url, array('return'=> 1));
|
||||||
|
set_error_handler('simpleTestErrorHandler');
|
||||||
|
|
||||||
|
|
||||||
|
$result = $dispatcher->parseParams($url);
|
||||||
|
$expected = array('pass' => array('home', 'param:value', 'param2:value2'),
|
||||||
|
'plugin'=> 'my_plugin', 'controller'=> 'some_pages', 'action'=> 'display',
|
||||||
|
'form'=> null, //array('testdata'=> 'My Posted Data'),
|
||||||
|
'url'=> array('url'=> 'my_plugin/some_pages/home/param:value/param2:value2'),
|
||||||
|
'bare'=> 0, 'webservices'=> '');
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
|
||||||
|
$expected = 'my_plugin';
|
||||||
|
$this->assertIdentical($expected, $controller->plugin);
|
||||||
|
|
||||||
|
$expected = 'SomePages';
|
||||||
|
$this->assertIdentical($expected, $controller->name);
|
||||||
|
|
||||||
|
$expected = array('param'=>'value', 'param2'=>'value2');
|
||||||
|
$this->assertIdentical($expected, $controller->namedArgs);
|
||||||
|
|
||||||
|
$expected = '/cake/repo/branches/1.2.x.x/my_plugin/some_pages/home/param:value/param2:value2';
|
||||||
|
$this->assertIdentical($expected, $controller->here);
|
||||||
|
|
||||||
|
$expected = '/cake/repo/branches/1.2.x.x';
|
||||||
|
$this->assertIdentical($expected, $controller->base);
|
||||||
|
}
|
||||||
|
|
||||||
|
function tearDown() {
|
||||||
|
$_GET = $this->_get;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('cache');
|
||||||
class CacheTest extends UnitTestCase {
|
class CacheTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'CacheTest not implemented');
|
$this->skipif (true, 'CacheTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
2
cake/tests/cases/libs/cache/apc.test.php
vendored
2
cake/tests/cases/libs/cache/apc.test.php
vendored
|
@ -36,7 +36,7 @@ uses('cache', 'cache' . DS . 'apc');
|
||||||
class APCEngineTest extends UnitTestCase {
|
class APCEngineTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'APCEngineTest not implemented');
|
$this->skipif (true, 'APCEngineTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
2
cake/tests/cases/libs/cache/file.test.php
vendored
2
cake/tests/cases/libs/cache/file.test.php
vendored
|
@ -36,7 +36,7 @@ uses('cache', 'cache' . DS . 'file');
|
||||||
class FileEngineTest extends UnitTestCase {
|
class FileEngineTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'FileEngineTest not implemented');
|
$this->skipif (true, 'FileEngineTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('cache', 'cache' . DS . 'memcache');
|
||||||
class MemcacheEngineTest extends UnitTestCase {
|
class MemcacheEngineTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'MemcacheEngineTest not implemented');
|
$this->skipif (true, 'MemcacheEngineTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
2
cake/tests/cases/libs/cache/model.test.php
vendored
2
cake/tests/cases/libs/cache/model.test.php
vendored
|
@ -36,7 +36,7 @@ uses('cache', 'cache' . DS . 'model');
|
||||||
class ModelEngineTest extends UnitTestCase {
|
class ModelEngineTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'ModelEngineTest not implemented');
|
$this->skipif (true, 'ModelEngineTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
2
cake/tests/cases/libs/cache/xcache.test.php
vendored
2
cake/tests/cases/libs/cache/xcache.test.php
vendored
|
@ -36,7 +36,7 @@ uses('cache', 'cache' . DS . 'xcache');
|
||||||
class XcacheEngineTest extends UnitTestCase {
|
class XcacheEngineTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'XcacheEngineTest not implemented');
|
$this->skipif (true, 'XcacheEngineTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('cake_log');
|
||||||
class CakeLogTest extends UnitTestCase {
|
class CakeLogTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'CakeLogTest not implemented');
|
$this->skipif (true, 'CakeLogTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('class_registry');
|
||||||
class ClassRegistryTest extends UnitTestCase {
|
class ClassRegistryTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'ClassRegistry not implemented');
|
$this->skipif (true, 'ClassRegistry not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('configure');
|
||||||
class ConfigureTest extends UnitTestCase {
|
class ConfigureTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'ConfigureTest not implemented');
|
$this->skipif (true, 'ConfigureTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('controller' . DS . 'component');
|
||||||
class ComponentTest extends CakeTestCase {
|
class ComponentTest extends CakeTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'ComponentTest not implemented');
|
$this->skipif (true, 'ComponentTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('controller' . DS . 'components' . DS .'acl');
|
||||||
class AclComponentTest extends CakeTestCase {
|
class AclComponentTest extends CakeTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'AclComponentTest not implemented');
|
$this->skipif (true, 'AclComponentTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -87,7 +87,7 @@ class AuthTest extends CakeTestCase {
|
||||||
var $fixtures = array('core.auth_user', 'core.aco', 'core.aro', 'core.aros_aco');
|
var $fixtures = array('core.auth_user', 'core.aco', 'core.aro', 'core.aros_aco');
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'Auth tests currently disabled, to test use a clean database with tables needed for acl and comment out this line');
|
$this->skipif (true, 'Auth tests currently disabled, to test use a clean database with tables needed for acl and comment out this line');
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
|
|
@ -36,7 +36,7 @@ uses('controller' . DS . 'components' . DS .'cookie');
|
||||||
class CookieComponentTest extends CakeTestCase {
|
class CookieComponentTest extends CakeTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'CookieComponentTest not implemented');
|
$this->skipif (true, 'CookieComponentTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('controller' . DS . 'components' . DS .'request_handler');
|
||||||
class RequestHandlerComponentTest extends CakeTestCase {
|
class RequestHandlerComponentTest extends CakeTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'RequestHandlerComponentTest not implemented');
|
$this->skipif (true, 'RequestHandlerComponentTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('controller' . DS . 'components' . DS .'security');
|
||||||
class SecurityComponentTest extends CakeTestCase {
|
class SecurityComponentTest extends CakeTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'SecurityComponentTest not implemented');
|
$this->skipif (true, 'SecurityComponentTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('controller' . DS . 'components' . DS .'session');
|
||||||
class SessionComponentTest extends CakeTestCase {
|
class SessionComponentTest extends CakeTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'SessionComponentTest not implemented');
|
$this->skipif (true, 'SessionComponentTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('controller' . DS . 'controller');
|
||||||
class ControllerTest extends CakeTestCase {
|
class ControllerTest extends CakeTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'ControllerTest not implemented');
|
$this->skipif (true, 'ControllerTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('controller' . DS . 'controller', 'controller' . DS . 'pages_controller');
|
||||||
class PagesControllerTest extends CakeTestCase {
|
class PagesControllerTest extends CakeTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'PagesControllerTest not implemented');
|
$this->skipif (true, 'PagesControllerTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('controller' . DS . 'scaffold');
|
||||||
class ScaffoldTest extends CakeTestCase {
|
class ScaffoldTest extends CakeTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'ScaffoldTest not implemented');
|
$this->skipif (true, 'ScaffoldTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('debugger');
|
||||||
class DebuggerTest extends UnitTestCase {
|
class DebuggerTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'ConfigureTest not implemented');
|
$this->skipif (true, 'ConfigureTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('error');
|
||||||
class ErrorHandlerTest extends UnitTestCase {
|
class ErrorHandlerTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'ConfigureTest not implemented');
|
$this->skipif (true, 'ConfigureTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('flay');
|
||||||
class FlayTest extends UnitTestCase {
|
class FlayTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'FlayTest not implemented');
|
$this->skipif (true, 'FlayTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('i18n');
|
||||||
class I18nTest extends UnitTestCase {
|
class I18nTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'I18nTest not implemented');
|
$this->skipif (true, 'I18nTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('l10n');
|
||||||
class L10nTest extends UnitTestCase {
|
class L10nTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'L10nTest not implemented');
|
$this->skipif (true, 'L10nTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('neat_string');
|
||||||
class NeatStringTest extends UnitTestCase {
|
class NeatStringTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'NeatString not implemented');
|
$this->skipif (true, 'NeatString not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('object');
|
||||||
class ObjectTest extends UnitTestCase {
|
class ObjectTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'ObjectTest not implemented');
|
$this->skipif (true, 'ObjectTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('overloadable');
|
||||||
class OverloadableTest extends UnitTestCase {
|
class OverloadableTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'OverloadableTest not implemented');
|
$this->skipif (true, 'OverloadableTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,7 +36,7 @@ uses('security');
|
||||||
class SecurityTest extends UnitTestCase {
|
class SecurityTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'SecurityTest not implemented');
|
$this->skipif (true, 'SecurityTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -42,7 +42,7 @@ uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view
|
||||||
class CacheHelperTest extends UnitTestCase {
|
class CacheHelperTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'CacheHelper test not implemented');
|
$this->skipif (true, 'CacheHelper test not implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
|
|
@ -42,7 +42,7 @@ uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view
|
||||||
class JsTest extends UnitTestCase {
|
class JsTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'JsHelper test not implemented');
|
$this->skipif (true, 'JsHelper test not implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
|
|
@ -42,7 +42,7 @@ uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view
|
||||||
class RssTest extends UnitTestCase {
|
class RssTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'RssHelper test not implemented');
|
$this->skipif (true, 'RssHelper test not implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
|
|
@ -42,7 +42,7 @@ uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view
|
||||||
class SessionHelperTest extends UnitTestCase {
|
class SessionHelperTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'SessionHelper test not implemented');
|
$this->skipif (true, 'SessionHelper test not implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
|
|
@ -42,7 +42,7 @@ uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view
|
||||||
class TimeTest extends UnitTestCase {
|
class TimeTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'TimeHelper test not implemented');
|
$this->skipif (true, 'TimeHelper test not implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
|
|
@ -42,7 +42,7 @@ uses('controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view
|
||||||
class XmlHelperTest extends UnitTestCase {
|
class XmlHelperTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'XmlHelper test not implemented');
|
$this->skipif (true, 'XmlHelper test not implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
|
|
@ -36,7 +36,7 @@ uses('xml');
|
||||||
class XMLNodeTest extends UnitTestCase {
|
class XMLNodeTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'XMLNodeTest not implemented');
|
$this->skipif (true, 'XMLNodeTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +48,7 @@ class XMLNodeTest extends UnitTestCase {
|
||||||
class XMLTest extends UnitTestCase {
|
class XMLTest extends UnitTestCase {
|
||||||
|
|
||||||
function skip() {
|
function skip() {
|
||||||
$this->skipIf(true, 'XMLTest not implemented');
|
$this->skipif (true, 'XMLTest not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -50,7 +50,7 @@ class CakeHtmlReporter extends HtmlReporter {
|
||||||
*/
|
*/
|
||||||
function paintHeader($testName) {
|
function paintHeader($testName) {
|
||||||
$this->sendNoCacheHeaders();
|
$this->sendNoCacheHeaders();
|
||||||
$baseUrl = BASE_URL;
|
$baseUrl = BASE;
|
||||||
print "<h2>$testName</h2>\n";
|
print "<h2>$testName</h2>\n";
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
<div id="footer">
|
<div id="footer">
|
||||||
<!--PLEASE USE ONE OF THE POWERED BY CAKEPHP LOGO-->
|
<!--PLEASE USE ONE OF THE POWERED BY CAKEPHP LOGO-->
|
||||||
<a href="http://www.cakephp.org/" target="_new">
|
<a href="http://www.cakephp.org/" target="_new">
|
||||||
<img src="<?php echo $baseUrl; ?>/img/cake.power.png" alt="CakePHP(tm) :: Rapid Development Framework" height = "15" width = "80" /></a></p>
|
<img src="<?php echo $baseUrl; ?>img/cake.power.png" alt="CakePHP(tm) :: Rapid Development Framework" height = "15" width = "80" /></a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv='content-Type' content='text/html; <?php echo $characterSet; ?>' />
|
<meta http-equiv='content-Type' content='text/html; <?php echo $characterSet; ?>' />
|
||||||
<title>CakePHP Test Suite v 1.2.0.0</title>
|
<title>CakePHP Test Suite v 1.2.0.0</title>
|
||||||
<link rel="stylesheet" type="text/css" href="<?php echo $baseUrl; ?>/css/cake.generic.css" />
|
<link rel="stylesheet" type="text/css" href="<?php echo $baseUrl; ?>css/cake.generic.css" />
|
||||||
<style>
|
<style>
|
||||||
h3 {font-size: 150%}
|
h3 {font-size: 150%}
|
||||||
a {font-size: 120%}
|
a {font-size: 120%}
|
||||||
|
|
23
index.php
23
index.php
|
@ -54,24 +54,11 @@
|
||||||
require CORE_PATH . 'cake' . DS . 'basics.php';
|
require CORE_PATH . 'cake' . DS . 'basics.php';
|
||||||
require APP_PATH . 'config' . DS . 'core.php';
|
require APP_PATH . 'config' . DS . 'core.php';
|
||||||
require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
|
require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
|
||||||
$bootstrap=true;
|
require LIBS . 'object.php';
|
||||||
$uri =setUri();
|
require LIBS . 'configure.php';
|
||||||
/**
|
|
||||||
* As mod_rewrite (or .htaccess files) is not working, we need to take care
|
$bootstrap = true;
|
||||||
* of what would normally be rewritten, i.e. the static files in app/webroot/
|
$url = setUrl();
|
||||||
*/
|
|
||||||
if ($uri === '/' || $uri === '/index.php') {
|
|
||||||
$_GET['url'] = '/';
|
|
||||||
require APP_DIR . DS . WEBROOT_DIR . DS . 'index.php';
|
|
||||||
} else {
|
|
||||||
$elements=explode('/index.php', $uri);
|
|
||||||
|
|
||||||
if (!empty($elements[1])) {
|
|
||||||
$path = $elements[1];
|
|
||||||
} else {
|
|
||||||
$path = '/';
|
|
||||||
}
|
|
||||||
$_GET['url']=$path;
|
|
||||||
require APP_DIR . DS . WEBROOT_DIR . DS . 'index.php';
|
require APP_DIR . DS . WEBROOT_DIR . DS . 'index.php';
|
||||||
}
|
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue