diff --git a/cake/console/libs/api.php b/cake/console/libs/api.php index 4bb45ad90..a36792168 100644 --- a/cake/console/libs/api.php +++ b/cake/console/libs/api.php @@ -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, diff --git a/cake/console/libs/tasks/db_config.php b/cake/console/libs/tasks/db_config.php index bb81ef552..630d5b62c 100644 --- a/cake/console/libs/tasks/db_config.php +++ b/cake/console/libs/tasks/db_config.php @@ -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 = "__defaultConfig, $config); + $config = array_merge($this->__defaultConfig, $config); extract($config); $out .= "\tvar \${$name} = array(\n"; $out .= "\t\t'driver' => '{$driver}',\n"; diff --git a/cake/console/libs/tasks/view.php b/cake/console/libs/tasks/view.php index a588ef4b9..51a9e9a26 100644 --- a/cake/console/libs/tasks/view.php +++ b/cake/console/libs/tasks/view.php @@ -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); } diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 11edc2439..ac9600ad4 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -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; } diff --git a/cake/libs/error.php b/cake/libs/error.php index 744c6301f..fbb4c3ebf 100644 --- a/cake/libs/error.php +++ b/cake/libs/error.php @@ -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), "'{$url}'"), '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); } } ?> \ No newline at end of file diff --git a/cake/libs/model/behaviors/tree.php b/cake/libs/model/behaviors/tree.php index 2473b5efd..e1223d7b1 100644 --- a/cake/libs/model/behaviors/tree.php +++ b/cake/libs/model/behaviors/tree.php @@ -487,7 +487,7 @@ class TreeBehavior extends ModelBehavior { * @todo Could be written to be faster, *maybe*. Ideally using a subquery and putting all the logic burden on the DB. * @param AppModel $model * @param string $mode parent or tree - * @param mixed $missingParentAction 'return' to do nothing and return, 'delete' to + * @param mixed $missingParentAction 'return' to do nothing and return, 'delete' to * delete, or the id of the parent to set as the parent_id * @return boolean true on success, false on failure * @access public @@ -505,14 +505,14 @@ class TreeBehavior extends ModelBehavior { 'fields' => array($model->primaryKey, $left, $right, $parent, 'actsAs' => '') )))); - $missingParents = $model->find('list', array('recursive' => 0, 'conditions' => - array($scope, array('NOT' => array($model->escapeField($parent) => null), $model->VerifyParent->escapeField() => null)))); + $missingParents = $model->find('list', array('recursive' => 0, 'conditions' => + array($scope, array('NOT' => array($model->escapeField($parent) => null), $model->VerifyParent->escapeField() => null)))); $model->unbindModel(array('belongsTo' => array('VerifyParent'))); if ($missingParents) { if ($missingParentAction == 'return') { foreach ($missingParents as $id => $display) { - $this->errors[] = 'cannot find the parent for ' . $model->alias . ' with id ' . $id . '(' . $display . ')'; - + $this->errors[] = 'cannot find the parent for ' . $model->alias . ' with id ' . $id . '(' . $display . ')'; + } return false; } elseif ($missingParentAction == 'delete') { @@ -555,11 +555,11 @@ class TreeBehavior extends ModelBehavior { * Requires a valid tree, by default it verifies the tree before beginning. * * @param AppModel $model - * @param array $options + * @param array $options * @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; @@ -575,7 +575,7 @@ class TreeBehavior extends ModelBehavior { $model->moveDown($id, true); if ($node[$model->alias][$left] != $node[$model->alias][$right] - 1) { $this->reorder($model, compact('id', 'field', 'order', 'verify')); - } + } } } return true; diff --git a/cake/libs/model/datasources/dbo/dbo_oracle.php b/cake/libs/model/datasources/dbo/dbo_oracle.php index a46b676a1..790cca0c1 100644 --- a/cake/libs/model/datasources/dbo/dbo_oracle.php +++ b/cake/libs/model/datasources/dbo/dbo_oracle.php @@ -131,7 +131,7 @@ class DboOracle extends DboSource { * @access protected */ var $_results; - + /** * Base configuration settings for MySQL driver * @@ -156,7 +156,7 @@ class DboOracle extends DboSource { $config = $this->config; $this->connected = false; $config['charset'] = !empty($config['charset']) ? $config['charset'] : null; - + if ($this->config['persistent']) { $connect = 'ociplogon'; } else { @@ -451,7 +451,7 @@ class DboOracle extends DboSource { $this->__cacheDescription($this->fullTableName($model, false), $fields); return $fields; } - + /** * Returns an array of the indexes in given table name. * @@ -462,20 +462,20 @@ class DboOracle extends DboSource { $index = array(); $table = $this->fullTableName($model, false); if($table) { - $indexes = $this->query('SELECT + $indexes = $this->query('SELECT cc.table_name, cc.column_name, cc.constraint_name, c.constraint_type, i.index_name, i.uniqueness - FROM user_cons_columns cc - LEFT JOIN user_indexes i ON(cc.constraint_name = i.index_name) + FROM user_cons_columns cc + LEFT JOIN user_indexes i ON(cc.constraint_name = i.index_name) LEFT JOIN user_constraints c ON(c.constraint_name = cc.constraint_name) WHERE cc.table_name = \'' . strtoupper($table) .'\''); foreach ($indexes as $i => $idx) { if ($idx['c']['constraint_type'] == 'P') { - $key = 'PRIMARY'; + $key = 'PRIMARY'; } else { continue; } @@ -493,7 +493,7 @@ class DboOracle extends DboSource { } return $index; } - + /** * Generate a Oracle Alter Table syntax for the given Schema comparison * @@ -542,7 +542,7 @@ class DboOracle extends DboSource { } return $out; } - + /** * This method should quote Oracle identifiers. Well it doesn't. * It would break all scaffolding and all of Cake's default assumptions. @@ -740,7 +740,7 @@ class DboOracle extends DboSource { function insertMulti($table, $fields, $values) { parent::__insertMulti($table, $fields, $values); } - + /** * Renders a final SQL statement by putting together the component parts in the correct order * @@ -770,7 +770,7 @@ class DboOracle extends DboSource { break; } } - + /** * Enter description here... * @@ -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); } } @@ -845,7 +845,7 @@ class DboOracle extends DboSource { $ins[] = $in; } } - + $foreignKey = $model->hasAndBelongsToMany[$association]['foreignKey']; $joinKeys = array($foreignKey, $model->hasAndBelongsToMany[$association]['associationForeignKey']); list($with, $habtmFields) = $model->joinModel($model->hasAndBelongsToMany[$association]['with'], $joinKeys); @@ -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); } } } @@ -927,7 +927,7 @@ class DboOracle extends DboSource { } } } - + } ?> \ No newline at end of file diff --git a/cake/libs/object.php b/cake/libs/object.php index d131ab8cb..28c68e94f 100644 --- a/cake/libs/object.php +++ b/cake/libs/object.php @@ -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) { diff --git a/cake/libs/set.php b/cake/libs/set.php index 44fc7fa91..c545f854e 100644 --- a/cake/libs/set.php +++ b/cake/libs/set.php @@ -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; @@ -894,7 +894,7 @@ class Set extends Object { return $stack; } /** - * Sorts an array by any value, determined by a Set-compatible path + * Sorts an array by any value, determined by a Set-compatible path * * @param array $data * @param string $path A Set-compatible path to the array value diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 750304a0f..e824997e0 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -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, diff --git a/cake/tests/cases/libs/http_socket.test.php b/cake/tests/cases/libs/http_socket.test.php index a29c5aeee..22ef842c0 100644 --- a/cake/tests/cases/libs/http_socket.test.php +++ b/cake/tests/cases/libs/http_socket.test.php @@ -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); diff --git a/cake/tests/cases/libs/model/behaviors/translate.test.php b/cake/tests/cases/libs/model/behaviors/translate.test.php index 6d4a34cc5..b2a74509d 100644 --- a/cake/tests/cases/libs/model/behaviors/translate.test.php +++ b/cake/tests/cases/libs/model/behaviors/translate.test.php @@ -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); } diff --git a/cake/tests/cases/libs/model/model.test.php b/cake/tests/cases/libs/model/model.test.php index 719f8c252..7629ed3b4 100644 --- a/cake/tests/cases/libs/model/model.test.php +++ b/cake/tests/cases/libs/model/model.test.php @@ -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') )); diff --git a/cake/tests/cases/libs/model/models.php b/cake/tests/cases/libs/model/models.php index d9869cacf..b0cfbcb54 100644 --- a/cake/tests/cases/libs/model/models.php +++ b/cake/tests/cases/libs/model/models.php @@ -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; } diff --git a/cake/tests/cases/libs/object.test.php b/cake/tests/cases/libs/object.test.php index 43eb34258..1084fe72a 100644 --- a/cake/tests/cases/libs/object.test.php +++ b/cake/tests/cases/libs/object.test.php @@ -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(); @@ -82,11 +94,11 @@ class ObjectTest extends UnitTestCase { $this->object->oneParamMethod('Hello'); $expected[] = array('oneParamMethod' => array('Hello')); $this->assertIdentical($this->object->methodCalls, $expected); - + $this->object->twoParamMethod(true, false); $expected[] = array('twoParamMethod' => array(true, false)); $this->assertIdentical($this->object->methodCalls, $expected); - + $this->object->threeParamMethod(true, false, null); $expected[] = array('threeParamMethod' => array(true, false, null)); $this->assertIdentical($this->object->methodCalls, $expected); @@ -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); } } - ?> \ No newline at end of file diff --git a/cake/tests/lib/cake_test_case.php b/cake/tests/lib/cake_test_case.php index 81b354b94..ca13373fe 100644 --- a/cake/tests/lib/cake_test_case.php +++ b/cake/tests/lib/cake_test_case.php @@ -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; } /** diff --git a/cake/tests/lib/cake_test_fixture.php b/cake/tests/lib/cake_test_fixture.php index c011cdc1b..2543de59e 100644 --- a/cake/tests/lib/cake_test_fixture.php +++ b/cake/tests/lib/cake_test_fixture.php @@ -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']))) { diff --git a/cake/tests/test_app/controllers/tests_apps_controller.php b/cake/tests/test_app/controllers/tests_apps_controller.php new file mode 100644 index 000000000..35b82ad3a --- /dev/null +++ b/cake/tests/test_app/controllers/tests_apps_controller.php @@ -0,0 +1,40 @@ + + * 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; + } +} +?> \ No newline at end of file diff --git a/cake/tests/test_app/plugins/test_plugin/controllers/tests_plugins_tests_controller.php b/cake/tests/test_app/plugins/test_plugin/controllers/tests_plugins_tests_controller.php new file mode 100644 index 000000000..2e83ab4f8 --- /dev/null +++ b/cake/tests/test_app/plugins/test_plugin/controllers/tests_plugins_tests_controller.php @@ -0,0 +1,40 @@ + + * 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; + } +} +?> \ No newline at end of file diff --git a/cake/tests/test_app/plugins/test_plugin/views/tests_plugins_tests/index.ctp b/cake/tests/test_app/plugins/test_plugin/views/tests_plugins_tests/index.ctp new file mode 100644 index 000000000..ee2dea150 --- /dev/null +++ b/cake/tests/test_app/plugins/test_plugin/views/tests_plugins_tests/index.ctp @@ -0,0 +1 @@ +This is the TestsPluginsTestsController index view \ No newline at end of file diff --git a/cake/tests/test_app/views/tests_apps/index.ctp b/cake/tests/test_app/views/tests_apps/index.ctp new file mode 100644 index 000000000..36aecfa1d --- /dev/null +++ b/cake/tests/test_app/views/tests_apps/index.ctp @@ -0,0 +1 @@ +This is the TestsAppsController index view \ No newline at end of file