mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge remote branch 'origin/2.0' into feature/2.0/pdo
Conflicts: cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php
This commit is contained in:
commit
b6731dd9ad
52 changed files with 540 additions and 288 deletions
|
@ -18,7 +18,8 @@
|
|||
// @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
// +--------------------------------------------------------------------------------------------+ //
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
1.3.5
|
||||
1.3.6
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -264,14 +264,14 @@ if (!function_exists('sortByKey')) {
|
|||
* @link http://book.cakephp.org/view/1130/env
|
||||
*/
|
||||
function env($key) {
|
||||
if ($key == 'HTTPS') {
|
||||
if ($key === 'HTTPS') {
|
||||
if (isset($_SERVER['HTTPS'])) {
|
||||
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off');
|
||||
}
|
||||
return (strpos(env('SCRIPT_URI'), 'https://') === 0);
|
||||
}
|
||||
|
||||
if ($key == 'SCRIPT_NAME') {
|
||||
if ($key === 'SCRIPT_NAME') {
|
||||
if (env('CGI_MODE') && isset($_ENV['SCRIPT_URL'])) {
|
||||
$key = 'SCRIPT_URL';
|
||||
}
|
||||
|
|
|
@ -17,4 +17,4 @@
|
|||
* @since CakePHP(tm) v 1.1.11.4062
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
return $config['Cake.version'] = '1.3.5';
|
||||
return $config['Cake.version'] = '1.3.6';
|
||||
|
|
|
@ -23,3 +23,4 @@
|
|||
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR. 'shell_dispatcher.php');
|
||||
|
||||
return ShellDispatcher::run($argv);
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
* @since CakePHP(tm) v 2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
App::import('Core', 'String', false);
|
||||
|
||||
/**
|
||||
* HelpFormatter formats help for console shells. Can format to either
|
||||
* text or XML formats. Uses ConsoleOptionParser methods to generate help.
|
||||
|
|
33
cake/console/shells/app_shell.php
Normal file
33
cake/console/shells/app_shell.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* AppShell file
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.console.shells
|
||||
* @since CakePHP(tm) v 2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a placeholder class.
|
||||
* Create the same file in app/console/shells/app_shell.php
|
||||
*
|
||||
* Add your application-wide methods in the class below, your shells
|
||||
* will inherit them.
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.cake.console.libs
|
||||
*/
|
||||
class AppShell extends Shell {
|
||||
|
||||
}
|
|
@ -40,7 +40,14 @@ class BakeShell extends Shell {
|
|||
public $tasks = array('Project', 'DbConfig', 'Model', 'Controller', 'View', 'Plugin', 'Fixture', 'Test');
|
||||
|
||||
/**
|
||||
* Override loadTasks() to handle paths
|
||||
* The connection being used.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $connection = 'default';
|
||||
|
||||
/**
|
||||
* Assign $this->connection to the active task if a connection param is set.
|
||||
*
|
||||
*/
|
||||
public function startup() {
|
||||
|
@ -121,7 +128,6 @@ class BakeShell extends Shell {
|
|||
*
|
||||
*/
|
||||
public function all() {
|
||||
$this->hr();
|
||||
$this->out('Bake All');
|
||||
$this->hr();
|
||||
|
||||
|
@ -156,7 +162,6 @@ class BakeShell extends Shell {
|
|||
$modelBaked = $this->Model->bake($object, false);
|
||||
|
||||
if ($modelBaked && $modelExists === false) {
|
||||
$this->out(sprintf(__('%s Model was baked.'), $model));
|
||||
if ($this->_checkUnitTest()) {
|
||||
$this->Model->bakeFixture($model);
|
||||
$this->Model->bakeTest($model);
|
||||
|
@ -167,7 +172,6 @@ class BakeShell extends Shell {
|
|||
if ($modelExists === true) {
|
||||
$controller = $this->_controllerName($name);
|
||||
if ($this->Controller->bake($controller, $this->Controller->bakeActions($controller))) {
|
||||
$this->out(sprintf(__('%s Controller was baked.'), $name));
|
||||
if ($this->_checkUnitTest()) {
|
||||
$this->Controller->bakeTest($controller);
|
||||
}
|
||||
|
@ -175,9 +179,9 @@ class BakeShell extends Shell {
|
|||
if (App::import('Controller', $controller)) {
|
||||
$this->View->args = array($controller);
|
||||
$this->View->execute();
|
||||
$this->out(sprintf(__('%s Views were baked.'), $name));
|
||||
}
|
||||
$this->out(__('Bake All complete'));
|
||||
$this->out('', 1, Shell::QUIET);
|
||||
$this->out(__('<success>Bake All complete</success>'), 1, Shell::QUIET);
|
||||
array_shift($this->args);
|
||||
} else {
|
||||
$this->error(__('Bake All could not continue without a valid model'));
|
||||
|
|
|
@ -111,7 +111,7 @@ class CommandListShell extends Shell {
|
|||
continue;
|
||||
}
|
||||
foreach ($shells as $shell) {
|
||||
if ($shell !== 'shell.php') {
|
||||
if ($shell !== 'shell.php' && $shell !== 'app_shell.php') {
|
||||
$shell = str_replace('.php', '', $shell);
|
||||
$shellList[$shell][$type] = $type;
|
||||
}
|
||||
|
|
|
@ -164,6 +164,14 @@ class Shell extends Object {
|
|||
if ($this->stdin == null) {
|
||||
$this->stdin = new ConsoleInput('php://stdin');
|
||||
}
|
||||
|
||||
$parent = get_parent_class($this);
|
||||
if ($this->tasks !== null && $this->tasks !== false) {
|
||||
$this->_mergeVars(array('tasks'), $parent, true);
|
||||
}
|
||||
if ($this->uses !== null && $this->uses !== false) {
|
||||
$this->_mergeVars(array('uses'), $parent, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -302,6 +302,8 @@ class ControllerTask extends BakeTask {
|
|||
* @return string Baked controller
|
||||
*/
|
||||
public function bake($controllerName, $actions = '', $helpers = null, $components = null) {
|
||||
$this->out("\nBaking controller class for $controllerName...", 1, Shell::QUIET);
|
||||
|
||||
$isScaffold = ($actions === 'scaffold') ? true : false;
|
||||
|
||||
$this->Template->set('plugin', Inflector::camelize($this->plugin));
|
||||
|
|
|
@ -254,7 +254,7 @@ class FixtureTask extends BakeTask {
|
|||
$this->Template->set($vars);
|
||||
$content = $this->Template->generate('classes', 'fixture');
|
||||
|
||||
$this->out("\nBaking test fixture for $model...");
|
||||
$this->out("\nBaking test fixture for $model...", 1, Shell::QUIET);
|
||||
$this->createFile($path . $filename, $content);
|
||||
return $content;
|
||||
}
|
||||
|
|
|
@ -742,7 +742,7 @@ class ModelTask extends BakeTask {
|
|||
|
||||
$path = $this->getPath();
|
||||
$filename = $path . Inflector::underscore($name) . '.php';
|
||||
$this->out("\nBaking model class for $name...");
|
||||
$this->out("\nBaking model class for $name...", 1, Shell::QUIET);
|
||||
$this->createFile($filename, $out);
|
||||
ClassRegistry::flush();
|
||||
return $out;
|
||||
|
|
|
@ -115,7 +115,7 @@ class TestTask extends BakeTask {
|
|||
*/
|
||||
public function bake($type, $className) {
|
||||
if ($this->typeCanDetectFixtures($type) && $this->isLoadableClass($type, $className)) {
|
||||
$this->out(__('Bake is detecting possible fixtures..'));
|
||||
$this->out(__('Bake is detecting possible fixtures...'));
|
||||
$testSubject = $this->buildTestSubject($type, $className);
|
||||
$this->generateFixtureList($testSubject);
|
||||
} elseif ($this->interactive) {
|
||||
|
@ -134,6 +134,7 @@ class TestTask extends BakeTask {
|
|||
if ($this->plugin) {
|
||||
$plugin = $this->plugin . '.';
|
||||
}
|
||||
$this->out("\nBaking test case for $className $type...", 1, Shell::QUIET);
|
||||
|
||||
$this->Template->set('fixtures', $this->_fixtures);
|
||||
$this->Template->set('plugin', $plugin);
|
||||
|
|
|
@ -366,6 +366,7 @@ class ViewTask extends BakeTask {
|
|||
if (empty($content)) {
|
||||
return false;
|
||||
}
|
||||
$this->out("\nBaking `$action` view file...", 1, Shell::QUIET);
|
||||
$path = $this->getPath();
|
||||
$filename = $path . $this->controllerPath . DS . Inflector::underscore($action) . '.ctp';
|
||||
return $this->createFile($filename, $content);
|
||||
|
|
|
@ -56,7 +56,7 @@ class TestSuiteShell extends Shell {
|
|||
))->addOption('log-dbus', array(
|
||||
'help' => __('Log test execution to DBUS.'),
|
||||
'default' => false
|
||||
))->addOption('--coverage-html', array(
|
||||
))->addOption('coverage-html', array(
|
||||
'help' => __('<dir> Generate code coverage report in HTML format.'),
|
||||
'default' => false
|
||||
))->addOption('coverage-clover', array(
|
||||
|
@ -280,8 +280,7 @@ class TestSuiteShell extends Shell {
|
|||
|
||||
if (empty($testCases)) {
|
||||
$this->out(__("No test cases available \n\n"));
|
||||
$this->help();
|
||||
$this->_stop();
|
||||
return $this->out($this->OptionParser->help());
|
||||
}
|
||||
|
||||
$this->out($title);
|
||||
|
|
|
@ -324,9 +324,6 @@ class App {
|
|||
*/
|
||||
public static function core($type = null) {
|
||||
static $paths = false;
|
||||
if ($paths === false) {
|
||||
$paths = Cache::read('core_paths', '_cake_core_');
|
||||
}
|
||||
if (!$paths) {
|
||||
$paths = array();
|
||||
$libs = dirname(__FILE__) . DS;
|
||||
|
@ -347,8 +344,6 @@ class App {
|
|||
$paths['shells'][] = $cake . 'console' . DS . 'shells' . DS;
|
||||
// Provide BC path to vendors/shells
|
||||
$paths['shells'][] = $path . 'vendors' . DS . 'shells' . DS;
|
||||
|
||||
Cache::write('core_paths', array_filter($paths), '_cake_core_');
|
||||
}
|
||||
if ($type && isset($paths[$type])) {
|
||||
return $paths[$type];
|
||||
|
@ -513,8 +508,6 @@ class App {
|
|||
if ($name != null && !class_exists($name . $ext['class'])) {
|
||||
if ($load = self::__mapped($name . $ext['class'], $type, $plugin)) {
|
||||
if (self::__load($load)) {
|
||||
self::__overload($type, $name . $ext['class'], $parent);
|
||||
|
||||
if (self::$return) {
|
||||
return include($load);
|
||||
}
|
||||
|
@ -554,7 +547,6 @@ class App {
|
|||
if ($directory !== null) {
|
||||
self::$__cache = true;
|
||||
self::__map($directory . $file, $name . $ext['class'], $type, $plugin);
|
||||
self::__overload($type, $name . $ext['class'], $parent);
|
||||
|
||||
if (self::$return) {
|
||||
return include($directory . $file);
|
||||
|
@ -696,17 +688,6 @@ class App {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to overload objects as needed.
|
||||
*
|
||||
* @param string $type Model or Helper
|
||||
* @param string $name Class name to overload
|
||||
* @access private
|
||||
*/
|
||||
private static function __overload($type, $name, $parent) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads parent classes based on $type.
|
||||
* Returns a prefix or suffix needed for loading files.
|
||||
|
@ -796,6 +777,9 @@ class App {
|
|||
if (!class_exists('Shell')) {
|
||||
App::import($type, 'Shell', false);
|
||||
}
|
||||
if (!class_exists('AppShell')) {
|
||||
App::import($type, 'AppShell', false);
|
||||
}
|
||||
if ($plugin) {
|
||||
$path = $pluginPath . DS . 'console' . DS . 'shells' . DS;
|
||||
}
|
||||
|
|
|
@ -520,7 +520,6 @@ class AuthComponent extends Component {
|
|||
$valid = $this->Acl->check($user, $this->action());
|
||||
break;
|
||||
case 'crud':
|
||||
$this->mapActions();
|
||||
if (!isset($this->actionMap[$this->request['action']])) {
|
||||
trigger_error(
|
||||
sprintf(__('Auth::startup() - Attempted access of un-mapped action "%1$s" in controller "%2$s"'), $this->request['action'], $this->request['controller']),
|
||||
|
@ -535,7 +534,6 @@ class AuthComponent extends Component {
|
|||
}
|
||||
break;
|
||||
case 'model':
|
||||
$this->mapActions();
|
||||
$action = $this->request['action'];
|
||||
if (isset($this->actionMap[$action])) {
|
||||
$action = $this->actionMap[$action];
|
||||
|
|
|
@ -618,10 +618,15 @@ class SecurityComponent extends Component {
|
|||
}
|
||||
unset($check['_Token']);
|
||||
|
||||
$locked = str_rot13($locked);
|
||||
if (preg_match('/(\A|;|{|})O\:[0-9]+/', $locked)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$lockedFields = array();
|
||||
$fields = Set::flatten($check);
|
||||
$fieldList = array_keys($fields);
|
||||
$locked = unserialize(str_rot13($locked));
|
||||
$locked = unserialize($locked);
|
||||
$multi = array();
|
||||
|
||||
foreach ($fieldList as $i => $key) {
|
||||
|
|
|
@ -415,23 +415,21 @@ class Controller extends Object {
|
|||
* @return void
|
||||
*/
|
||||
protected function __mergeVars() {
|
||||
$pluginName = Inflector::camelize($this->plugin);
|
||||
$pluginController = $pluginName . 'AppController';
|
||||
$pluginName = $pluginController = $plugin = null;
|
||||
|
||||
if (is_subclass_of($this, 'AppController') || is_subclass_of($this, $pluginController)) {
|
||||
if (!empty($this->plugin)) {
|
||||
$pluginName = Inflector::camelize($this->plugin);
|
||||
$pluginController = $pluginName . 'AppController';
|
||||
if (!is_subclass_of($this, $pluginController)) {
|
||||
$pluginController = null;
|
||||
}
|
||||
$plugin = $pluginName . '.';
|
||||
}
|
||||
|
||||
if (is_subclass_of($this, 'AppController') || !empty($pluginController)) {
|
||||
$appVars = get_class_vars('AppController');
|
||||
$uses = $appVars['uses'];
|
||||
$merge = array('components', 'helpers');
|
||||
$plugin = null;
|
||||
|
||||
if (!empty($this->plugin)) {
|
||||
$plugin = $pluginName . '.';
|
||||
if (!is_subclass_of($this, $pluginController)) {
|
||||
$pluginController = null;
|
||||
}
|
||||
} else {
|
||||
$pluginController = null;
|
||||
}
|
||||
|
||||
if ($uses == $this->uses && !empty($this->uses)) {
|
||||
if (!in_array($plugin . $this->modelClass, $this->uses)) {
|
||||
|
@ -443,50 +441,18 @@ class Controller extends Object {
|
|||
array_unshift($this->uses, $plugin . $this->modelClass);
|
||||
}
|
||||
} elseif ($this->uses !== null || $this->uses !== false) {
|
||||
$merge[] = 'uses';
|
||||
}
|
||||
|
||||
foreach ($merge as $var) {
|
||||
if (!empty($appVars[$var]) && is_array($this->{$var})) {
|
||||
if ($var === 'components') {
|
||||
$normal = Set::normalize($this->{$var});
|
||||
$app = Set::normalize($appVars[$var]);
|
||||
if ($app !== $normal) {
|
||||
$this->{$var} = Set::merge($app, $normal);
|
||||
}
|
||||
} else {
|
||||
$this->{$var} = Set::merge(
|
||||
$this->{$var}, array_diff($appVars[$var], $this->{$var})
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->_mergeVars(array('uses'), 'AppController', false);
|
||||
}
|
||||
$this->_mergeVars($merge, 'AppController', true);
|
||||
}
|
||||
|
||||
if ($pluginController && $pluginName != null) {
|
||||
$appVars = get_class_vars($pluginController);
|
||||
$uses = $appVars['uses'];
|
||||
$merge = array('components', 'helpers');
|
||||
|
||||
if ($this->uses !== null || $this->uses !== false) {
|
||||
$merge[] = 'uses';
|
||||
}
|
||||
|
||||
foreach ($merge as $var) {
|
||||
if (isset($appVars[$var]) && !empty($appVars[$var]) && is_array($this->{$var})) {
|
||||
if ($var === 'components') {
|
||||
$normal = Set::normalize($this->{$var});
|
||||
$app = Set::normalize($appVars[$var]);
|
||||
if ($app !== $normal) {
|
||||
$this->{$var} = Set::merge($app, $normal);
|
||||
}
|
||||
} else {
|
||||
$this->{$var} = Set::merge(
|
||||
$this->{$var}, array_diff($appVars[$var], $this->{$var})
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->_mergeVars(array('uses'), $pluginController, false);
|
||||
}
|
||||
$this->_mergeVars($merge, $pluginController);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -244,7 +244,7 @@ class Folder {
|
|||
* @static
|
||||
*/
|
||||
function isWindowsPath($path) {
|
||||
return (bool)preg_match('/^[A-Z]:\\\\/i', $path);
|
||||
return (preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -256,7 +256,7 @@ class Folder {
|
|||
* @static
|
||||
*/
|
||||
function isAbsolute($path) {
|
||||
return !empty($path) && ($path[0] === '/' || preg_match('/^[A-Z]:\\\\/i', $path));
|
||||
return !empty($path) && ($path[0] === '/' || preg_match('/^[A-Z]:\\\\/i', $path) || substr($path, 0, 2) == '\\\\');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -139,11 +139,11 @@ class I18n {
|
|||
|
||||
$_this->domain = $domain . '_' . $_this->l10n->lang;
|
||||
|
||||
if (empty($_this->__domains[$domain][$_this->__lang])) {
|
||||
if (!isset($_this->__domains[$domain][$_this->__lang])) {
|
||||
$_this->__domains[$domain][$_this->__lang] = Cache::read($_this->domain, '_cake_core_');
|
||||
}
|
||||
|
||||
if (empty($_this->__domains[$domain][$_this->__lang][$_this->category])) {
|
||||
if (!isset($_this->__domains[$domain][$_this->__lang][$_this->category])) {
|
||||
$_this->__bindTextDomain($domain);
|
||||
Cache::write($_this->domain, $_this->__domains[$domain][$_this->__lang], '_cake_core_');
|
||||
}
|
||||
|
|
|
@ -67,9 +67,6 @@ class FileLog implements CakeLogInterface {
|
|||
$filename = $this->_path . $type . '.log';
|
||||
}
|
||||
$output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $message . "\n";
|
||||
$log = new SplFileObject($filename, 'a+');
|
||||
if ($log->isWritable()) {
|
||||
return $log->fwrite($output);
|
||||
}
|
||||
return file_put_contents($filename, $output, FILE_APPEND);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,8 +64,8 @@ class BehaviorCollection extends ObjectCollection {
|
|||
$this->modelName = $modelName;
|
||||
|
||||
if (!empty($behaviors)) {
|
||||
foreach (Set::normalize($behaviors) as $behavior => $config) {
|
||||
$this->load($behavior, $config);
|
||||
foreach (BehaviorCollection::normalizeObjectArray($behaviors) as $behavior => $config) {
|
||||
$this->load($config['class'], $config['settings']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -438,27 +438,15 @@ class Model extends Object {
|
|||
}
|
||||
|
||||
if (is_subclass_of($this, 'AppModel')) {
|
||||
$appVars = get_class_vars('AppModel');
|
||||
$merge = array('_findMethods');
|
||||
|
||||
if ($this->actsAs !== null || $this->actsAs !== false) {
|
||||
$merge[] = 'actsAs';
|
||||
}
|
||||
$parentClass = get_parent_class($this);
|
||||
if (strtolower($parentClass) !== 'appmodel') {
|
||||
$parentVars = get_class_vars($parentClass);
|
||||
foreach ($merge as $var) {
|
||||
if (isset($parentVars[$var]) && !empty($parentVars[$var])) {
|
||||
$appVars[$var] = Set::merge($appVars[$var], $parentVars[$var]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($merge as $var) {
|
||||
if (isset($appVars[$var]) && !empty($appVars[$var]) && is_array($this->{$var})) {
|
||||
$this->{$var} = Set::merge($appVars[$var], $this->{$var});
|
||||
}
|
||||
if ($parentClass !== 'AppModel') {
|
||||
$this->_mergeVars($merge, $parentClass);
|
||||
}
|
||||
$this->_mergeVars($merge, 'AppModel');
|
||||
}
|
||||
$this->Behaviors = new BehaviorCollection();
|
||||
|
||||
|
@ -629,9 +617,9 @@ class Model extends Object {
|
|||
*
|
||||
* Example: Turn off the associated Model Support request,
|
||||
* to temporarily lighten the User model:
|
||||
*
|
||||
*
|
||||
* `$this->User->unbindModel( array('hasMany' => array('Supportrequest')) );`
|
||||
*
|
||||
*
|
||||
* unbound models that are not made permanent will reset with the next call to Model::find()
|
||||
*
|
||||
* @param array $params Set of bindings to unbind (indexed by binding type)
|
||||
|
@ -1631,7 +1619,7 @@ class Model extends Object {
|
|||
}
|
||||
|
||||
if ($options['atomic'] && $options['validate'] !== 'only') {
|
||||
$db->begin($this);
|
||||
$transactionBegun = $db->begin($this);
|
||||
}
|
||||
|
||||
if (Set::numeric(array_keys($data))) {
|
||||
|
@ -1671,8 +1659,12 @@ class Model extends Object {
|
|||
break;
|
||||
default:
|
||||
if ($options['atomic']) {
|
||||
if ($validates && ($db->commit($this) !== false)) {
|
||||
return true;
|
||||
if ($validates) {
|
||||
if ($transactionBegun) {
|
||||
return $db->commit($this) !== false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$db->rollback($this);
|
||||
return false;
|
||||
|
@ -1782,7 +1774,11 @@ class Model extends Object {
|
|||
default:
|
||||
if ($options['atomic']) {
|
||||
if ($validates) {
|
||||
return ($db->commit($this) !== false);
|
||||
if ($transactionBegun) {
|
||||
return $db->commit($this) !== false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
$db->rollback($this);
|
||||
}
|
||||
|
@ -1865,7 +1861,7 @@ class Model extends Object {
|
|||
));
|
||||
}
|
||||
|
||||
if ($db->delete($this)) {
|
||||
if ($db->delete($this, array($this->alias . '.' . $this->primaryKey => $id))) {
|
||||
if (!empty($this->belongsTo)) {
|
||||
$this->updateCounterCache($keys[$this->alias]);
|
||||
}
|
||||
|
|
|
@ -198,6 +198,36 @@ class Object {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges this objects $property with the property in $class' definition.
|
||||
* This classes value for the property will be merged on top of $class'
|
||||
*
|
||||
* This provides some of the DRY magic CakePHP provides. If you want to shut it off, redefine
|
||||
* this method as an empty function.
|
||||
*
|
||||
* @param array $properties The name of the properties to merge.
|
||||
* @param sting $class The class to merge the property with.
|
||||
* @param boolean $normalize Set to true to run the properties through Set::normalize() before merging.
|
||||
* @return void
|
||||
*/
|
||||
protected function _mergeVars($properties, $class, $normalize = true) {
|
||||
$classProperties = get_class_vars($class);
|
||||
foreach ($properties as $var) {
|
||||
if (
|
||||
isset($classProperties[$var]) &&
|
||||
!empty($classProperties[$var]) &&
|
||||
is_array($this->{$var}) &&
|
||||
$this->{$var} != $classProperties[$var]
|
||||
) {
|
||||
if ($normalize) {
|
||||
$classProperties[$var] = Set::normalize($classProperties[$var]);
|
||||
$this->{$var} = Set::normalize($this->{$var});
|
||||
}
|
||||
$this->{$var} = Set::merge($classProperties[$var], $this->{$var});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* You should choose a unique name for the persistent file
|
||||
*
|
||||
|
|
|
@ -355,14 +355,13 @@ class Helper extends Object {
|
|||
if (!is_array($exclude)) {
|
||||
$exclude = array();
|
||||
}
|
||||
$keys = array_diff(array_keys($options), array_merge($exclude, array('escape')));
|
||||
$values = array_intersect_key(array_values($options), $keys);
|
||||
$filtered = array_diff_key($options, array_merge(array_flip($exclude), array('escape' => true)));
|
||||
$escape = $options['escape'];
|
||||
$attributes = array();
|
||||
|
||||
foreach ($keys as $index => $key) {
|
||||
if ($values[$index] !== false && $values[$index] !== null) {
|
||||
$attributes[] = $this->__formatAttribute($key, $values[$index], $escape);
|
||||
foreach ($filtered as $key => $value) {
|
||||
if ($value !== false && $value !== null) {
|
||||
$attributes[] = $this->__formatAttribute($key, $value, $escape);
|
||||
}
|
||||
}
|
||||
$out = implode(' ', $attributes);
|
||||
|
|
|
@ -218,7 +218,8 @@ class FormHelper extends AppHelper {
|
|||
$data = $this->fieldset[$modelEntity];
|
||||
$recordExists = (
|
||||
isset($this->request->data[$model]) &&
|
||||
!empty($this->request->data[$model][$data['key']])
|
||||
!empty($this->request->data[$model][$data['key']]) &&
|
||||
!is_array($this->request->data[$model][$data['key']])
|
||||
);
|
||||
|
||||
if ($recordExists) {
|
||||
|
|
|
@ -48,7 +48,7 @@ class NumberHelper extends AppHelper {
|
|||
'decimals' => '.', 'negative' => '()','escape' => false
|
||||
),
|
||||
'EUR' => array(
|
||||
'before'=>'€', 'after' => 'c', 'zero' => 0, 'places' => 2, 'thousands' => '.',
|
||||
'before'=>'€', 'after' => false, 'zero' => 0, 'places' => 2, 'thousands' => '.',
|
||||
'decimals' => ',', 'negative' => '()', 'escape' => false
|
||||
)
|
||||
);
|
||||
|
|
|
@ -21,7 +21,7 @@ if (Configure::read() == 0):
|
|||
endif;
|
||||
?>
|
||||
<h2><?php echo sprintf(__('Release Notes for CakePHP %s.', true), Configure::version()); ?></h2>
|
||||
<a href="http://cakephp.lighthouseapp.com/projects/42648/changelog-1-3-5"><?php __('Read the changelog'); ?> </a>
|
||||
<a href="http://cakephp.org/changelogs/1.3.6"><?php __('Read the changelog'); ?> </a>
|
||||
<?php
|
||||
if (Configure::read() > 0):
|
||||
Debugger::checkSecurityKeys();
|
||||
|
|
|
@ -69,6 +69,20 @@ class TestShell extends Shell {
|
|||
protected function no_access() {
|
||||
|
||||
}
|
||||
|
||||
public function mergeVars($properties, $class, $normalize = true) {
|
||||
return $this->_mergeVars($properties, $class, $normalize);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for testing merging vars
|
||||
*
|
||||
* @package cake.tests.cases.console
|
||||
*/
|
||||
class TestMergeShell extends Shell {
|
||||
var $tasks = array('DbConfig', 'Fixture');
|
||||
var $uses = array('Comment');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,6 +148,25 @@ class ShellTest extends CakeTestCase {
|
|||
$this->assertType('ConsoleOutput', $this->Shell->stderr);
|
||||
}
|
||||
|
||||
/**
|
||||
* test merging vars
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testMergeVars() {
|
||||
$this->Shell->tasks = array('DbConfig' => array('one', 'two'));
|
||||
$this->Shell->uses = array('Posts');
|
||||
$this->Shell->mergeVars(array('tasks'), 'TestMergeShell');
|
||||
$this->Shell->mergeVars(array('uses'), 'TestMergeShell', false);
|
||||
|
||||
$expected = array('DbConfig' => null, 'Fixture' => null, 'DbConfig' => array('one', 'two'));
|
||||
$this->assertEquals($expected, $this->Shell->tasks);
|
||||
|
||||
$expected = array('Fixture' => null, 'DbConfig' => array('one', 'two'));
|
||||
$this->assertEquals($expected, Set::normalize($this->Shell->tasks), 'Normalized results are wrong.');
|
||||
$this->assertEquals(array('Comment', 'Posts'), $this->Shell->uses, 'Merged models are wrong.');
|
||||
}
|
||||
|
||||
/**
|
||||
* testInitialize method
|
||||
*
|
|
@ -304,11 +304,11 @@ class ControllerTaskTest extends CakeTestCase {
|
|||
|
||||
$path = APP . 'plugins' . DS . 'controller_test' . DS . 'controllers' . DS . 'articles_controller.php';
|
||||
|
||||
$this->Task->expects($this->at(0))->method('createFile')->with(
|
||||
$this->Task->expects($this->at(1))->method('createFile')->with(
|
||||
$path,
|
||||
new PHPUnit_Framework_Constraint_IsAnything()
|
||||
);
|
||||
$this->Task->expects($this->at(1))->method('createFile')->with(
|
||||
$this->Task->expects($this->at(3))->method('createFile')->with(
|
||||
$path,
|
||||
new PHPUnit_Framework_Constraint_PCREMatch('/ArticlesController extends ControllerTestAppController/')
|
||||
);
|
||||
|
|
|
@ -42,7 +42,10 @@ class ModelTaskTest extends CakeTestCase {
|
|||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag', 'core.category_thread');
|
||||
public $fixtures = array(
|
||||
'core.bake_article', 'core.bake_comment', 'core.bake_articles_bake_tag',
|
||||
'core.bake_tag', 'core.category_thread'
|
||||
);
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
|
@ -116,25 +119,25 @@ class ModelTaskTest extends CakeTestCase {
|
|||
}
|
||||
$this->_useMockedOut();
|
||||
|
||||
$this->Task->expects($this->at(1))->method('out')->with('1. Article');
|
||||
$this->Task->expects($this->at(2))->method('out')->with('2. ArticlesTag');
|
||||
$this->Task->expects($this->at(3))->method('out')->with('3. CategoryThread');
|
||||
$this->Task->expects($this->at(4))->method('out')->with('4. Comment');
|
||||
$this->Task->expects($this->at(5))->method('out')->with('5. Tag');
|
||||
$this->Task->expects($this->at(1))->method('out')->with('1. BakeArticle');
|
||||
$this->Task->expects($this->at(2))->method('out')->with('2. BakeArticlesBakeTag');
|
||||
$this->Task->expects($this->at(3))->method('out')->with('3. BakeComment');
|
||||
$this->Task->expects($this->at(4))->method('out')->with('4. BakeTag');
|
||||
$this->Task->expects($this->at(5))->method('out')->with('5. CategoryThread');
|
||||
|
||||
$this->Task->expects($this->at(7))->method('out')->with('1. Article');
|
||||
$this->Task->expects($this->at(8))->method('out')->with('2. ArticlesTag');
|
||||
$this->Task->expects($this->at(9))->method('out')->with('3. CategoryThread');
|
||||
$this->Task->expects($this->at(10))->method('out')->with('4. Comment');
|
||||
$this->Task->expects($this->at(11))->method('out')->with('5. Tag');
|
||||
$this->Task->expects($this->at(7))->method('out')->with('1. BakeArticle');
|
||||
$this->Task->expects($this->at(8))->method('out')->with('2. BakeArticlesBakeTag');
|
||||
$this->Task->expects($this->at(9))->method('out')->with('3. BakeComment');
|
||||
$this->Task->expects($this->at(10))->method('out')->with('4. BakeTag');
|
||||
$this->Task->expects($this->at(11))->method('out')->with('5. CategoryThread');
|
||||
|
||||
$result = $this->Task->listAll('test');
|
||||
$expected = array('articles', 'articles_tags', 'category_threads', 'comments', 'tags');
|
||||
$expected = array('bake_articles', 'bake_articles_bake_tags', 'bake_comments', 'bake_tags', 'category_threads');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Task->connection = 'test';
|
||||
$result = $this->Task->listAll();
|
||||
$expected = array('articles', 'articles_tags', 'category_threads', 'comments', 'tags');
|
||||
$expected = array('bake_articles', 'bake_articles_bake_tags', 'bake_comments', 'bake_tags', 'category_threads');
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
|
@ -155,20 +158,14 @@ class ModelTaskTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testGetNameValidOption() {
|
||||
$count = count($this->Task->listAll('test'));
|
||||
if ($count != count($this->fixtures)) {
|
||||
$this->markTestSkipped('Additional tables detected.');
|
||||
}
|
||||
|
||||
$listing = $this->Task->listAll('test');
|
||||
$this->Task->expects($this->any())->method('in')->will($this->onConsecutiveCalls(1, 4));
|
||||
|
||||
$result = $this->Task->getName('test');
|
||||
$expected = 'Article';
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->assertEquals(Inflector::classify($listing[0]), $result);
|
||||
|
||||
$result = $this->Task->getName('test');
|
||||
$expected = 'Comment';
|
||||
$this->assertEqual($result, $expected);
|
||||
$this->assertEquals(Inflector::classify($listing[3]), $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,8 +187,8 @@ class ModelTaskTest extends CakeTestCase {
|
|||
*/
|
||||
public function testGetTableName() {
|
||||
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y'));
|
||||
$result = $this->Task->getTable('Article', 'test');
|
||||
$expected = 'articles';
|
||||
$result = $this->Task->getTable('BakeArticle', 'test');
|
||||
$expected = 'bake_articles';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
|
@ -202,7 +199,7 @@ class ModelTaskTest extends CakeTestCase {
|
|||
*/
|
||||
function testGetTableNameCustom() {
|
||||
$this->Task->expects($this->any())->method('in')->will($this->onConsecutiveCalls('n', 'my_table'));
|
||||
$result = $this->Task->getTable('Article', 'test');
|
||||
$result = $this->Task->getTable('BakeArticle', 'test');
|
||||
$expected = 'my_table';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
@ -419,19 +416,19 @@ class ModelTaskTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testBelongsToGeneration() {
|
||||
$model = new Model(array('ds' => 'test', 'name' => 'Comment'));
|
||||
$model = new Model(array('ds' => 'test', 'name' => 'BakeComment'));
|
||||
$result = $this->Task->findBelongsTo($model, array());
|
||||
$expected = array(
|
||||
'belongsTo' => array(
|
||||
array(
|
||||
'alias' => 'Article',
|
||||
'className' => 'Article',
|
||||
'foreignKey' => 'article_id',
|
||||
'alias' => 'BakeArticle',
|
||||
'className' => 'BakeArticle',
|
||||
'foreignKey' => 'bake_article_id',
|
||||
),
|
||||
array(
|
||||
'alias' => 'User',
|
||||
'className' => 'User',
|
||||
'foreignKey' => 'user_id',
|
||||
'alias' => 'BakeUser',
|
||||
'className' => 'BakeUser',
|
||||
'foreignKey' => 'bake_user_id',
|
||||
),
|
||||
)
|
||||
);
|
||||
|
@ -457,23 +454,23 @@ class ModelTaskTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testHasManyHasOneGeneration() {
|
||||
$model = new Model(array('ds' => 'test', 'name' => 'Article'));
|
||||
$model = new Model(array('ds' => 'test', 'name' => 'BakeArticle'));
|
||||
$this->Task->connection = 'test';
|
||||
$this->Task->listAll();
|
||||
$result = $this->Task->findHasOneAndMany($model, array());
|
||||
$expected = array(
|
||||
'hasMany' => array(
|
||||
array(
|
||||
'alias' => 'Comment',
|
||||
'className' => 'Comment',
|
||||
'foreignKey' => 'article_id',
|
||||
'alias' => 'BakeComment',
|
||||
'className' => 'BakeComment',
|
||||
'foreignKey' => 'bake_article_id',
|
||||
),
|
||||
),
|
||||
'hasOne' => array(
|
||||
array(
|
||||
'alias' => 'Comment',
|
||||
'className' => 'Comment',
|
||||
'foreignKey' => 'article_id',
|
||||
'alias' => 'BakeComment',
|
||||
'className' => 'BakeComment',
|
||||
'foreignKey' => 'bake_article_id',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -506,23 +503,18 @@ class ModelTaskTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testHasAndBelongsToManyGeneration() {
|
||||
$count = count($this->Task->listAll('test'));
|
||||
if ($count != count($this->fixtures)) {
|
||||
$this->markTestSkipped('Additional tables detected.');
|
||||
}
|
||||
|
||||
$model = new Model(array('ds' => 'test', 'name' => 'Article'));
|
||||
$model = new Model(array('ds' => 'test', 'name' => 'BakeArticle'));
|
||||
$this->Task->connection = 'test';
|
||||
$this->Task->listAll();
|
||||
$result = $this->Task->findHasAndBelongsToMany($model, array());
|
||||
$expected = array(
|
||||
'hasAndBelongsToMany' => array(
|
||||
array(
|
||||
'alias' => 'Tag',
|
||||
'className' => 'Tag',
|
||||
'foreignKey' => 'article_id',
|
||||
'joinTable' => 'articles_tags',
|
||||
'associationForeignKey' => 'tag_id',
|
||||
'alias' => 'BakeTag',
|
||||
'className' => 'BakeTag',
|
||||
'foreignKey' => 'bake_article_id',
|
||||
'joinTable' => 'bake_articles_bake_tags',
|
||||
'associationForeignKey' => 'bake_tag_id',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -537,23 +529,23 @@ class ModelTaskTest extends CakeTestCase {
|
|||
public function testDoAssociationsNonInteractive() {
|
||||
$this->Task->connection = 'test';
|
||||
$this->Task->interactive = false;
|
||||
$model = new Model(array('ds' => 'test', 'name' => 'Article'));
|
||||
$model = new Model(array('ds' => 'test', 'name' => 'BakeArticle'));
|
||||
$result = $this->Task->doAssociations($model);
|
||||
$expected = array(
|
||||
'hasMany' => array(
|
||||
array(
|
||||
'alias' => 'Comment',
|
||||
'className' => 'Comment',
|
||||
'foreignKey' => 'article_id',
|
||||
'alias' => 'BakeComment',
|
||||
'className' => 'BakeComment',
|
||||
'foreignKey' => 'bake_article_id',
|
||||
),
|
||||
),
|
||||
'hasAndBelongsToMany' => array(
|
||||
array(
|
||||
'alias' => 'Tag',
|
||||
'className' => 'Tag',
|
||||
'foreignKey' => 'article_id',
|
||||
'joinTable' => 'articles_tags',
|
||||
'associationForeignKey' => 'tag_id',
|
||||
'alias' => 'BakeTag',
|
||||
'className' => 'BakeTag',
|
||||
'foreignKey' => 'bake_article_id',
|
||||
'joinTable' => 'bake_articles_bake_tags',
|
||||
'associationForeignKey' => 'bake_tag_id',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -567,8 +559,8 @@ class ModelTaskTest extends CakeTestCase {
|
|||
public function testBakeFixture() {
|
||||
$this->Task->plugin = 'test_plugin';
|
||||
$this->Task->interactive = true;
|
||||
$this->Task->Fixture->expects($this->at(0))->method('bake')->with('Article', 'articles');
|
||||
$this->Task->bakeFixture('Article', 'articles');
|
||||
$this->Task->Fixture->expects($this->at(0))->method('bake')->with('BakeArticle', 'bake_articles');
|
||||
$this->Task->bakeFixture('BakeArticle', 'bake_articles');
|
||||
|
||||
$this->assertEqual($this->Task->plugin, $this->Task->Fixture->plugin);
|
||||
$this->assertEqual($this->Task->connection, $this->Task->Fixture->connection);
|
||||
|
@ -583,8 +575,8 @@ class ModelTaskTest extends CakeTestCase {
|
|||
public function testBakeTest() {
|
||||
$this->Task->plugin = 'test_plugin';
|
||||
$this->Task->interactive = true;
|
||||
$this->Task->Test->expects($this->at(0))->method('bake')->with('Model', 'Article');
|
||||
$this->Task->bakeTest('Article');
|
||||
$this->Task->Test->expects($this->at(0))->method('bake')->with('Model', 'BakeArticle');
|
||||
$this->Task->bakeTest('BakeArticle');
|
||||
|
||||
$this->assertEqual($this->Task->plugin, $this->Task->Test->plugin);
|
||||
$this->assertEqual($this->Task->connection, $this->Task->Test->connection);
|
||||
|
@ -676,9 +668,9 @@ class ModelTaskTest extends CakeTestCase {
|
|||
'time' => 'time'
|
||||
)
|
||||
);
|
||||
$result = $this->Task->bake('Article', compact('validate'));
|
||||
$this->assertPattern('/class Article extends AppModel \{/', $result);
|
||||
$this->assertPattern('/\$name \= \'Article\'/', $result);
|
||||
$result = $this->Task->bake('BakeArticle', compact('validate'));
|
||||
$this->assertPattern('/class BakeArticle extends AppModel \{/', $result);
|
||||
$this->assertPattern('/\$name \= \'BakeArticle\'/', $result);
|
||||
$this->assertPattern('/\$validate \= array\(/', $result);
|
||||
$expected = <<< STRINGEND
|
||||
array(
|
||||
|
@ -708,9 +700,9 @@ STRINGEND;
|
|||
'foreignKey' => 'something_else_id',
|
||||
),
|
||||
array(
|
||||
'alias' => 'User',
|
||||
'className' => 'User',
|
||||
'foreignKey' => 'user_id',
|
||||
'alias' => 'BakeUser',
|
||||
'className' => 'BakeUser',
|
||||
'foreignKey' => 'bake_user_id',
|
||||
),
|
||||
),
|
||||
'hasOne' => array(
|
||||
|
@ -722,30 +714,30 @@ STRINGEND;
|
|||
),
|
||||
'hasMany' => array(
|
||||
array(
|
||||
'alias' => 'Comment',
|
||||
'className' => 'Comment',
|
||||
'alias' => 'BakeComment',
|
||||
'className' => 'BakeComment',
|
||||
'foreignKey' => 'parent_id',
|
||||
),
|
||||
),
|
||||
'hasAndBelongsToMany' => array(
|
||||
array(
|
||||
'alias' => 'Tag',
|
||||
'className' => 'Tag',
|
||||
'foreignKey' => 'article_id',
|
||||
'joinTable' => 'articles_tags',
|
||||
'associationForeignKey' => 'tag_id',
|
||||
'alias' => 'BakeTag',
|
||||
'className' => 'BakeTag',
|
||||
'foreignKey' => 'bake_article_id',
|
||||
'joinTable' => 'bake_articles_bake_tags',
|
||||
'associationForeignKey' => 'bake_tag_id',
|
||||
),
|
||||
)
|
||||
);
|
||||
$result = $this->Task->bake('Article', compact('associations'));
|
||||
$result = $this->Task->bake('BakeArticle', compact('associations'));
|
||||
$this->assertPattern('/\$hasAndBelongsToMany \= array\(/', $result);
|
||||
$this->assertPattern('/\$hasMany \= array\(/', $result);
|
||||
$this->assertPattern('/\$belongsTo \= array\(/', $result);
|
||||
$this->assertPattern('/\$hasOne \= array\(/', $result);
|
||||
$this->assertPattern('/Tag/', $result);
|
||||
$this->assertPattern('/BakeTag/', $result);
|
||||
$this->assertPattern('/OtherModel/', $result);
|
||||
$this->assertPattern('/SomethingElse/', $result);
|
||||
$this->assertPattern('/Comment/', $result);
|
||||
$this->assertPattern('/BakeComment/', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -756,11 +748,11 @@ STRINGEND;
|
|||
public function testBakeWithPlugin() {
|
||||
$this->Task->plugin = 'controllerTest';
|
||||
|
||||
$path = APP . 'plugins' . DS . 'controller_test' . DS . 'models' . DS . 'article.php';
|
||||
$path = APP . 'plugins' . DS . 'controller_test' . DS . 'models' . DS . 'bake_article.php';
|
||||
$this->Task->expects($this->once())->method('createFile')
|
||||
->with($path, new PHPUnit_Framework_Constraint_PCREMatch('/Article extends ControllerTestAppModel/'));
|
||||
->with($path, new PHPUnit_Framework_Constraint_PCREMatch('/BakeArticle extends ControllerTestAppModel/'));
|
||||
|
||||
$this->Task->bake('Article', array(), array());
|
||||
$this->Task->bake('BakeArticle', array(), array());
|
||||
|
||||
$this->assertEqual(count(ClassRegistry::keys()), 0);
|
||||
$this->assertEqual(count(ClassRegistry::mapKeys()), 0);
|
||||
|
@ -774,12 +766,12 @@ STRINGEND;
|
|||
public function testExecuteWithNamedModel() {
|
||||
$this->Task->connection = 'test';
|
||||
$this->Task->path = '/my/path/';
|
||||
$this->Task->args = array('article');
|
||||
$filename = '/my/path/article.php';
|
||||
$this->Task->args = array('bake_article');
|
||||
$filename = '/my/path/bake_article.php';
|
||||
|
||||
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1));
|
||||
$this->Task->expects($this->once())->method('createFile')
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class Article extends AppModel/'));
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle extends AppModel/'));
|
||||
|
||||
$this->Task->execute();
|
||||
|
||||
|
@ -794,7 +786,7 @@ STRINGEND;
|
|||
*/
|
||||
static function nameVariations() {
|
||||
return array(
|
||||
array('Articles'), array('Article'), array('article'), array('articles')
|
||||
array('BakeArticles'), array('BakeArticle'), array('bake_article'), array('bake_articles')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -810,10 +802,10 @@ STRINGEND;
|
|||
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1));
|
||||
|
||||
$this->Task->args = array($name);
|
||||
$filename = '/my/path/article.php';
|
||||
$filename = '/my/path/bake_article.php';
|
||||
|
||||
$this->Task->expects($this->at(0))->method('createFile')
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class Article extends AppModel/'));
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle extends AppModel/'));
|
||||
$this->Task->execute();
|
||||
}
|
||||
|
||||
|
@ -825,12 +817,12 @@ STRINGEND;
|
|||
public function testExecuteWithNamedModelHasManyCreated() {
|
||||
$this->Task->connection = 'test';
|
||||
$this->Task->path = '/my/path/';
|
||||
$this->Task->args = array('article');
|
||||
$filename = '/my/path/article.php';
|
||||
$this->Task->args = array('bake_article');
|
||||
$filename = '/my/path/bake_article.php';
|
||||
|
||||
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1));
|
||||
$this->Task->expects($this->at(0))->method('createFile')
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch("/'Comment' \=\> array\(/"));
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch("/'BakeComment' \=\> array\(/"));
|
||||
|
||||
$this->Task->execute();
|
||||
}
|
||||
|
@ -854,26 +846,26 @@ STRINGEND;
|
|||
$this->Task->Fixture->expects($this->exactly(5))->method('bake');
|
||||
$this->Task->Test->expects($this->exactly(5))->method('bake');
|
||||
|
||||
$filename = '/my/path/article.php';
|
||||
$filename = '/my/path/bake_article.php';
|
||||
$this->Task->expects($this->at(1))->method('createFile')
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class Article/'));
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle/'));
|
||||
|
||||
$filename = '/my/path/articles_tag.php';
|
||||
$filename = '/my/path/bake_articles_bake_tag.php';
|
||||
$this->Task->expects($this->at(2))->method('createFile')
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class ArticlesTag/'));
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesBakeTag/'));
|
||||
|
||||
$filename = '/my/path/category_thread.php';
|
||||
$filename = '/my/path/bake_comment.php';
|
||||
$this->Task->expects($this->at(3))->method('createFile')
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeComment/'));
|
||||
|
||||
$filename = '/my/path/bake_tag.php';
|
||||
$this->Task->expects($this->at(4))
|
||||
->method('createFile')->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeTag/'));
|
||||
|
||||
$filename = '/my/path/category_thread.php';
|
||||
$this->Task->expects($this->at(5))->method('createFile')
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class CategoryThread/'));
|
||||
|
||||
$filename = '/my/path/comment.php';
|
||||
$this->Task->expects($this->at(4))->method('createFile')
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class Comment/'));
|
||||
|
||||
$filename = '/my/path/tag.php';
|
||||
$this->Task->expects($this->at(5))
|
||||
->method('createFile')->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class Tag/'));
|
||||
|
||||
$this->Task->execute();
|
||||
|
||||
$this->assertEqual(count(ClassRegistry::keys()), 0);
|
||||
|
@ -895,26 +887,26 @@ STRINGEND;
|
|||
$this->Task->path = '/my/path/';
|
||||
$this->Task->args = array('all');
|
||||
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true));
|
||||
$this->Task->skipTables = array('tags');
|
||||
$this->Task->skipTables = array('bake_tags');
|
||||
|
||||
$this->Task->Fixture->expects($this->exactly(4))->method('bake');
|
||||
$this->Task->Test->expects($this->exactly(4))->method('bake');
|
||||
|
||||
$filename = '/my/path/article.php';
|
||||
$filename = '/my/path/bake_article.php';
|
||||
$this->Task->expects($this->at(1))->method('createFile')
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class Article/'));
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle/'));
|
||||
|
||||
$filename = '/my/path/articles_tag.php';
|
||||
$filename = '/my/path/bake_articles_bake_tag.php';
|
||||
$this->Task->expects($this->at(2))->method('createFile')
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class ArticlesTag/'));
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesBakeTag/'));
|
||||
|
||||
$filename = '/my/path/bake_comment.php';
|
||||
$this->Task->expects($this->at(3))->method('createFile')
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeComment/'));
|
||||
|
||||
$filename = '/my/path/category_thread.php';
|
||||
$this->Task->expects($this->at(3))->method('createFile')
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class CategoryThread/'));
|
||||
|
||||
$filename = '/my/path/comment.php';
|
||||
$this->Task->expects($this->at(4))->method('createFile')
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class Comment/'));
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class CategoryThread/'));
|
||||
|
||||
$this->Task->execute();
|
||||
}
|
||||
|
@ -950,10 +942,10 @@ STRINGEND;
|
|||
$this->Task->Test->expects($this->once())->method('bake');
|
||||
$this->Task->Fixture->expects($this->once())->method('bake');
|
||||
|
||||
$filename = '/my/path/article.php';
|
||||
$filename = '/my/path/bake_article.php';
|
||||
|
||||
$this->Task->expects($this->once())->method('createFile')
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class Article/'));
|
||||
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle/'));
|
||||
|
||||
$this->Task->execute();
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ class TestSuiteShellTest extends CakeTestCase {
|
|||
array('in', 'out', 'hr', 'help', 'error', 'err', '_stop', 'initialize', 'run', 'clear'),
|
||||
array($out, $out, $in)
|
||||
);
|
||||
$this->Shell->OptionParser = $this->getMock('ConsoleOptionParser', array(), array(null, false));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,7 +62,7 @@ class TestSuiteShellTest extends CakeTestCase {
|
|||
$this->Shell->startup();
|
||||
$this->Shell->args = array('unexistant-category');
|
||||
$this->Shell->expects($this->at(0))->method('out')->with(__("No test cases available \n\n"));
|
||||
$this->Shell->expects($this->once())->method('help');
|
||||
$this->Shell->OptionParser->expects($this->once())->method('help');
|
||||
$this->Shell->available();
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
*/
|
||||
function tearDown() {
|
||||
Configure::write('debug', $this->_debug);
|
||||
unset($this->Case);
|
||||
unset($this->Result);
|
||||
unset($this->Reporter);
|
||||
}
|
||||
|
@ -77,6 +76,30 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
$this->assertEquals(0, $result->errorCount());
|
||||
$this->assertTrue($result->wasSuccessful());
|
||||
$this->assertEquals(0, $result->failureCount());
|
||||
|
||||
$input = '<a href="/test.html" class="active">My link</a>';
|
||||
$pattern = array(
|
||||
'a' => array('href' => '/test.html', 'class' => 'active'),
|
||||
'My link',
|
||||
'/a'
|
||||
);
|
||||
$this->assertTrue($test->assertTags($input, $pattern), 'Double quoted attributes %s');
|
||||
|
||||
$input = "<a href='/test.html' class='active'>My link</a>";
|
||||
$pattern = array(
|
||||
'a' => array('href' => '/test.html', 'class' => 'active'),
|
||||
'My link',
|
||||
'/a'
|
||||
);
|
||||
$this->assertTrue($test->assertTags($input, $pattern), 'Single quoted attributes %s');
|
||||
|
||||
$input = "<a href='/test.html' class='active'>My link</a>";
|
||||
$pattern = array(
|
||||
'a' => array('href' => 'preg:/.*\.html/', 'class' => 'active'),
|
||||
'My link',
|
||||
'/a'
|
||||
);
|
||||
$this->assertTrue($test->assertTags($input, $pattern), 'Single quoted attributes %s');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -181,6 +204,7 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
$manager->expects($this->once())->method('unload');
|
||||
$result = $test->run();
|
||||
$this->assertEquals(1, $result->errorCount());
|
||||
|
||||
}
|
||||
/**
|
||||
* testSkipIf
|
||||
|
|
|
@ -608,6 +608,29 @@ DIGEST;
|
|||
$this->assertFalse($result, 'validatePost passed when fields were missing. %s');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that objects can't be passed into the serialized string. This was a vector for RFI and LFI
|
||||
* attacks. Thanks to Felix Wilhelm
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testValidatePostObjectDeserialize() {
|
||||
$this->Controller->Security->startup($this->Controller);
|
||||
$key = $this->Controller->request->params['_Token']['key'];
|
||||
$fields = 'a5475372b40f6e3ccbf9f8af191f20e1642fd877';
|
||||
|
||||
// a corrupted serialized object, so we can see if it ever gets to deserialize
|
||||
$attack = 'O:3:"App":1:{s:5:"__map";a:1:{s:3:"foo";s:7:"Hacked!";s:1:"fail"}}';
|
||||
$fields .= urlencode(':' . str_rot13($attack));
|
||||
|
||||
$this->Controller->request->data = array(
|
||||
'Model' => array('username' => 'mark', 'password' => 'foo', 'valid' => '0'),
|
||||
'_Token' => compact('key', 'fields')
|
||||
);
|
||||
$result = $this->Controller->Security->validatePost($this->Controller);
|
||||
$this->assertFalse($result, 'validatePost passed when key was missing. %s');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests validation of checkbox arrays
|
||||
*
|
||||
|
|
|
@ -1241,7 +1241,7 @@ class ControllerTest extends CakeTestCase {
|
|||
? array_merge($appVars['uses'], $testVars['uses'])
|
||||
: $testVars['uses'];
|
||||
|
||||
$this->assertEqual(count(array_diff($TestController->helpers, $helpers)), 0);
|
||||
$this->assertEqual(count(array_diff_assoc(Set::normalize($TestController->helpers), Set::normalize($helpers))), 0);
|
||||
$this->assertEqual(count(array_diff($TestController->uses, $uses)), 0);
|
||||
$this->assertEqual(count(array_diff_assoc(Set::normalize($TestController->components), Set::normalize($components))), 0);
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
* @since CakePHP(tm) v 1.2.3
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
App::import('Core', 'Controller');
|
||||
|
||||
if (!class_exists('AppController')) {
|
||||
|
||||
/**
|
||||
|
@ -183,6 +185,27 @@ class ControllerMergeVarsTest extends CakeTestCase {
|
|||
$this->assertEqual($Controller->helpers, $expected, 'Duplication of settings occured. %s');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that helpers declared in appcontroller come before those in the subclass
|
||||
* orderwise
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testHelperOrderPrecedence() {
|
||||
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), "APP_CONTROLLER_EXISTS cannot run {$this->name}");
|
||||
|
||||
$Controller =& new MergeVariablesController();
|
||||
$Controller->helpers = array('Custom', 'Foo' => array('something'));
|
||||
$Controller->constructClasses();
|
||||
|
||||
$expected = array(
|
||||
'MergeVar' => array('format' => 'html', 'terse'),
|
||||
'Custom' => null,
|
||||
'Foo' => array('something')
|
||||
);
|
||||
$this->assertSame($Controller->helpers, $expected, 'Order is incorrect.');
|
||||
}
|
||||
|
||||
/**
|
||||
* test merging of vars with plugin
|
||||
*
|
||||
|
@ -201,13 +224,13 @@ class ControllerMergeVarsTest extends CakeTestCase {
|
|||
'Auth' => array('setting' => 'val', 'otherVal'),
|
||||
'Email' => array('ports' => 'open')
|
||||
);
|
||||
$this->assertEqual($Controller->components, $expected, 'Components are unexpected %s');
|
||||
$this->assertEquals($expected, $Controller->components, 'Components are unexpected.');
|
||||
|
||||
$expected = array(
|
||||
'Javascript',
|
||||
'MergeVar' => array('format' => 'html', 'terse')
|
||||
'MergeVar' => array('format' => 'html', 'terse'),
|
||||
'Javascript' => null
|
||||
);
|
||||
$this->assertEqual($Controller->helpers, $expected, 'Helpers are unexpected %s');
|
||||
$this->assertEquals($expected, $Controller->helpers, 'Helpers are unexpected.');
|
||||
|
||||
$Controller = new MergePostsController();
|
||||
$Controller->components = array();
|
||||
|
@ -218,7 +241,7 @@ class ControllerMergeVarsTest extends CakeTestCase {
|
|||
'MergeVar' => array('flag', 'otherFlag', 'redirect' => false),
|
||||
'Auth' => array('setting' => 'val', 'otherVal'),
|
||||
);
|
||||
$this->assertEqual($Controller->components, $expected, 'Components are unexpected %s');
|
||||
$this->assertEquals($expected, $Controller->components, 'Components are unexpected.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -367,6 +367,7 @@ class FolderTest extends CakeTestCase {
|
|||
$this->assertFalse(Folder::isWindowsPath('0:\\cake\\is\\awesome'));
|
||||
$this->assertTrue(Folder::isWindowsPath('C:\\cake\\is\\awesome'));
|
||||
$this->assertTrue(Folder::isWindowsPath('d:\\cake\\is\\awesome'));
|
||||
$this->assertTrue(Folder::isWindowsPath('\\\\vmware-host\\Shared Folders\\file'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -388,6 +389,7 @@ class FolderTest extends CakeTestCase {
|
|||
$this->assertTrue(Folder::isAbsolute('C:\\cake'));
|
||||
$this->assertTrue(Folder::isAbsolute('C:\\path\\to\\file'));
|
||||
$this->assertTrue(Folder::isAbsolute('d:\\path\\to\\file'));
|
||||
$this->assertTrue(Folder::isAbsolute('\\\\vmware-host\\Shared Folders\\file'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
* @since CakePHP(tm) v 1.2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||
}
|
||||
|
||||
require_once LIBS.'model'.DS.'model.php';
|
||||
require_once LIBS.'model'.DS.'datasources'.DS.'datasource.php';
|
||||
require_once LIBS.'model'.DS.'datasources'.DS.'dbo_source.php';
|
||||
|
|
|
@ -728,9 +728,10 @@ class DboMysqlTest extends CakeTestCase {
|
|||
$model->virtualFields = array(
|
||||
'other__field' => 'SUM(id)'
|
||||
);
|
||||
|
||||
|
||||
$this->Dbo->virtualFieldSeparator = '_$_';
|
||||
$result = $this->Dbo->fields($model, null, array('data', 'other__field'));
|
||||
|
||||
$expected = array('`BinaryTest`.`data`', '(SUM(id)) AS `BinaryTest_$_other__field`');
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
* @since CakePHP(tm) v 1.2.0
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||
}
|
||||
|
||||
require_once LIBS . 'model' . DS . 'datasources' . DS . 'dbo_source.php';
|
||||
require_once LIBS . 'model' . DS . 'datasources' . DS . 'dbo' . DS . 'dbo_oracle.php';
|
||||
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
* @since CakePHP(tm) v 1.2.0.4206
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||
}
|
||||
|
||||
App::import('Model', array('Model', 'DataSource', 'DboSource', 'DboMysql', 'App'));
|
||||
require_once dirname(dirname(__FILE__)) . DS . 'models.php';
|
||||
|
||||
|
|
|
@ -1309,12 +1309,12 @@ class ModelIntegrationTest extends BaseModelTest {
|
|||
$this->loadFixtures('Post');
|
||||
|
||||
$TestModel = ClassRegistry::init('MergeVarPluginPost');
|
||||
$this->assertEqual($TestModel->actsAs, array('Containable', 'Tree'));
|
||||
$this->assertEqual($TestModel->actsAs, array('Containable' => null, 'Tree' => null));
|
||||
$this->assertTrue(isset($TestModel->Behaviors->Containable));
|
||||
$this->assertTrue(isset($TestModel->Behaviors->Tree));
|
||||
|
||||
$TestModel = ClassRegistry::init('MergeVarPluginComment');
|
||||
$expected = array('Containable', 'Containable' => array('some_settings'));
|
||||
$expected = array('Containable' => array('some_settings'));
|
||||
$this->assertEqual($TestModel->actsAs, $expected);
|
||||
$this->assertTrue(isset($TestModel->Behaviors->Containable));
|
||||
}
|
||||
|
|
|
@ -3061,6 +3061,22 @@ class ModelWriteTest extends BaseModelTest {
|
|||
$Post->saveAll($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* test saveAll with nested saveAll call.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testSaveAllNestedSaveAll() {
|
||||
$this->loadFixtures('Sample');
|
||||
$TransactionTestModel =& new TransactionTestModel();
|
||||
|
||||
$data = array(
|
||||
array('apple_id' => 1, 'name' => 'sample5'),
|
||||
);
|
||||
|
||||
$this->assertTrue($TransactionTestModel->saveAll($data, array('atomic' => true)));
|
||||
}
|
||||
|
||||
/**
|
||||
* testSaveAllTransaction method
|
||||
*
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
* @since CakePHP(tm) v 1.2.0.6464
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||
}
|
||||
|
||||
PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT');
|
||||
|
||||
|
@ -292,7 +289,7 @@ class Article extends CakeTestModel {
|
|||
*/
|
||||
class BeforeDeleteComment extends CakeTestModel {
|
||||
var $name = 'BeforeDeleteComment';
|
||||
|
||||
|
||||
var $useTable = 'comments';
|
||||
|
||||
function beforeDelete($cascade = true) {
|
||||
|
@ -3559,6 +3556,7 @@ class FruitNoWith extends CakeTestModel {
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
class UuidTagNoWith extends CakeTestModel {
|
||||
public $name = 'UuidTag';
|
||||
public $useTable = 'uuid_tags';
|
||||
|
@ -3581,7 +3579,18 @@ class ProductUpdateAll extends CakeTestModel {
|
|||
class GroupUpdateAll extends CakeTestModel {
|
||||
public $name = 'GroupUpdateAll';
|
||||
public $useTable = 'group_update_all';
|
||||
}
|
||||
|
||||
class TransactionTestModel extends CakeTestModel {
|
||||
var $name = 'TransactionTestModel';
|
||||
var $useTable = 'samples';
|
||||
|
||||
function afterSave($created) {
|
||||
$data = array(
|
||||
array('apple_id' => 1, 'name' => 'sample6'),
|
||||
);
|
||||
$this->saveAll($data, array('atomic' => true, 'callbacks' => false));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4888,4 +4897,4 @@ class MysqlTestModel extends Model {
|
|||
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ class RouterTest extends CakeTestCase {
|
|||
}
|
||||
$this->assertPattern('/^http(s)?:\/\//', Router::url('/', true));
|
||||
$this->assertPattern('/^http(s)?:\/\//', Router::url(null, true));
|
||||
$this->assertPattern('/^http(s)?:\/\//', Router::url(array('full_base' => true)));
|
||||
$this->assertIdentical(FULL_BASE_URL . '/', Router::url(array('full_base' => true)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1707,8 +1709,8 @@ class RouterTest extends CakeTestCase {
|
|||
function testParsingWithPatternOnAction() {
|
||||
Router::reload();
|
||||
Router::connect(
|
||||
'/blog/:action/*',
|
||||
array('controller' => 'blog_posts'),
|
||||
'/blog/:action/*',
|
||||
array('controller' => 'blog_posts'),
|
||||
array('action' => 'other|actions')
|
||||
);
|
||||
$result = Router::parse('/blog/other');
|
||||
|
@ -1730,7 +1732,7 @@ class RouterTest extends CakeTestCase {
|
|||
'named' => array()
|
||||
);
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
|
||||
$result = Router::url(array('controller' => 'blog_posts', 'action' => 'foo'));
|
||||
$this->assertEqual('/blog_posts/foo', $result);
|
||||
|
||||
|
@ -2265,6 +2267,31 @@ class RouterTest extends CakeTestCase {
|
|||
$this->assertEqual($url, Router::url($url));
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing that patterns on the :action param work properly.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testPatternOnAction() {
|
||||
$route =& new CakeRoute(
|
||||
'/blog/:action/*',
|
||||
array('controller' => 'blog_posts'),
|
||||
array('action' => 'other|actions')
|
||||
);
|
||||
$result = $route->match(array('controller' => 'blog_posts', 'action' => 'foo'));
|
||||
$this->assertFalse($result);
|
||||
|
||||
$result = $route->match(array('controller' => 'blog_posts', 'action' => 'actions'));
|
||||
$this->assertEquals('/blog/actions/', $result);
|
||||
|
||||
$result = $route->parse('/blog/other');
|
||||
$expected = array('controller' => 'blog_posts', 'action' => 'other', 'pass' => array(), 'named' => array());
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = $route->parse('/blog/foobar');
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test setting redirect routes
|
||||
*
|
||||
|
|
|
@ -2990,4 +2990,50 @@ class SetTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* test normalization
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testNormalizeStrings() {
|
||||
$result = Set::normalize('one,two,three');
|
||||
$expected = array('one' => null, 'two' => null, 'three' => null);
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = Set::normalize('one two three', true, ' ');
|
||||
$expected = array('one' => null, 'two' => null, 'three' => null);
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = Set::normalize('one , two , three ', true, ',', true);
|
||||
$expected = array('one' => null, 'two' => null, 'three' => null);
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test normalizing arrays
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testNormalizeArrays() {
|
||||
$result = Set::normalize(array('one', 'two', 'three'));
|
||||
$expected = array('one' => null, 'two' => null, 'three' => null);
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = Set::normalize(array('one', 'two', 'three'), false);
|
||||
$expected = array('one', 'two', 'three');
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = Set::normalize(array('one' => 1, 'two' => 2, 'three' => 3, 'four'), false);
|
||||
$expected = array('one' => 1, 'two' => 2, 'three' => 3, 'four' => null);
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = Set::normalize(array('one' => 1, 'two' => 2, 'three' => 3, 'four'));
|
||||
$expected = array('one' => 1, 'two' => 2, 'three' => 3, 'four' => null);
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = Set::normalize(array('one' => array('a', 'b', 'c' => 'cee'), 'two' => 2, 'three'));
|
||||
$expected = array('one' => array('a', 'b', 'c' => 'cee'), 'two' => 2, 'three' => null);
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5679,6 +5679,31 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that create() doesn't cause errors by multiple id's being in the primary key
|
||||
* as could happen with multiple select or checkboxes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testCreateWithMultipleIdInData() {
|
||||
$encoding = strtolower(Configure::read('App.encoding'));
|
||||
|
||||
$this->Form->request->data['Contact']['id'] = array(1, 2);
|
||||
$result = $this->Form->create('Contact');
|
||||
$expected = array(
|
||||
'form' => array(
|
||||
'id' => 'ContactAddForm',
|
||||
'method' => 'post',
|
||||
'action' => '/contacts/add',
|
||||
'accept-charset' => $encoding
|
||||
),
|
||||
'div' => array('style' => 'display:none;'),
|
||||
'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that create() doesn't add in extra passed params.
|
||||
*
|
||||
|
|
|
@ -90,6 +90,8 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
$this->Html = new HtmlHelper($this->View);
|
||||
$this->Html->request = new CakeRequest(null, false);
|
||||
$this->Html->request->webroot = '';
|
||||
|
||||
Configure::write('Asset.timestamp', false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -262,7 +264,6 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
*/
|
||||
function testImageTag() {
|
||||
$this->Html->request->webroot = '';
|
||||
Configure::write('Asset.timestamp', false);
|
||||
|
||||
$result = $this->Html->image('test.gif');
|
||||
$this->assertTags($result, array('img' => array('src' => 'img/test.gif', 'alt' => '')));
|
||||
|
@ -354,7 +355,6 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testThemeAssetsInMainWebrootPath() {
|
||||
Configure::write('Asset.timestamp', false);
|
||||
App::build(array(
|
||||
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
|
||||
));
|
||||
|
@ -402,7 +402,6 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testCssLink() {
|
||||
Configure::write('Asset.timestamp', false);
|
||||
Configure::write('Asset.filter.css', false);
|
||||
|
||||
$result = $this->Html->css('screen');
|
||||
|
@ -528,7 +527,6 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testScript() {
|
||||
Configure::write('Asset.timestamp', false);
|
||||
$result = $this->Html->script('foo');
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript', 'src' => 'js/foo.js')
|
||||
|
|
|
@ -237,7 +237,7 @@ class NumberHelperTest extends CakeTestCase {
|
|||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = $this->Number->currency($value, 'EUR');
|
||||
$expected = '99c';
|
||||
$expected = '€0,99';
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = $this->Number->currency($value, 'GBP');
|
||||
|
@ -259,7 +259,7 @@ class NumberHelperTest extends CakeTestCase {
|
|||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = $this->Number->currency($value, 'EUR');
|
||||
$expected = '(99c)';
|
||||
$expected = '(€0,99)';
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = $this->Number->currency($value, 'GBP');
|
||||
|
@ -271,7 +271,7 @@ class NumberHelperTest extends CakeTestCase {
|
|||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = $this->Number->currency($value, 'EUR', array('negative'=>'-'));
|
||||
$expected = '-99c';
|
||||
$expected = '-€0,99';
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = $this->Number->currency($value, 'GBP', array('negative'=>'-'));
|
||||
|
@ -337,6 +337,10 @@ class NumberHelperTest extends CakeTestCase {
|
|||
$result = $this->Number->currency('0.35', 'GBP');
|
||||
$expected = '35p';
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = $this->Number->currency('0.35', 'EUR');
|
||||
$expected = '€0,35';
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
App::import('Core', 'View');
|
||||
App::import('Helper', array('Html', 'Paginator', 'Form', 'Js'));
|
||||
|
||||
if (!defined('FULL_BASE_URL')) {
|
||||
define('FULL_BASE_URL', 'http://cakephp.org');
|
||||
}
|
||||
|
||||
/**
|
||||
* PaginatorHelperTest class
|
||||
*
|
||||
|
@ -1777,6 +1781,15 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
'/span',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Paginator->options(array('url' => array('full_base' => true)));
|
||||
$result = $this->Paginator->first();
|
||||
$expected = array(
|
||||
'<span',
|
||||
array('a' => array('href' => FULL_BASE_URL . '/index/page:1/sort:Client.name/direction:DESC')), '<< first', '/a',
|
||||
'/span',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,13 +19,6 @@
|
|||
*/
|
||||
App::import('Core', array('Media', 'Controller', 'CakeResponse'));
|
||||
|
||||
if (!class_exists('ErrorHandler')) {
|
||||
App::import('Core', array('Error'));
|
||||
}
|
||||
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* MediaViewTest class
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue