mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 10:36:16 +00:00
"Closes #2508, Allow requestAction to use array urls
Fixes #4325, error pages no longer displayed since changeset Closes #4329, remove am() usage in core" git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6563 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
698d3e4f40
commit
acc79fe0f3
21 changed files with 292 additions and 114 deletions
|
@ -47,7 +47,7 @@ class ApiShell extends Shell {
|
|||
* @access public
|
||||
*/
|
||||
function initialize () {
|
||||
$this->paths = am($this->paths, array(
|
||||
$this->paths = array_merge($this->paths, array(
|
||||
'behavior' => LIBS . 'model' . DS . 'behaviors' . DS,
|
||||
'cache' => LIBS . 'cache' . DS,
|
||||
'controller' => LIBS . 'controller' . DS,
|
||||
|
|
|
@ -178,7 +178,7 @@ class DbConfigTask extends Shell {
|
|||
* @access private
|
||||
*/
|
||||
function __verify($config) {
|
||||
$config = am($this->__defaultConfig, $config);
|
||||
$config = array_merge($this->__defaultConfig, $config);
|
||||
extract($config);
|
||||
$this->out('');
|
||||
$this->hr();
|
||||
|
@ -262,12 +262,12 @@ class DbConfigTask extends Shell {
|
|||
}
|
||||
}
|
||||
|
||||
$configs = am($oldConfigs, $configs);
|
||||
$configs = array_merge($oldConfigs, $configs);
|
||||
$out = "<?php\n";
|
||||
$out .= "class DATABASE_CONFIG {\n\n";
|
||||
|
||||
foreach ($configs as $config) {
|
||||
$config = am($this->__defaultConfig, $config);
|
||||
$config = array_merge($this->__defaultConfig, $config);
|
||||
extract($config);
|
||||
$out .= "\tvar \${$name} = array(\n";
|
||||
$out .= "\t\t'driver' => '{$driver}',\n";
|
||||
|
|
|
@ -138,7 +138,7 @@ class ViewTask extends Shell {
|
|||
$adminDelete = $adminRoute.'_delete';
|
||||
}
|
||||
foreach ($methods as $method) {
|
||||
if ($method{0} != '_' && !in_array(low($method), am($protected, array('delete', $adminDelete)))) {
|
||||
if ($method{0} != '_' && !in_array(low($method), array_merge($protected, array('delete', $adminDelete)))) {
|
||||
$content = $this->getContent($method, $vars);
|
||||
$this->bake($method, $content);
|
||||
}
|
||||
|
|
|
@ -108,20 +108,32 @@ class Dispatcher extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function dispatch($url = null, $additionalParams = array()) {
|
||||
$parse = true;
|
||||
if ($this->base === false) {
|
||||
$this->base = $this->baseUrl();
|
||||
}
|
||||
|
||||
if (is_array($url)) {
|
||||
$url = $this->extractParams($url, $additionalParams);
|
||||
$parse = false;
|
||||
}
|
||||
|
||||
if ($url !== null) {
|
||||
$_GET['url'] = $url;
|
||||
}
|
||||
|
||||
$url = $this->getUrl();
|
||||
if ($parse) {
|
||||
$url = $this->getUrl();
|
||||
}
|
||||
$this->here = $this->base . '/' . $url;
|
||||
|
||||
if ($this->cached($url)) {
|
||||
exit();
|
||||
}
|
||||
$this->params = array_merge($this->parseParams($url), $additionalParams);
|
||||
|
||||
if ($parse) {
|
||||
$this->params = array_merge($this->parseParams($url), $additionalParams);
|
||||
}
|
||||
$controller = $this->__getController();
|
||||
|
||||
if (!is_object($controller)) {
|
||||
|
@ -155,7 +167,7 @@ class Dispatcher extends Object {
|
|||
$protected = array_map('strtolower', get_class_methods('controller'));
|
||||
$classMethods = array_map('strtolower', get_class_methods($controller));
|
||||
|
||||
if (in_array(strtolower($this->params['action']), $protected) || strpos($this->params['action'], '_', 0) === 0) {
|
||||
if (in_array(strtolower($this->params['action']), $protected) || strpos($this->params['action'], '_', 0) === 0) {
|
||||
$privateAction = true;
|
||||
}
|
||||
|
||||
|
@ -267,6 +279,9 @@ class Dispatcher extends Object {
|
|||
}
|
||||
}
|
||||
$controller->afterFilter();
|
||||
if (isset($params['return'])) {
|
||||
return $controller->output;
|
||||
}
|
||||
e($controller->output);
|
||||
}
|
||||
/**
|
||||
|
@ -278,7 +293,7 @@ class Dispatcher extends Object {
|
|||
*/
|
||||
function start(&$controller) {
|
||||
if (!empty($controller->beforeFilter)) {
|
||||
trigger_error(sprintf(__('Dispatcher::start - Controller::$beforeFilter property usage is deprecated and will no longer be supported. Use Controller::beforeFilter().', true)), E_USER_WARNING);
|
||||
trigger_error(sprintf(__('Dispatcher::start - Controller::$beforeFilter property usage is deprecated and will no longer be supported. Use Controller::beforeFilter().', true)), E_USER_WARNING);
|
||||
|
||||
if (is_array($controller->beforeFilter)) {
|
||||
foreach ($controller->beforeFilter as $filter) {
|
||||
|
@ -304,7 +319,22 @@ class Dispatcher extends Object {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the params when $url is passed as an array to Object::requestAction();
|
||||
*
|
||||
* @param array $url
|
||||
* @param array $additionalParams
|
||||
* @return null
|
||||
* @access private
|
||||
* @todo commented Router::url(). this improved performance,
|
||||
* will work on this more later.
|
||||
*/
|
||||
function extractParams($url, $additionalParams = array()) {
|
||||
$defaults = array('pass' => array(), 'named' => array(), 'form' => array());
|
||||
$this->params = array_merge($defaults, $url, $additionalParams);
|
||||
//$url = Router::url($url);
|
||||
//return $url;
|
||||
}
|
||||
/**
|
||||
* Returns array of GET and POST parameters. GET parameters are taken from given URL.
|
||||
*
|
||||
|
@ -401,10 +431,10 @@ class Dispatcher extends Object {
|
|||
$base = dirname(env('PHP_SELF'));
|
||||
|
||||
if ($webroot === 'webroot' && $webroot === basename($base)) {
|
||||
$base = dirname($base);
|
||||
$base = dirname($base);
|
||||
}
|
||||
if ($dir === 'app' && $dir === basename($base)) {
|
||||
$base = dirname($base);
|
||||
$base = dirname($base);
|
||||
}
|
||||
|
||||
if (in_array($base, array(DS, '.'))) {
|
||||
|
@ -425,7 +455,7 @@ class Dispatcher extends Object {
|
|||
$this->webroot = $base .'/';
|
||||
|
||||
if (strpos($this->webroot, $dir) === false) {
|
||||
$this->webroot .= $dir . '/' ;
|
||||
$this->webroot .= $dir . '/' ;
|
||||
}
|
||||
if (strpos($this->webroot, $webroot) === false) {
|
||||
$this->webroot .= $webroot . '/';
|
||||
|
@ -640,7 +670,7 @@ class Dispatcher extends Object {
|
|||
$isAsset = false;
|
||||
foreach ($assets as $type => $contentType) {
|
||||
$pos = strpos($url, $type . '/');
|
||||
if ($pos !== false) {
|
||||
if ($pos !== false) {
|
||||
$isAsset = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -59,9 +59,9 @@ class ErrorHandler extends Object {
|
|||
$this->controller->viewPath = 'errors';
|
||||
|
||||
$allow = array('.', '/', '_', ' ', '-', '~');
|
||||
if (substr(PHP_OS,0,3) == "WIN") {
|
||||
$allow = array_merge($allow, array('\\', ':') );
|
||||
}
|
||||
if (substr(PHP_OS,0,3) == "WIN") {
|
||||
$allow = array_merge($allow, array('\\', ':') );
|
||||
}
|
||||
|
||||
App::import('Core', 'Sanitize');
|
||||
$messages = Sanitize::paranoid($messages, $allow);
|
||||
|
@ -103,7 +103,7 @@ class ErrorHandler extends Object {
|
|||
'name' => $name,
|
||||
'message' => $message,
|
||||
'title' => $code . ' ' . $name));
|
||||
$this->controller->render('error404');
|
||||
$this->__outputMessage('error404');
|
||||
}
|
||||
/**
|
||||
* Convenience method to display a 404 page.
|
||||
|
@ -123,7 +123,7 @@ class ErrorHandler extends Object {
|
|||
'name' => __('Not Found', true),
|
||||
'message' => sprintf(__("The requested address %s was not found on this server.", true), "<strong>'{$url}'</strong>"),
|
||||
'base' => $this->controller->base));
|
||||
$this->controller->render('error404');
|
||||
$this->__outputMessage('error404');
|
||||
}
|
||||
/**
|
||||
* Renders the Missing Controller web page.
|
||||
|
@ -138,7 +138,7 @@ class ErrorHandler extends Object {
|
|||
$this->controller->set(array('controller' => $className,
|
||||
'controllerName' => $controllerName,
|
||||
'title' => __('Missing Controller', true)));
|
||||
$this->controller->render('missingController');
|
||||
$this->__outputMessage('missingController');
|
||||
}
|
||||
/**
|
||||
* Renders the Missing Action web page.
|
||||
|
@ -154,7 +154,7 @@ class ErrorHandler extends Object {
|
|||
'controllerName' => $controllerName,
|
||||
'action' => $action,
|
||||
'title' => __('Missing Method in Controller', true)));
|
||||
$this->controller->render('missingAction');
|
||||
$this->__outputMessage('missingAction');
|
||||
}
|
||||
/**
|
||||
* Renders the Private Action web page.
|
||||
|
@ -168,7 +168,7 @@ class ErrorHandler extends Object {
|
|||
$this->controller->set(array('controller' => $className,
|
||||
'action' => $action,
|
||||
'title' => __('Trying to access private method in class', true)));
|
||||
$this->controller->render('privateAction');
|
||||
$this->__outputMessage('privateAction');
|
||||
}
|
||||
/**
|
||||
* Renders the Missing Table web page.
|
||||
|
@ -182,7 +182,7 @@ class ErrorHandler extends Object {
|
|||
$this->controller->set(array('model' => $className,
|
||||
'table' => $table,
|
||||
'title' => __('Missing Database Table', true)));
|
||||
$this->controller->render('missingTable');
|
||||
$this->__outputMessage('missingTable');
|
||||
}
|
||||
/**
|
||||
* Renders the Missing Database web page.
|
||||
|
@ -194,7 +194,7 @@ class ErrorHandler extends Object {
|
|||
extract($params, EXTR_OVERWRITE);
|
||||
|
||||
$this->controller->set(array('title' => __('Scaffold Missing Database Connection', true)));
|
||||
$this->controller->render('missingScaffolddb');
|
||||
$this->__outputMessage('missingScaffolddb');
|
||||
}
|
||||
/**
|
||||
* Renders the Missing View web page.
|
||||
|
@ -209,7 +209,8 @@ class ErrorHandler extends Object {
|
|||
'action' => $action,
|
||||
'file' => $file,
|
||||
'title' => __('Missing View', true)));
|
||||
$this->controller->render('missingView');
|
||||
$this->__outputMessage('missingView');
|
||||
|
||||
}
|
||||
/**
|
||||
* Renders the Missing Layout web page.
|
||||
|
@ -221,9 +222,9 @@ class ErrorHandler extends Object {
|
|||
extract($params, EXTR_OVERWRITE);
|
||||
|
||||
$this->controller->layout = 'default';
|
||||
$this->controller->set(array('file' => $file,
|
||||
$this->controller->set(array('file' => $file,
|
||||
'title' => __('Missing Layout', true)));
|
||||
$this->controller->render('missingLayout');
|
||||
$this->__outputMessage('missingLayout');
|
||||
}
|
||||
/**
|
||||
* Renders the Database Connection web page.
|
||||
|
@ -236,7 +237,7 @@ class ErrorHandler extends Object {
|
|||
|
||||
$this->controller->set(array('model' => $className,
|
||||
'title' => __('Missing Database Connection', true)));
|
||||
$this->controller->render('missingConnection');
|
||||
$this->__outputMessage('missingConnection');
|
||||
}
|
||||
/**
|
||||
* Renders the Missing Helper file web page.
|
||||
|
@ -250,7 +251,7 @@ class ErrorHandler extends Object {
|
|||
$this->controller->set(array('helperClass' => Inflector::camelize($helper) . "Helper",
|
||||
'file' => $file,
|
||||
'title' => __('Missing Helper File', true)));
|
||||
$this->controller->render('missingHelperFile');
|
||||
$this->__outputMessage('missingHelperFile');
|
||||
}
|
||||
/**
|
||||
* Renders the Missing Helper class web page.
|
||||
|
@ -264,7 +265,7 @@ class ErrorHandler extends Object {
|
|||
$this->controller->set(array('helperClass' => Inflector::camelize($helper) . "Helper",
|
||||
'file' => $file,
|
||||
'title' => __('Missing Helper Class', true)));
|
||||
$this->controller->render('missingHelperClass');
|
||||
$this->__outputMessage('missingHelperClass');
|
||||
}
|
||||
/**
|
||||
* Renders the Missing Component file web page.
|
||||
|
@ -279,7 +280,7 @@ class ErrorHandler extends Object {
|
|||
'component' => $component,
|
||||
'file' => $file,
|
||||
'title' => __('Missing Component File', true)));
|
||||
$this->controller->render('missingComponentFile');
|
||||
$this->__outputMessage('missingComponentFile');
|
||||
}
|
||||
/**
|
||||
* Renders the Missing Component class web page.
|
||||
|
@ -294,7 +295,7 @@ class ErrorHandler extends Object {
|
|||
'component' => $component,
|
||||
'file' => $file,
|
||||
'title' => __('Missing Component Class', true)));
|
||||
$this->controller->render('missingComponentClass');
|
||||
$this->__outputMessage('missingComponentClass');
|
||||
}
|
||||
/**
|
||||
* Renders the Missing Model class web page.
|
||||
|
@ -307,7 +308,17 @@ class ErrorHandler extends Object {
|
|||
|
||||
$this->controller->set(array('model' => $className,
|
||||
'title' => __('Missing Model', true)));
|
||||
$this->controller->render('missingModel');
|
||||
$this->__outputMessage('missingModel');
|
||||
}
|
||||
/**
|
||||
* Output message
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function __outputMessage($template) {
|
||||
$this->controller->render($template);
|
||||
$this->controller->afterFilter();
|
||||
e($this->controller->output);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -559,7 +559,7 @@ class TreeBehavior extends ModelBehavior {
|
|||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
function reorder(&$model, $options = array()) {
|
||||
$options = am(array('id' => null, 'field' => $model->displayField, 'order' => 'ASC', 'verify' => true), $options);
|
||||
$options = array_merge(array('id' => null, 'field' => $model->displayField, 'order' => 'ASC', 'verify' => true), $options);
|
||||
extract($options);
|
||||
if ($verify && !$model->verify()) {
|
||||
return false;
|
||||
|
|
|
@ -814,7 +814,7 @@ class DboOracle extends DboSource {
|
|||
foreach ($ins as $i) {
|
||||
$q = str_replace('{$__cakeID__$}', join(', ', $i), $query);
|
||||
$res = $this->fetchAll($q, $model->cacheQueries, $model->alias);
|
||||
$fetch = am($fetch, $res);
|
||||
$fetch = array_merge($fetch, $res);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -861,7 +861,7 @@ class DboOracle extends DboSource {
|
|||
$q = $this->insertQueryData($q, null, $association, $assocData, $model, $linkModel, $stack);
|
||||
if ($q != false) {
|
||||
$res = $this->fetchAll($q, $model->cacheQueries, $model->alias);
|
||||
$fetch = am($fetch, $res);
|
||||
$fetch = array_merge($fetch, $res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,46 +79,36 @@ class Object {
|
|||
/**
|
||||
* Calls a controller's method from any location.
|
||||
*
|
||||
* @param string $url URL in the form of Cake URL ("/controller/method/parameter")
|
||||
* @param array $extra If array includes the key "return" it sets the AutoRender to true.
|
||||
* @return mixed Success (true/false) or contents if 'return' is set in $extra
|
||||
* @param string $url URL in the form of Cake URL ("/controller/method/parameter")
|
||||
* @param array $extra if array includes the key "return" it sets the AutoRender to true.
|
||||
* @return mixed Success (true/false) or contents if 'return' is set in $extra
|
||||
* @access public
|
||||
*/
|
||||
function requestAction($url, $extra = array()) {
|
||||
if (!empty($url)) {
|
||||
if (!class_exists('dispatcher')) {
|
||||
require CAKE . 'dispatcher.php';
|
||||
}
|
||||
$dispatcher =& new Dispatcher();
|
||||
if (in_array('return', $extra, true)) {
|
||||
$extra['return'] = 0;
|
||||
$extra['bare'] = 1;
|
||||
$extra['requested'] = 1;
|
||||
ob_start();
|
||||
$out = $dispatcher->dispatch($url, $extra);
|
||||
$out = ob_get_clean();
|
||||
return $out;
|
||||
} else {
|
||||
$extra['return'] = 1;
|
||||
$extra['bare'] = 1;
|
||||
$extra['requested'] = 1;
|
||||
return $dispatcher->dispatch($url, $extra);
|
||||
}
|
||||
} else {
|
||||
if (empty($url)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!class_exists('dispatcher')) {
|
||||
require CAKE . 'dispatcher.php';
|
||||
}
|
||||
if (in_array('return', $extra, true)) {
|
||||
$extra = array_merge($extra, array('return' => 0, 'autoRender' => 1));
|
||||
}
|
||||
$params = am(array('autoRender' => 0, 'return' => 1, 'bare' => 1, 'requested' => 1), $extra);
|
||||
$dispatcher = new Dispatcher;
|
||||
return $dispatcher->dispatch($url, $params);
|
||||
}
|
||||
/**
|
||||
* Calls a method on this object with the given parameters. Provides an OO wrapper
|
||||
* Calls a method on this object with the given parameters. Provides an OO wrapper
|
||||
* for call_user_func_array, and improves performance by using straight method calls
|
||||
* in most cases.
|
||||
*
|
||||
* @param string $method Name of the method to call
|
||||
* @param array $params Parameter list to use when calling $method
|
||||
* @param boolean $strict If true, checks to make sure that $method is defined
|
||||
* in this object. Throws a warning if not.
|
||||
* @return mixed Returns the result of the method call, or null if $strict is
|
||||
* true and the method was not found
|
||||
* @param string $method Name of the method to call
|
||||
* @param array $params Parameter list to use when calling $method
|
||||
* @param boolean $strict If true, checks to make sure that $method is defined
|
||||
* in this object. Throws a warning if not.
|
||||
* @return mixed Returns the result of the method call, or null if $strict is
|
||||
* true and the method was not found
|
||||
* @access public
|
||||
*/
|
||||
function dispatchMethod($method, $params = array(), $strict = false) {
|
||||
|
|
|
@ -881,7 +881,7 @@ class Set extends Object {
|
|||
$stack = array();
|
||||
foreach ($results as $k => $r) {
|
||||
if (is_array($r)) {
|
||||
$stack = am($stack, Set::__flatten($r, $k));
|
||||
$stack = array_merge($stack, Set::__flatten($r, $k));
|
||||
} else {
|
||||
if (!empty($key)) {
|
||||
$id = $key;
|
||||
|
|
|
@ -303,8 +303,8 @@ class View extends Object {
|
|||
return $cache;
|
||||
} else {
|
||||
$element = $this->renderElement($name, $params);
|
||||
cache('views' . DS . $cacheFile, $element, $expires);
|
||||
return $element;
|
||||
cache('views' . DS . $cacheFile, $element, $expires);
|
||||
return $element;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -428,10 +428,10 @@ class View extends Object {
|
|||
|
||||
$data_for_layout = array_merge($this->viewVars,
|
||||
array(
|
||||
'title_for_layout' => $pageTitle,
|
||||
'title_for_layout' => $pageTitle,
|
||||
'content_for_layout' => $content_for_layout,
|
||||
'scripts_for_layout' => join("\n\t", $this->__scripts),
|
||||
'cakeDebug' => $debug
|
||||
'cakeDebug' => $debug
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -557,7 +557,7 @@ class View extends Object {
|
|||
}
|
||||
/**
|
||||
* Allows a template or element to set a variable that will be available in
|
||||
* a layout or other element. Analagous to Controller::set.
|
||||
* a layout or other element. Analagous to Controller::set.
|
||||
*
|
||||
* @param mixed $one A string or an array of data.
|
||||
* @param mixed $two Value in case $one is a string (which then works as the key).
|
||||
|
@ -707,7 +707,7 @@ class View extends Object {
|
|||
|
||||
if (in_array($helper, array_keys($loaded)) !== true) {
|
||||
if (!class_exists($helperCn)) {
|
||||
if (is_null($plugin) || !App::import('Helper', $plugin . '.' . $helper)) {
|
||||
if (is_null($plugin) || !App::import('Helper', $plugin . '.' . $helper)) {
|
||||
if (!App::import('Helper', $helper)) {
|
||||
$this->cakeError('missingHelperFile', array(array(
|
||||
'helper' => $helper,
|
||||
|
@ -716,7 +716,7 @@ class View extends Object {
|
|||
)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!class_exists($helperCn)) {
|
||||
$this->cakeError('missingHelperClass', array(array(
|
||||
'helper' => $helper,
|
||||
|
|
|
@ -565,10 +565,10 @@ class HttpSocketTest extends UnitTestCase {
|
|||
|
||||
foreach ($tests as $name => $test) {
|
||||
|
||||
$testResponse = am($testResponse, $test['response']);
|
||||
$testResponse = array_merge($testResponse, $test['response']);
|
||||
$testResponse['response'] = $testResponse['status-line'].$testResponse['header']."\r\n".$testResponse['body'];
|
||||
$r = $this->Socket->parseResponse($testResponse['response']);
|
||||
$expectations = am($expectations, $test['expectations']);
|
||||
$expectations = array_merge($expectations, $test['expectations']);
|
||||
|
||||
foreach ($expectations as $property => $expectedVal) {
|
||||
$val = Set::extract($r, $property);
|
||||
|
|
|
@ -325,7 +325,7 @@ class TranslateTest extends CakeTestCase {
|
|||
$this->Model->create($data);
|
||||
$this->Model->save();
|
||||
$result = $this->Model->read();
|
||||
$expected = array('TranslatedItem' => am($data, array('id' => $this->Model->id, 'locale' => 'spa')));
|
||||
$expected = array('TranslatedItem' => array_merge($data, array('id' => $this->Model->id, 'locale' => 'spa')));
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
|
@ -339,7 +339,7 @@ class TranslateTest extends CakeTestCase {
|
|||
$this->Model->create($newData);
|
||||
$this->Model->save();
|
||||
$result = $this->Model->read(null, $id);
|
||||
$expected = array('TranslatedItem' => am($oldData, $newData, array('locale' => 'spa')));
|
||||
$expected = array('TranslatedItem' => array_merge($oldData, $newData, array('locale' => 'spa')));
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ class ModelTest extends CakeTestCase {
|
|||
$this->model =& new Article();
|
||||
|
||||
$this->model->belongsTo = $this->model->hasAndBelongsToMany = $this->model->hasOne = array();
|
||||
$this->model->hasMany['Comment'] = am($this->model->hasMany['Comment'], array(
|
||||
$this->model->hasMany['Comment'] = array_merge($this->model->hasMany['Comment'], array(
|
||||
'foreignKey' => false,
|
||||
'conditions' => array('Comment.user_id' => '= 2')
|
||||
));
|
||||
|
|
|
@ -70,7 +70,7 @@ class TestValidate extends Model {
|
|||
);
|
||||
|
||||
function validateNumber($value, $options) {
|
||||
$options = am(array('min' => 0, 'max' => 100), $options);
|
||||
$options = array_merge(array('min' => 0, 'max' => 100), $options);
|
||||
$valid = ($value['number'] >= $options['min'] && $value['number'] <= $options['max']);
|
||||
return $valid;
|
||||
}
|
||||
|
|
|
@ -26,8 +26,20 @@
|
|||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
App::import('Core', 'Object');
|
||||
App::import('Core', array('Object', 'Controller'));
|
||||
|
||||
if (!class_exists('RequestActionController')) {
|
||||
class RequestActionController extends Controller {
|
||||
var $uses = array();
|
||||
function test_request_action() {
|
||||
return 'This is a test';
|
||||
}
|
||||
|
||||
function another_ra_test($id, $other) {
|
||||
return $id + $other;
|
||||
}
|
||||
}
|
||||
}
|
||||
class TestObject extends Object {
|
||||
|
||||
var $methodCalls = array();
|
||||
|
@ -123,9 +135,62 @@ class ObjectTest extends UnitTestCase {
|
|||
$this->assertIdentical($this->object->methodCalls, $expected);
|
||||
}
|
||||
|
||||
function testRequestAction(){
|
||||
$result = $this->object->requestAction('/request_action/test_request_action');
|
||||
$expected = 'This is a test';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->object->requestAction(array('controller' => 'request_action', 'action' => 'test_request_action'));
|
||||
$expected = 'This is a test';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->object->requestAction('/request_action/another_ra_test/2/5');
|
||||
$expected = 7;
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->object->requestAction(array('controller' => 'request_action', 'action' => 'another_ra_test'), array('pass' => array('5', '7')));
|
||||
$expected = 12;
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
Configure::write('controllerPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS));
|
||||
Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS));
|
||||
Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
|
||||
|
||||
$result = $this->object->requestAction('/tests_apps/index', array('return'));
|
||||
$expected = 'This is the TestsAppsController index view';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->object->requestAction(array('controller' => 'tests_apps', 'action' => 'index'), array('return'));
|
||||
$expected = 'This is the TestsAppsController index view';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->object->requestAction('/tests_apps/some_method');
|
||||
$expected = 5;
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->object->requestAction(array('controller' => 'tests_apps', 'action' => 'some_method'));
|
||||
$expected = 5;
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->object->requestAction('/test_plugin/tests_plugins_tests/index', array('return'));
|
||||
$expected = 'This is the TestsPluginsTestsController index view';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->object->requestAction(array('controller' => 'tests_plugins_tests', 'action' => 'index', 'plugin' => 'test_plugin'), array('return'));
|
||||
$expected = 'This is the TestsPluginsTestsController index view';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->object->requestAction('/test_plugin/tests_plugins_tests/some_method');
|
||||
$expected = 25;
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->object->requestAction(array('controller' => 'tests_plugins_tests', 'action' => 'some_method', 'plugin' => 'test_plugin'));
|
||||
$expected = 25;
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
unset($this->object);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -173,13 +173,13 @@ class CakeTestCase extends UnitTestCase {
|
|||
$dropFixture = $fixture->drop();
|
||||
|
||||
if (!empty($createFixture)) {
|
||||
$this->_queries['create'] = am($this->_queries['create'], array($createFixture));
|
||||
$this->_queries['create'] = array_merge($this->_queries['create'], array($createFixture));
|
||||
}
|
||||
if (!empty($insertsFixture)) {
|
||||
$this->_queries['insert'] = am($this->_queries['insert'], $insertsFixture);
|
||||
$this->_queries['insert'] = array_merge($this->_queries['insert'], $insertsFixture);
|
||||
}
|
||||
if (!empty($dropFixture)) {
|
||||
$this->_queries['drop'] = am($this->_queries['drop'], array($dropFixture));
|
||||
$this->_queries['drop'] = array_merge($this->_queries['drop'], array($dropFixture));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,7 +239,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
'method' => 'post'
|
||||
);
|
||||
|
||||
$params = am($default, $params);
|
||||
$params = array_merge($default, $params);
|
||||
|
||||
if (!empty($params['data'])) {
|
||||
$data = array('data' => $params['data']);
|
||||
|
@ -278,7 +278,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
}
|
||||
|
||||
if (!empty($view->pageTitle)) {
|
||||
$result = am($result, array('title' => $view->pageTitle));
|
||||
$result = array_merge($result, array('title' => $view->pageTitle));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -391,7 +391,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
*/
|
||||
function getTests() {
|
||||
$methods = array_diff(parent::getTests(), array('testAction', 'testaction'));
|
||||
$methods = am(am(array('start', 'startCase'), $methods), array('endCase', 'end'));
|
||||
$methods = array_merge(array_merge(array('start', 'startCase'), $methods), array('endCase', 'end'));
|
||||
return $methods;
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -57,10 +57,10 @@ class CakeTestFixture extends Object {
|
|||
$import = array();
|
||||
|
||||
if (is_string($this->import) || is_array($this->import) && isset($this->import['model'])) {
|
||||
$import = am(array('records' => false), ife(is_array($this->import), $this->import, array()));
|
||||
$import = array_merge(array('records' => false), ife(is_array($this->import), $this->import, array()));
|
||||
$import['model'] = ife(is_array($this->import), $this->import['model'], $this->import);
|
||||
} elseif (isset($this->import['table'])) {
|
||||
$import = am(array('connection' => 'default', 'records' => false), $this->import);
|
||||
$import = array_merge(array('connection' => 'default', 'records' => false), $this->import);
|
||||
}
|
||||
|
||||
if (isset($import['model']) && (class_exists($import['model']) || App::import('Model', $import['model']))) {
|
||||
|
|
40
cake/tests/test_app/controllers/tests_apps_controller.php
Normal file
40
cake/tests/test_app/controllers/tests_apps_controller.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?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-2008, 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-2008, Cake Software Foundation, Inc.
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.test_app.plugins.test_plugin.views.helpers
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
class TestsAppsController extends AppController {
|
||||
var $name = 'TestsApps';
|
||||
var $uses = array();
|
||||
|
||||
function index(){
|
||||
}
|
||||
|
||||
function some_method() {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,40 @@
|
|||
<?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-2008, 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-2008, Cake Software Foundation, Inc.
|
||||
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
||||
* @package cake.tests
|
||||
* @subpackage cake.tests.test_app.plugins.test_plugin.views.helpers
|
||||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
class TestsPluginsTestsController extends AppController {
|
||||
var $name = 'TestsPluginsTests';
|
||||
var $uses = array();
|
||||
|
||||
function index(){
|
||||
}
|
||||
|
||||
function some_method() {
|
||||
return 25;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1 @@
|
|||
This is the TestsPluginsTestsController index view
|
1
cake/tests/test_app/views/tests_apps/index.ctp
Normal file
1
cake/tests/test_app/views/tests_apps/index.ctp
Normal file
|
@ -0,0 +1 @@
|
|||
This is the TestsAppsController index view
|
Loading…
Add table
Reference in a new issue