Merge branch '2.2' into 2.2-validator

Conflicts:
	lib/Cake/Model/Model.php
	lib/Cake/Test/Case/Model/ModelValidationTest.php
	lib/Cake/Test/Case/Model/ModelWriteTest.php
This commit is contained in:
Jose Lorenzo Rodriguez 2012-05-10 22:19:35 -04:30
commit 307197da9e
337 changed files with 2702 additions and 1133 deletions

View file

@ -1,6 +1,4 @@
<?php
/*DbAcl schema generated on: 2007-11-24 15:11:13 : 1195945453*/
/**
* This is Acl Schema file
*
@ -39,36 +37,36 @@ class DbAclSchema extends CakeSchema {
}
public $acos = array(
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'parent_id' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'model' => array('type'=>'string', 'null' => true),
'foreign_key' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'alias' => array('type'=>'string', 'null' => true),
'lft' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'rght' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
);
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'),
'parent_id' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10),
'model' => array('type' => 'string', 'null' => true),
'foreign_key' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10),
'alias' => array('type' => 'string', 'null' => true),
'lft' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10),
'rght' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
);
public $aros = array(
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'parent_id' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'model' => array('type'=>'string', 'null' => true),
'foreign_key' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'alias' => array('type'=>'string', 'null' => true),
'lft' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'rght' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
);
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'),
'parent_id' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10),
'model' => array('type' => 'string', 'null' => true),
'foreign_key' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10),
'alias' => array('type' => 'string', 'null' => true),
'lft' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10),
'rght' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
);
public $aros_acos = array(
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'aro_id' => array('type'=>'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
'aco_id' => array('type'=>'integer', 'null' => false, 'length' => 10),
'_create' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
'_read' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
'_update' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
'_delete' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'ARO_ACO_KEY' => array('column' => array('aro_id', 'aco_id'), 'unique' => 1))
);
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'),
'aro_id' => array('type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
'aco_id' => array('type' => 'integer', 'null' => false, 'length' => 10),
'_create' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2),
'_read' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2),
'_update' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2),
'_delete' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'ARO_ACO_KEY' => array('column' => array('aro_id', 'aco_id'), 'unique' => 1))
);
}

View file

@ -1,6 +1,4 @@
<?php
/*i18n schema generated on: 2007-11-25 07:11:25 : 1196004805*/
/**
* This is i18n Schema file
*
@ -39,13 +37,13 @@ class i18nSchema extends CakeSchema {
}
public $i18n = array(
'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'locale' => array('type'=>'string', 'null' => false, 'length' => 6, 'key' => 'index'),
'model' => array('type'=>'string', 'null' => false, 'key' => 'index'),
'foreign_key' => array('type'=>'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
'field' => array('type'=>'string', 'null' => false, 'key' => 'index'),
'content' => array('type'=>'text', 'null' => true, 'default' => NULL),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'locale' => array('column' => 'locale', 'unique' => 0), 'model' => array('column' => 'model', 'unique' => 0), 'row_id' => array('column' => 'foreign_key', 'unique' => 0), 'field' => array('column' => 'field', 'unique' => 0))
);
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'),
'locale' => array('type' => 'string', 'null' => false, 'length' => 6, 'key' => 'index'),
'model' => array('type' => 'string', 'null' => false, 'key' => 'index'),
'foreign_key' => array('type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
'field' => array('type' => 'string', 'null' => false, 'key' => 'index'),
'content' => array('type' => 'text', 'null' => true, 'default' => null),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'locale' => array('column' => 'locale', 'unique' => 0), 'model' => array('column' => 'model', 'unique' => 0), 'row_id' => array('column' => 'foreign_key', 'unique' => 0), 'field' => array('column' => 'field', 'unique' => 0))
);
}

View file

@ -1,6 +1,4 @@
<?php
/*Sessions schema generated on: 2007-11-25 07:11:54 : 1196004714*/
/**
* This is Sessions Schema file
*
@ -39,10 +37,10 @@ class SessionsSchema extends CakeSchema {
}
public $cake_sessions = array(
'id' => array('type'=>'string', 'null' => false, 'key' => 'primary'),
'data' => array('type'=>'text', 'null' => true, 'default' => NULL),
'expires' => array('type'=>'integer', 'null' => true, 'default' => NULL),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
);
'id' => array('type' => 'string', 'null' => false, 'key' => 'primary'),
'data' => array('type' => 'text', 'null' => true, 'default' => null),
'expires' => array('type' => 'integer', 'null' => true, 'default' => null),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
);
}

View file

@ -22,10 +22,10 @@ $dispatcher = 'Cake' . $ds . 'Console' . $ds . 'ShellDispatcher.php';
if (function_exists('ini_set')) {
$root = dirname(dirname(dirname(__FILE__)));
ini_set('include_path', $root . $ds. 'lib' . PATH_SEPARATOR . ini_get('include_path'));
ini_set('include_path', $root . $ds . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
}
if (!include($dispatcher)) {
if (!include ($dispatcher)) {
trigger_error('Could not locate CakePHP core files.', E_USER_ERROR);
}
unset($paths, $path, $dispatcher, $root, $ds);

View file

@ -38,7 +38,6 @@ class PagesController extends AppController {
*/
public $name = 'Pages';
/**
* This controller does not use a model
*

View file

@ -21,9 +21,9 @@
/**
* Use the DS to separate the directories in other defines
*/
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
/**
* These defines should only be edited if you have cake installed in
* a directory layout other than the way it is distributed.
@ -34,16 +34,16 @@
* The full path to the directory which holds "app", WITHOUT a trailing DS.
*
*/
if (!defined('ROOT')) {
define('ROOT', dirname(dirname(dirname(__FILE__))));
}
if (!defined('ROOT')) {
define('ROOT', dirname(dirname(dirname(__FILE__))));
}
/**
* The actual directory name for the "app".
*
*/
if (!defined('APP_DIR')) {
define('APP_DIR', basename(dirname(dirname(__FILE__))));
}
if (!defined('APP_DIR')) {
define('APP_DIR', basename(dirname(dirname(__FILE__))));
}
/**
* The absolute path to the "cake" directory, WITHOUT a trailing DS.
@ -63,30 +63,30 @@
* Change at your own risk.
*
*/
if (!defined('WEBROOT_DIR')) {
define('WEBROOT_DIR', basename(dirname(__FILE__)));
}
if (!defined('WWW_ROOT')) {
define('WWW_ROOT', dirname(__FILE__) . DS);
}
if (!defined('WEBROOT_DIR')) {
define('WEBROOT_DIR', basename(dirname(__FILE__)));
}
if (!defined('WWW_ROOT')) {
define('WWW_ROOT', dirname(__FILE__) . DS);
}
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
if (function_exists('ini_set')) {
ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
}
if (!include('Cake' . DS . 'bootstrap.php')) {
$failed = true;
}
} else {
if (!include(CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {
$failed = true;
}
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
if (function_exists('ini_set')) {
ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
}
if (!empty($failed)) {
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
if (!include ('Cake' . DS . 'bootstrap.php')) {
$failed = true;
}
} else {
if (!include (CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {
$failed = true;
}
}
if (!empty($failed)) {
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
}
App::uses('Dispatcher', 'Routing');
App::uses('Dispatcher', 'Routing');
$Dispatcher = new Dispatcher();
$Dispatcher->dispatch(new CakeRequest(), new CakeResponse(array('charset' => Configure::read('App.encoding'))));
$Dispatcher = new Dispatcher();
$Dispatcher->dispatch(new CakeRequest(), new CakeResponse(array('charset' => Configure::read('App.encoding'))));

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing
* @link http://book.cakephp.org/2.0/en/development/testing.html
* @package app.webroot
* @since CakePHP(tm) v 1.2.0.4433
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
@ -21,9 +21,9 @@ ini_set('display_errors', 1);
/**
* Use the DS to separate the directories in other defines
*/
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
/**
* These defines should only be edited if you have cake installed in
* a directory layout other than the way it is distributed.
@ -34,16 +34,16 @@ ini_set('display_errors', 1);
* The full path to the directory which holds "app", WITHOUT a trailing DS.
*
*/
if (!defined('ROOT')) {
define('ROOT', dirname(dirname(dirname(__FILE__))));
}
if (!defined('ROOT')) {
define('ROOT', dirname(dirname(dirname(__FILE__))));
}
/**
* The actual directory name for the "app".
*
*/
if (!defined('APP_DIR')) {
define('APP_DIR', basename(dirname(dirname(__FILE__))));
}
if (!defined('APP_DIR')) {
define('APP_DIR', basename(dirname(dirname(__FILE__))));
}
/**
* The absolute path to the "Cake" directory, WITHOUT a trailing DS.
@ -71,11 +71,11 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
if (function_exists('ini_set')) {
ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
}
if (!include('Cake' . DS . 'bootstrap.php')) {
if (!include ('Cake' . DS . 'bootstrap.php')) {
$failed = true;
}
} else {
if (!include(CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {
if (!include (CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {
$failed = true;
}
}

View file

@ -20,21 +20,23 @@
* @since CakePHP(tm) v 0.2.9
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
/**
* Get Cake's root directory
*/
define('APP_DIR', 'app');
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__));
define('WEBROOT_DIR', 'webroot');
define('WWW_ROOT', ROOT . DS . APP_DIR . DS . WEBROOT_DIR . DS);
define('APP_DIR', 'app');
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__));
define('WEBROOT_DIR', 'webroot');
define('WWW_ROOT', ROOT . DS . APP_DIR . DS . WEBROOT_DIR . DS);
/**
* This only needs to be changed if the "cake" directory is located
* outside of the distributed structure.
* Full path to the directory containing "cake". Do not add trailing directory separator
*/
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
}
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
}
require APP_DIR . DS . WEBROOT_DIR . DS . 'index.php';
require APP_DIR . DS . WEBROOT_DIR . DS . 'index.php';

View file

@ -16,13 +16,15 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('Hash', 'Utility');
/**
* Ini file configuration parser. Since IniReader uses parse_ini_file underneath,
* you should be aware that this class shares the same behavior, especially with
* regards to boolean and null values.
* Ini file configuration engine.
*
* In addition to the native parse_ini_file features, IniReader also allows you
* Since IniReader uses parse_ini_file underneath, you should be aware that this
* class shares the same behavior, especially with regards to boolean and null values.
*
* In addition to the native `parse_ini_file` features, IniReader also allows you
* to create nested array structures through usage of `.` delimited names. This allows
* you to create nested arrays structures in an ini config file. For example:
*
@ -126,6 +128,7 @@ class IniReader implements ConfigReaderInterface {
if ($value === '') {
$value = false;
}
unset($values[$key]);
if (strpos($key, '.') !== false) {
$values = Hash::insert($values, $key, $value);
} else {
@ -135,4 +138,47 @@ class IniReader implements ConfigReaderInterface {
return $values;
}
/**
* Dumps the state of Configure data into an ini formatted string.
*
* @param string $filename The filename on $this->_path to save into.
* @param array $data The data to convert to ini file.
* @return int Bytes saved.
*/
public function dump($filename, $data) {
$result = array();
foreach ($data as $key => $value) {
if ($key[0] != '[') {
$result[] = "[$key]";
}
if (is_array($value)) {
$keyValues = Hash::flatten($value, '.');
foreach ($keyValues as $k => $v) {
$result[] = "$k = " . $this->_value($v);
}
}
}
$contents = join("\n", $result);
return file_put_contents($this->_path . $filename, $contents);
}
/**
* Converts a value into the ini equivalent
*
* @param mixed $value to export.
* @return string String value for ini file.
*/
protected function _value($val) {
if ($val === null) {
return 'null';
}
if ($val === true) {
return 'true';
}
if ($val === false) {
return 'false';
}
return (string)$val;
}
}

View file

@ -4,7 +4,6 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
@ -88,4 +87,17 @@ class PhpReader implements ConfigReaderInterface {
return $config;
}
/**
* Converts the provided $data into a string of PHP code that can
* be used saved into a file and loaded later.
*
* @param string $filename The filename to create on $this->_path.
* @param array $data Data to dump.
* @return int Bytes saved.
*/
public function dump($filename, $data) {
$contents = '<?php' . "\n" . '$config = ' . var_export($data, true) . ';';
return file_put_contents($this->_path . $filename, $contents);
}
}

View file

@ -362,6 +362,9 @@ class FixtureTask extends BakeTask {
$values = array();
foreach ($record as $field => $value) {
$val = var_export($value, true);
if ($val === 'NULL') {
$val = 'null';
}
$values[] = "\t\t\t'$field' => $val";
}
$out .= "\t\tarray(\n";

View file

@ -70,12 +70,6 @@ class ProjectTask extends AppShell {
$success = true;
if ($this->bake($project)) {
$path = Folder::slashTerm($project);
if ($this->createHome($path)) {
$this->out(__d('cake_console', ' * Welcome page created'));
} else {
$this->err(__d('cake_console', 'The Welcome page was <error>NOT</error> created'));
$success = false;
}
if ($this->securitySalt($path) === true) {
$this->out(__d('cake_console', ' * Random hash key created for \'Security.salt\''));
@ -220,20 +214,6 @@ class ProjectTask extends AppShell {
}
}
/**
* Writes a file with a default home page to the project.
*
* @param string $dir Path to project
* @return boolean Success
*/
public function createHome($dir) {
$app = basename($dir);
$path = $dir . 'View' . DS . 'Pages' . DS;
$source = CAKE . 'Console' . DS . 'Templates' . DS . 'default' . DS . 'views' . DS . 'home.ctp';
include $source;
return $this->createFile($path . 'home.ctp', $output);
}
/**
* Generates the correct path to the CakePHP libs that are generating the project
* and points app/console/cake.php to the right place

View file

@ -55,11 +55,18 @@ class TemplateTask extends AppShell {
* Find the paths to all the installed shell themes in the app.
*
* Bake themes are directories not named `skel` inside a `Console/Templates` path.
*
* They are listed in this order: app -> plugin -> default
*
* @return array Array of bake themes that are installed.
*/
protected function _findThemes() {
$paths = array();
$paths = App::path('Console');
$plugins = App::objects('plugin');
foreach ($plugins as $plugin) {
$paths[] = $this->_pluginPath($plugin) . 'Console' . DS;
}
$core = current(App::core('Console'));
$separator = DS === '/' ? '/' : '\\\\';
$core = preg_replace('#shells' . $separator . '$#', '', $core);
@ -69,13 +76,7 @@ class TemplateTask extends AppShell {
$contents = $Folder->read();
$themeFolders = $contents[0];
$plugins = App::objects('plugin');
$paths[] = $core;
foreach ($plugins as $plugin) {
$paths[] = $this->_pluginPath($plugin) . 'Console' . DS;
}
$paths = array_merge($paths, App::path('Console'));
// TEMPORARY TODO remove when all paths are DS terminated
foreach ($paths as $i => $path) {

View file

@ -77,7 +77,7 @@ class TestTask extends BakeTask {
}
if (count($this->args) > 1) {
$type = Inflector::underscore($this->args[0]);
$type = Inflector::classify($this->args[0]);
if ($this->bake($type, $this->args[1])) {
$this->out('<success>Done</success>');
}
@ -139,7 +139,7 @@ class TestTask extends BakeTask {
$methods = $this->getTestableMethods($fullClassName);
}
$mock = $this->hasMockClass($type, $fullClassName);
list($preConstruct, $construction, $postConstruct) = $this->generateConstructor($type, $fullClassName);
list($preConstruct, $construction, $postConstruct) = $this->generateConstructor($type, $fullClassName, $plugin);
$uses = $this->generateUses($type, $realType, $fullClassName);
$this->out("\n" . __d('cake_console', 'Baking test case for %s %s ...', $className, $type), 1, Shell::QUIET);
@ -241,6 +241,12 @@ class TestTask extends BakeTask {
*/
public function isLoadableClass($package, $class) {
App::uses($class, $package);
list($plugin, $ns) = pluginSplit($package);
if ($plugin) {
App::uses("{$plugin}AppController", $package);
App::uses("{$plugin}AppModel", $package);
App::uses("{$plugin}AppHelper", $package);
}
return class_exists($class);
}
@ -440,13 +446,14 @@ class TestTask extends BakeTask {
*
* @param string $type The Type of object you are generating tests for eg. controller
* @param string $fullClassName The Classname of the class the test is being generated for.
* @param string $plugin The plugin name.
* @return array Constructor snippets for the thing you are building.
*/
public function generateConstructor($type, $fullClassName) {
public function generateConstructor($type, $fullClassName, $plugin) {
$type = strtolower($type);
$pre = $post = '';
if ($type == 'model') {
$construct = "ClassRegistry::init('$fullClassName');\n";
$construct = "ClassRegistry::init('{$plugin}$fullClassName');\n";
}
if ($type == 'behavior') {
$construct = "new $fullClassName();\n";

View file

@ -6,14 +6,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html
* @since CakePHP(tm) v 1.2.0.4433
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

View file

@ -6,14 +6,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html
* @since CakePHP(tm) v 1.2.0.4433
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

View file

@ -160,9 +160,11 @@ class ShellDispatcher {
$errorHandler = new ConsoleErrorHandler();
if (empty($error['consoleHandler'])) {
$error['consoleHandler'] = array($errorHandler, 'handleError');
Configure::write('error', $error);
}
if (empty($exception['consoleHandler'])) {
$exception['consoleHandler'] = array($errorHandler, 'handleException');
Configure::write('exception', $exception);
}
set_exception_handler($exception['consoleHandler']);
set_error_handler($error['consoleHandler'], Configure::read('Error.level'));

View file

@ -31,6 +31,7 @@
/**
* <?php echo $admin ?>view method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
@ -85,6 +86,7 @@
/**
* <?php echo $admin ?>edit method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
@ -129,6 +131,8 @@
/**
* <?php echo $admin ?>delete method
*
* @throws MethodNotAllowedException
* @throws NotFoundException
* @param string $id
* @return void
*/
@ -154,4 +158,4 @@
$this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted'), array('action' => 'index'));
<?php endif; ?>
$this->redirect(array('action' => 'index'));
}
}

View file

@ -46,36 +46,36 @@ class <?php echo $controllerName; ?>Controller extends <?php echo $plugin; ?>App
* @var mixed
*/
public $scaffold;
<?php else: ?>
<?php
if (count($helpers)):
echo "/**\n * Helpers\n *\n * @var array\n */\n";
echo "\tpublic \$helpers = array(";
for ($i = 0, $len = count($helpers); $i < $len; $i++):
if ($i != $len - 1):
echo "'" . Inflector::camelize($helpers[$i]) . "', ";
else:
echo "'" . Inflector::camelize($helpers[$i]) . "'";
endif;
endfor;
echo ");\n";
endif;
if (count($components)):
echo "/**\n * Components\n *\n * @var array\n */\n";
echo "\tpublic \$components = array(";
for ($i = 0, $len = count($components); $i < $len; $i++):
if ($i != $len - 1):
echo "'" . Inflector::camelize($components[$i]) . "', ";
else:
echo "'" . Inflector::camelize($components[$i]) . "'";
endif;
endfor;
echo ");\n";
endif;
<?php else:
echo $actions;
if (count($helpers)):
echo "/**\n * Helpers\n *\n * @var array\n */\n";
echo "\tpublic \$helpers = array(";
for ($i = 0, $len = count($helpers); $i < $len; $i++):
if ($i != $len - 1):
echo "'" . Inflector::camelize($helpers[$i]) . "', ";
else:
echo "'" . Inflector::camelize($helpers[$i]) . "'";
endif;
endfor;
echo ");\n\n";
endif;
if (count($components)):
echo "/**\n * Components\n *\n * @var array\n */\n";
echo "\tpublic \$components = array(";
for ($i = 0, $len = count($components); $i < $len; $i++):
if ($i != $len - 1):
echo "'" . Inflector::camelize($components[$i]) . "', ";
else:
echo "'" . Inflector::camelize($components[$i]) . "'";
endif;
endfor;
echo ");\n\n";
endif;
echo trim($actions) . "\n";
endif; ?>
}

View file

@ -25,6 +25,7 @@
*
*/
class <?php echo $model; ?>Fixture extends CakeTestFixture {
<?php if ($table): ?>
/**
* Table name
@ -32,6 +33,7 @@ class <?php echo $model; ?>Fixture extends CakeTestFixture {
* @var string
*/
public $table = '<?php echo $table; ?>';
<?php endif; ?>
<?php if ($import): ?>
/**
@ -40,8 +42,8 @@ class <?php echo $model; ?>Fixture extends CakeTestFixture {
* @var array
*/
public $import = <?php echo $import; ?>;
<?php endif; ?>
<?php endif; ?>
<?php if ($schema): ?>
/**
* Fields
@ -49,8 +51,8 @@ class <?php echo $model; ?>Fixture extends CakeTestFixture {
* @var array
*/
public $fields = <?php echo $schema; ?>;
<?php endif;?>
<?php endif;?>
<?php if ($records): ?>
/**
* Records
@ -58,5 +60,6 @@ class <?php echo $model; ?>Fixture extends CakeTestFixture {
* @var array
*/
public $records = <?php echo $records; ?>;
<?php endif;?>
}

View file

@ -36,6 +36,7 @@ foreach (array('hasOne', 'belongsTo', 'hasMany', 'hasAndBelongsToMany') as $asso
?>
*/
class <?php echo $name ?> extends <?php echo $plugin; ?>AppModel {
<?php if ($useDbConfig != 'default'): ?>
/**
* Use database config
@ -43,12 +44,15 @@ class <?php echo $name ?> extends <?php echo $plugin; ?>AppModel {
* @var string
*/
public $useDbConfig = '<?php echo $useDbConfig; ?>';
<?php endif;?>
<?php if ($useTable && $useTable !== Inflector::tableize($name)):
$table = "'$useTable'";
echo "/**\n * Use table\n *\n * @var mixed False or table name\n */\n";
echo "\tpublic \$useTable = $table;\n";
<?php endif;
if ($useTable && $useTable !== Inflector::tableize($name)):
$table = "'$useTable'";
echo "/**\n * Use table\n *\n * @var mixed False or table name\n */\n";
echo "\tpublic \$useTable = $table;\n\n";
endif;
if ($primaryKey !== 'id'): ?>
/**
* Primary key field
@ -56,7 +60,9 @@ if ($primaryKey !== 'id'): ?>
* @var string
*/
public $primaryKey = '<?php echo $primaryKey; ?>';
<?php endif;
if ($displayField): ?>
/**
* Display field
@ -64,6 +70,7 @@ if ($displayField): ?>
* @var string
*/
public $displayField = '<?php echo $displayField; ?>';
<?php endif;
if (!empty($validate)):

View file

@ -23,12 +23,13 @@ echo "<?php\n";
App::uses('<?php echo $dependency[0]; ?>', '<?php echo $dependency[1]; ?>');
<?php endforeach; ?>
<?php if ($mock and strtolower($type) == 'controller'): ?>
<?php if ($mock && strtolower($type) === 'controller'): ?>
/**
* Test<?php echo $fullClassName; ?>
*
*/
class Test<?php echo $fullClassName; ?> extends <?php echo $fullClassName; ?> {
/**
* Auto render
*
@ -47,6 +48,7 @@ class Test<?php echo $fullClassName; ?> extends <?php echo $fullClassName; ?> {
public function redirect($url, $status = null, $exit = true) {
$this->redirectUrl = $url;
}
}
<?php endif; ?>
@ -55,13 +57,16 @@ class Test<?php echo $fullClassName; ?> extends <?php echo $fullClassName; ?> {
*
*/
class <?php echo $fullClassName; ?>Test extends CakeTestCase {
<?php if (!empty($fixtures)): ?>
/**
* Fixtures
*
* @var array
*/
public $fixtures = array('<?php echo join("', '", $fixtures); ?>');
public $fixtures = array(
'<?php echo join("',\n\t\t'", $fixtures); ?>'
);
<?php endif; ?>
/**
@ -94,7 +99,7 @@ class <?php echo $fullClassName; ?>Test extends CakeTestCase {
* @return void
*/
public function test<?php echo Inflector::camelize($method); ?>() {
}
<?php endforeach;?>
}

View file

@ -1,113 +0,0 @@
<?php
$output = "
<iframe src=\"http://cakephp.org/bake-banner\" width=\"830\" height=\"160\" style=\"overflow:hidden; border:none;\">
<p>For updates and important announcements, visit http://cakefest.org</p>
</iframe>\n";
$output .= "<h2>Sweet, \"" . Inflector::humanize($app) . "\" got Baked by CakePHP!</h2>\n";
$output .="
<?php
App::uses('Debugger', 'Utility');
if (Configure::read('debug') > 0):
Debugger::checkSecurityKeys();
endif;
?>
<p>
<?php
if (version_compare(PHP_VERSION, '5.2.8', '>=')):
echo '<span class=\"notice success\">';
echo __d('cake_dev', 'Your version of PHP is 5.2.8 or higher.');
echo '</span>';
else:
echo '<span class=\"notice\">';
echo __d('cake_dev', 'Your version of PHP is too low. You need PHP 5.2.8 or higher to use CakePHP.');
echo '</span>';
endif;
?>
</p>
<p>
<?php
if (is_writable(TMP)):
echo '<span class=\"notice success\">';
echo __d('cake_dev', 'Your tmp directory is writable.');
echo '</span>';
else:
echo '<span class=\"notice\">';
echo __d('cake_dev', 'Your tmp directory is NOT writable.');
echo '</span>';
endif;
?>
</p>
<p>
<?php
\$settings = Cache::settings('_cake_core_');
if (!empty(\$settings)):
echo '<span class=\"notice success\">';
echo __d('cake_dev', 'The %s is being used for core caching. To change the config edit APP/Config/core.php ', '<em>'. \$settings['engine'] . 'Engine</em>');
echo '</span>';
else:
echo '<span class=\"notice\">';
echo __d('cake_dev', 'Your cache is NOT working. Please check the settings in APP/Config/core.php');
echo '</span>';
endif;
?>
</p>
<p>
<?php
\$filePresent = null;
if (file_exists(APP . 'Config' . DS . 'database.php')):
echo '<span class=\"notice success\">';
echo __d('cake_dev', 'Your database configuration file is present.');
\$filePresent = true;
echo '</span>';
else:
echo '<span class=\"notice\">';
echo __d('cake_dev', 'Your database configuration file is NOT present.');
echo '<br/>';
echo __d('cake_dev', 'Rename APP/Config/database.php.default to APP/Config/database.php');
echo '</span>';
endif;
?>
</p>
<?php
if (isset(\$filePresent)):
App::uses('ConnectionManager', 'Model');
try {
\$connected = ConnectionManager::getDataSource('default');
} catch (Exception \$e) {
\$connected = false;
}
?>
<p>
<?php
if (\$connected && \$connected->isConnected()):
echo '<span class=\"notice success\">';
echo __d('cake_dev', 'Cake is able to connect to the database.');
echo '</span>';
else:
echo '<span class=\"notice\">';
echo __d('cake_dev', 'Cake is NOT able to connect to the database.');
echo '</span>';
endif;
?>
</p>
<?php endif;?>
<?php
App::uses('Validation', 'Utility');
if (!Validation::alphaNumeric('cakephp')) {
echo '<p><span class=\"notice\">';
__d('cake_dev', 'PCRE has not been compiled with Unicode support.');
echo '<br/>';
__d('cake_dev', 'Recompile PCRE with Unicode support by adding <code>--enable-unicode-properties</code> when configuring');
echo '</span></p>';
}
?>\n";
$output .= "<h3><?php echo __d('cake_dev', 'Editing this Page'); ?></h3>\n";
$output .= "<p>\n";
$output .= "<?php\n";
$output .= "\techo __d('cake_dev', 'To change the content of this page, edit: %s\n";
$output .= "\t\tTo change its layout, edit: %s\n";
$output .= "\t\tYou can also add some CSS styles for your pages at: %s',\n";
$output .= "\t\tAPP . 'View' . DS . 'Pages' . DS . 'home.ctp.<br />', APP . 'View' . DS . 'Layouts' . DS . 'default.ctp.<br />', APP . 'webroot' . DS . 'css');\n";
$output .= "?>\n";
$output .= "</p>\n";
?>

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing
* @link http://book.cakephp.org/2.0/en/development/testing.html
* @package app.webroot
* @since CakePHP(tm) v 1.2.0.4433
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -35,7 +35,7 @@ App::uses('ComponentCollection', 'Controller');
* - `beforeRedirect()` - Fired before a redirect() is done.
*
* @package Cake.Controller
* @link http://book.cakephp.org/view/993/Components
* @link http://book.cakephp.org/2.0/en/controllers/components.html
* @see Controller::$components
*/
class Component extends Object {

View file

@ -30,6 +30,7 @@ abstract class BaseAuthenticate {
* - `scope` Additional conditions to use when looking up and authenticating users,
* i.e. `array('User.is_active' => 1).`
* - `recursive` The value of the recursive key passed to find(). Defaults to 0.
* - `contain` Extra models to contain and store in session.
*
* @var array
*/
@ -40,7 +41,8 @@ abstract class BaseAuthenticate {
),
'userModel' => 'User',
'scope' => array(),
'recursive' => 0
'recursive' => 0,
'contain' => null,
);
/**
@ -82,13 +84,16 @@ abstract class BaseAuthenticate {
}
$result = ClassRegistry::init($userModel)->find('first', array(
'conditions' => $conditions,
'recursive' => (int)$this->settings['recursive']
'recursive' => (int)$this->settings['recursive'],
'contain' => $this->settings['contain'],
));
if (empty($result) || empty($result[$model])) {
return false;
}
unset($result[$model][$fields['password']]);
return $result[$model];
$user = $result[$model];
unset($user[$fields['password']]);
unset($result[$model]);
return array_merge($user, $result);
}
/**

View file

@ -50,6 +50,7 @@ class BasicAuthenticate extends BaseAuthenticate {
* - `scope` Additional conditions to use when looking up and authenticating users,
* i.e. `array('User.is_active' => 1).`
* - `recursive` The value of the recursive key passed to find(). Defaults to 0.
* - `contain` Extra models to contain and store in session.
* - `realm` The realm authentication is for. Defaults the server name.
*
* @var array
@ -62,6 +63,7 @@ class BasicAuthenticate extends BaseAuthenticate {
'userModel' => 'User',
'scope' => array(),
'recursive' => 0,
'contain' => null,
'realm' => '',
);

View file

@ -63,6 +63,8 @@ class DigestAuthenticate extends BaseAuthenticate {
* - `userModel` The model name of the User, defaults to User.
* - `scope` Additional conditions to use when looking up and authenticating users,
* i.e. `array('User.is_active' => 1).`
* - `recursive` The value of the recursive key passed to find(). Defaults to 0.
* - `contain` Extra models to contain and store in session.
* - `realm` The realm authentication is for, Defaults to the servername.
* - `nonce` A nonce used for authentication. Defaults to `uniqid()`.
* - `qop` Defaults to auth, no other values are supported at this time.
@ -79,6 +81,7 @@ class DigestAuthenticate extends BaseAuthenticate {
'userModel' => 'User',
'scope' => array(),
'recursive' => 0,
'contain' => null,
'realm' => '',
'qop' => 'auth',
'nonce' => '',

View file

@ -117,7 +117,7 @@ class AuthComponent extends Component {
* You can also use AuthComponent::ALL instead of the string 'all'
*
* @var mixed
* @link http://book.cakephp.org/view/1275/authorize
* @link http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#authorization
*/
public $authorize = false;

View file

@ -100,6 +100,7 @@ class Controller extends Object implements CakeEventListener {
* additional information about the request.
*
* @var CakeRequest
* @link http://book.cakephp.org/2.0/en/controllers/request-response.html#cakerequest
*/
public $request;
@ -107,6 +108,7 @@ class Controller extends Object implements CakeEventListener {
* An instance of a CakeResponse object that contains information about the impending response
*
* @var CakeResponse
* @link http://book.cakephp.org/2.0/en/controllers/request-response.html#cakeresponse
*/
public $response;
@ -184,7 +186,7 @@ class Controller extends Object implements CakeEventListener {
* Example: `public $components = array('Session', 'RequestHandler', 'Acl');`
*
* @var array
* @link http://book.cakephp.org/view/961/components-helpers-and-uses
* @link http://book.cakephp.org/2.0/en/controllers/components.html
*/
public $components = array('Session');
@ -196,7 +198,8 @@ class Controller extends Object implements CakeEventListener {
public $viewClass = 'View';
/**
* Instance of the View created during rendering. Won't be set until after Controller::render() is called.
* Instance of the View created during rendering. Won't be set until after
* Controller::render() is called.
*
* @var View
*/
@ -234,7 +237,7 @@ class Controller extends Object implements CakeEventListener {
* marks all the actions in the controller for view caching.
*
* @var mixed
* @link http://book.cakephp.org/view/1380/Caching-in-the-Controller
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/cache.html#additional-configuration-options
*/
public $cacheAction = false;
@ -249,13 +252,13 @@ class Controller extends Object implements CakeEventListener {
* Triggers Scaffolding
*
* @var mixed
* @link http://book.cakephp.org/view/1103/Scaffolding
* @link http://book.cakephp.org/2.0/en/controllers/scaffolding.html
*/
public $scaffold = false;
/**
* Holds current methods of the controller. This is a list of all the methods reachable
* via url. Modifying this array, will allow you to change which methods can be reached.
* Holds current methods of the controller. This is a list of all the methods reachable
* via url. Modifying this array, will allow you to change which methods can be reached.
*
* @var array
*/
@ -767,18 +770,18 @@ class Controller extends Object implements CakeEventListener {
session_write_close();
}
if (!empty($status) && is_string($status)) {
if ($url !== null) {
$this->response->header('Location', Router::url($url, true));
}
if (is_string($status)) {
$codes = array_flip($this->response->httpCodes());
if (isset($codes[$status])) {
$status = $codes[$status];
}
}
if ($url !== null) {
$this->response->header('Location', Router::url($url, true));
}
if (!empty($status) && ($status >= 300 && $status < 400)) {
if ($status) {
$this->response->statusCode($status);
}

View file

@ -305,11 +305,11 @@ class Scaffold {
throw new NotFoundException(__d('cake', 'Invalid %s', Inflector::humanize($this->modelClass)));
}
if ($this->ScaffoldModel->delete()) {
$message = __d('cake', 'The %1$s with id: %2$d has been deleted.', Inflector::humanize($this->modelClass), $id);
$message = __d('cake', 'The %1$s with id: %2$s has been deleted.', Inflector::humanize($this->modelClass), $id);
return $this->_sendMessage($message);
} else {
$message = __d('cake',
'There was an error deleting the %1$s with id: %2$d',
'There was an error deleting the %1$s with id: %2$s',
Inflector::humanize($this->modelClass),
$id
);

View file

@ -913,7 +913,11 @@ class App {
return;
}
$errorHandler = Configure::read('Error.handler');
if (PHP_SAPI === 'cli') {
$errorHandler = Configure::read('Error.consoleHandler');
} else {
$errorHandler = Configure::read('Error.handler');
}
if (!is_callable($errorHandler)) {
return;
}

View file

@ -278,6 +278,45 @@ class Configure {
return self::write($values);
}
/**
* Dump data currently in Configure into $filename. The serialization format
* is decided by the config reader attached as $config. For example, if the
* 'default' adapter is a PhpReader, the generated file will be a PHP
* configuration file loadable by the PhpReader.
*
* ## Usage
*
* Given that the 'default' reader is an instance of PhpReader.
* Save all data in Configure to the file `my_config.php`:
*
* `Configure::dump('my_config.php', 'default');`
*
* Save only the error handling configuration:
*
* `Configure::dump('error.php', 'default', array('Error', 'Exception');`
*
* @param string $key The identifier to create in the config adapter.
* This could be a filename or a cache key depending on the adapter being used.
* @param string $config The name of the configured adapter to dump data with.
* @param array $keys The name of the top-level keys you want to dump.
* This allows you save only some data stored in Configure.
* @return boolean success
* @throws ConfigureException if the adapter does not implement a `dump` method.
*/
public static function dump($key, $config = 'default', $keys = array()) {
if (empty(self::$_readers[$config])) {
throw new ConfigureException(__d('cake', 'There is no "%s" adapter.', $config));
}
if (!method_exists(self::$_readers[$config], 'dump')) {
throw new ConfigureException(__d('cake', 'The "%s" adapter, does not have a dump() method.', $config));
}
$values = self::$_values;
if (!empty($keys) && is_array($keys)) {
$values = array_intersect_key($values, array_flip($keys));
}
return (bool)self::$_readers[$config]->dump($key, $values);
}
/**
* Used to determine the current version of CakePHP.
*

View file

@ -204,7 +204,10 @@ class ErrorHandler {
return false;
}
ob_clean();
if (ob_get_level()) {
ob_clean();
}
if (Configure::read('debug')) {
call_user_func($exceptionHandler, new FatalErrorException($description, 500, $file, $line));
} else {

View file

@ -147,8 +147,12 @@ class ExceptionRenderer {
}
$response = new CakeResponse(array('charset' => Configure::read('App.encoding')));
try {
$controller = new CakeErrorController($request, $response);
if (class_exists('AppController')) {
$controller = new CakeErrorController($request, $response);
}
} catch (Exception $e) {
}
if (empty($controller)) {
$controller = new Controller($request, $response);
$controller->viewPath = 'Errors';
}
@ -264,6 +268,11 @@ class ExceptionRenderer {
$this->controller->afterFilter();
$this->controller->response->send();
} catch (Exception $e) {
$this->controller->set(array(
'error' => $e,
'name' => $e->getMessage(),
'code' => $e->getCode(),
));
$this->_outputMessageSafe('error500');
}
}

View file

@ -12,7 +12,7 @@
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html
* @package Cake.Error
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
@ -555,3 +555,18 @@ class FatalErrorException extends CakeException {
}
}
/**
* Not Implemented Exception - used when an API method is not implemented
*
* @package Cake.Error
*/
class NotImplementedException extends CakeException {
protected $_messageTemplate = '%s is not implemented.';
public function __construct($message, $code = 501) {
parent::__construct($message, $code);
}
}

View file

@ -310,6 +310,42 @@ class TranslateBehavior extends ModelBehavior {
* @return boolean
*/
public function beforeValidate(Model $model) {
unset($this->runtime[$model->alias]['beforeSave']);
$this->_setRuntimeData($model);
return true;
}
/**
* beforeSave callback.
*
* Copies data into the runtime property when `$options['validate']` is
* disabled. Or the runtime data hasn't been set yet.
*
* @param Model $model Model save was called on.
* @return boolean true.
*/
public function beforeSave(Model $model, $options = array()) {
if (isset($options['validate']) && $options['validate'] == false) {
unset($this->runtime[$model->alias]['beforeSave']);
}
if (isset($this->runtime[$model->alias]['beforeSave'])) {
return true;
}
$this->_setRuntimeData($model);
return true;
}
/**
* Sets the runtime data.
*
* Used from beforeValidate() and beforeSave() for compatibility issues,
* and to allow translations to be persisted even when validation
* is disabled.
*
* @param Model $model
* @return void
*/
protected function _setRuntimeData(Model $model) {
$locale = $this->_getLocale($model);
if (empty($locale)) {
return true;
@ -333,7 +369,6 @@ class TranslateBehavior extends ModelBehavior {
}
}
$this->runtime[$model->alias]['beforeSave'] = $tempData;
return true;
}
/**
@ -344,12 +379,17 @@ class TranslateBehavior extends ModelBehavior {
* @return void
*/
public function afterSave(Model $model, $created) {
if (!isset($this->runtime[$model->alias]['beforeSave'])) {
if (!isset($this->runtime[$model->alias]['beforeValidate']) && !isset($this->runtime[$model->alias]['beforeSave'])) {
return true;
}
$locale = $this->_getLocale($model);
$tempData = $this->runtime[$model->alias]['beforeSave'];
unset($this->runtime[$model->alias]['beforeSave']);
if (isset($this->runtime[$model->alias]['beforeValidate'])) {
$tempData = $this->runtime[$model->alias]['beforeValidate'];
} else {
$tempData = $this->runtime[$model->alias]['beforeSave'];
}
unset($this->runtime[$model->alias]['beforeValidate'], $this->runtime[$model->alias]['beforeSave']);
$conditions = array('model' => $model->alias, 'foreign_key' => $model->id);
$RuntimeModel = $this->translateModel($model);

View file

@ -414,12 +414,12 @@ class CakeSchema extends Object {
unset($value['type']);
$col .= join(', ', $this->_values($value));
} elseif ($field == 'indexes') {
$col = "\t\t'indexes' => array(";
$col = "\t\t'indexes' => array(\n\t\t\t";
$props = array();
foreach ((array)$value as $key => $index) {
$props[] = "'{$key}' => array(" . join(', ', $this->_values($index)) . ")";
}
$col .= join(', ', $props);
$col .= join(",\n\t\t\t", $props) . "\n\t\t";
} elseif ($field == 'tableParameters') {
$col = "\t\t'tableParameters' => array(";
$props = array();
@ -577,6 +577,9 @@ class CakeSchema extends Object {
$vals[] = "'{$key}' => array('" . implode("', '", $val) . "')";
} elseif (!is_numeric($key)) {
$val = var_export($val, true);
if ($val === 'NULL') {
$val = 'null';
}
$vals[] = "'{$key}' => {$val}";
}
}

View file

@ -681,8 +681,8 @@ class Mysql extends DboSource {
*
* @return boolean
*/
public function supportNestedTransaction() {
return $this->nestedTransaction && version_compare($this->getVersion(), '4.1', '>=');
public function nestedTransactionSupported() {
return $this->useNestedTransactions && version_compare($this->getVersion(), '4.1', '>=');
}
}

View file

@ -900,8 +900,8 @@ class Postgres extends DboSource {
*
* @return boolean
*/
public function supportNestedTransaction() {
return $this->nestedTransaction && version_compare($this->getVersion(), '8.0', '>=');
public function nestedTransactionSupported() {
return $this->useNestedTransactions && version_compare($this->getVersion(), '8.0', '>=');
}
}

View file

@ -564,8 +564,8 @@ class Sqlite extends DboSource {
*
* @return boolean
*/
public function supportNestedTransaction() {
return $this->nestedTransaction && version_compare($this->getVersion(), '3.6.8', '>=');
public function nestedTransactionSupported() {
return $this->useNestedTransactions && version_compare($this->getVersion(), '3.6.8', '>=');
}
}

View file

@ -76,7 +76,7 @@ class DboSource extends DataSource {
*
* @var boolean
*/
public $nestedTransaction = false;
public $useNestedTransactions = false;
/**
* Print full query debug info?
@ -2031,7 +2031,7 @@ class DboSource extends DataSource {
*
* @return boolean
*/
public function supportNestedTransaction() {
public function nestedTransactionSupported() {
return false;
}
@ -2044,7 +2044,7 @@ class DboSource extends DataSource {
*/
public function begin() {
if ($this->_transactionStarted) {
if ($this->supportNestedTransaction()) {
if ($this->nestedTransactionSupported()) {
return $this->_beginNested();
}
$this->_transactionNesting++;
@ -2092,7 +2092,7 @@ class DboSource extends DataSource {
return $this->_connection->commit();
}
if ($this->supportNestedTransaction()) {
if ($this->nestedTransactionSupported()) {
return $this->_commitNested();
}
@ -2134,7 +2134,7 @@ class DboSource extends DataSource {
return $this->_connection->rollBack();
}
if ($this->supportNestedTransaction()) {
if ($this->nestedTransactionSupported()) {
return $this->_rollbackNested();
}

View file

@ -60,7 +60,7 @@ class Model extends Object implements CakeEventListener {
* Custom database table name, or null/false if no table association is desired.
*
* @var string
* @link http://book.cakephp.org/2.0/en/models/model-attributes.html#useTable
* @link http://book.cakephp.org/2.0/en/models/model-attributes.html#usetable
*/
public $useTable = null;
@ -70,7 +70,7 @@ class Model extends Object implements CakeEventListener {
* This field is also used in `find('list')` when called with no extra parameters in the fields list
*
* @var string
* @link http://book.cakephp.org/2.0/en/models/model-attributes.html#displayField
* @link http://book.cakephp.org/2.0/en/models/model-attributes.html#displayfield
*/
public $displayField = null;
@ -262,7 +262,7 @@ class Model extends Object implements CakeEventListener {
* caching only, the results are not stored beyond the current request.
*
* @var boolean
* @link http://book.cakephp.org/2.0/en/models/model-attributes.html#cacheQueries
* @link http://book.cakephp.org/2.0/en/models/model-attributes.html#cachequeries
*/
public $cacheQueries = false;
@ -1454,7 +1454,7 @@ class Model extends Object implements CakeEventListener {
$defaults = array();
$this->id = false;
$this->data = array();
$this->validationErrors = $this->validator()->validationErrors = array();
$this->validationErrors = array();
if ($data !== null && $data !== false) {
foreach ($this->schema() as $field => $properties) {
@ -2041,7 +2041,7 @@ class Model extends Object implements CakeEventListener {
}
$options = array_merge(array('validate' => 'first', 'atomic' => true, 'deep' => false), $options);
$validationErrors = array();
$this->validationErrors = $validationErrors = array();
if (empty($data) && $options['validate'] !== false) {
$result = $this->save($data, $options);
@ -2109,6 +2109,10 @@ class Model extends Object implements CakeEventListener {
* - fieldList: Equivalent to the $fieldList parameter in Model::save()
* - deep: If set to true, all associated data will be validated as well.
*
* Warning: This method could potentially change the passed argument `$data`,
* If you do not want this to happen, make a copy of `$data` before passing it
* to this method
*
* @param array $data Record data to validate. This should be a numerically-indexed array
* @param array $options Options to use when validating record data (see above), See also $options of validates().
* @return boolean True on success, or false on failure.
@ -2152,7 +2156,7 @@ class Model extends Object implements CakeEventListener {
}
$options = array_merge(array('validate' => 'first', 'atomic' => true, 'deep' => false), $options);
$validationErrors = array();
$this->validationErrors = $validationErrors = array();
if (empty($data) && $options['validate'] !== false) {
$result = $this->save($data, $options);
@ -2285,14 +2289,74 @@ class Model extends Object implements CakeEventListener {
* - fieldList: Equivalent to the $fieldList parameter in Model::save()
* - deep: If set to true, not only directly associated data , but deeper nested associated data is validated as well.
*
* Warning: This method could potentially change the passed argument `$data`,
* If you do not want this to happen, make a copy of `$data` before passing it
* to this method
*
* @param array $data Record data to validate. This should be an array indexed by association name.
* @param array $options Options to use when validating record data (see above), See also $options of validates().
* @return array|boolean If atomic: True on success, or false on failure.
* Otherwise: array similar to the $data array passed, but values are set to true/false
* depending on whether each record validated successfully.
*/
public function validateAssociated($data, $options = array()) {
return $this->validator()->validateAssociated($data, $options);
public function validateAssociated(&$data, $options = array()) {
$options = array_merge(array('atomic' => true, 'deep' => false), $options);
$this->validationErrors = $validationErrors = $return = array();
if (!($this->create($data) && $this->validates($options))) {
$validationErrors[$this->alias] = $this->validationErrors;
$return[$this->alias] = false;
} else {
$return[$this->alias] = true;
}
if (empty($options['deep'])) {
$data = $this->data;
} else {
$modelData = $this->data;
$recordData = $modelData[$this->alias];
unset($modelData[$this->alias]);
$data = $modelData + array_merge($data, $recordData);
}
$associations = $this->getAssociated();
foreach ($data as $association => &$values) {
$validates = true;
if (isset($associations[$association])) {
if (in_array($associations[$association], array('belongsTo', 'hasOne'))) {
if ($options['deep']) {
$validates = $this->{$association}->validateAssociated($values, $options);
} else {
$validates = $this->{$association}->create($values) !== null && $this->{$association}->validates($options);
}
if (is_array($validates)) {
if (in_array(false, $validates, true)) {
$validates = false;
} else {
$validates = true;
}
}
$return[$association] = $validates;
} elseif ($associations[$association] === 'hasMany') {
$validates = $this->{$association}->validateMany($values, $options);
$return[$association] = $validates;
}
if (!$validates || (is_array($validates) && in_array(false, $validates, true))) {
$validationErrors[$association] = $this->{$association}->validationErrors;
}
}
}
$this->validationErrors = $validationErrors;
if (isset($validationErrors[$this->alias])) {
$this->validationErrors = $validationErrors[$this->alias];
}
if (!$options['atomic']) {
return $return;
}
if ($return[$this->alias] === false || !empty($this->validationErrors)) {
return false;
}
return true;
}
/**
@ -3239,7 +3303,7 @@ class Model extends Object implements CakeEventListener {
* @param array $queryData Data used to execute this query, i.e. conditions, order, etc.
* @return mixed true if the operation should continue, false if it should abort; or, modified
* $queryData to continue with new $queryData
* @link http://book.cakephp.org/view/1048/Callback-Methods#beforeFind-1049
* @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforefind
*/
public function beforeFind($queryData) {
return true;
@ -3252,7 +3316,7 @@ class Model extends Object implements CakeEventListener {
* @param mixed $results The results of the find operation
* @param boolean $primary Whether this model is being queried directly (vs. being queried as an association)
* @return mixed Result of the find operation
* @link http://book.cakephp.org/view/1048/Callback-Methods#afterFind-1050
* @link http://book.cakephp.org/2.0/en/models/callback-methods.html#afterfind
*/
public function afterFind($results, $primary = false) {
return $results;
@ -3264,7 +3328,7 @@ class Model extends Object implements CakeEventListener {
*
* @param array $options
* @return boolean True if the operation should continue, false if it should abort
* @link http://book.cakephp.org/view/1048/Callback-Methods#beforeSave-1052
* @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforesave
*/
public function beforeSave($options = array()) {
return true;
@ -3275,7 +3339,7 @@ class Model extends Object implements CakeEventListener {
*
* @param boolean $created True if this save created a new record
* @return void
* @link http://book.cakephp.org/view/1048/Callback-Methods#afterSave-1053
* @link http://book.cakephp.org/2.0/en/models/callback-methods.html#aftersave
*/
public function afterSave($created) {
}
@ -3285,7 +3349,7 @@ class Model extends Object implements CakeEventListener {
*
* @param boolean $cascade If true records that depend on this record will also be deleted
* @return boolean True if the operation should continue, false if it should abort
* @link http://book.cakephp.org/view/1048/Callback-Methods#beforeDelete-1054
* @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforedelete
*/
public function beforeDelete($cascade = true) {
return true;
@ -3295,7 +3359,7 @@ class Model extends Object implements CakeEventListener {
* Called after every deletion operation.
*
* @return void
* @link http://book.cakephp.org/view/1048/Callback-Methods#afterDelete-1055
* @link http://book.cakephp.org/2.0/en/models/callback-methods.html#afterdelete
*/
public function afterDelete() {
}
@ -3306,7 +3370,7 @@ class Model extends Object implements CakeEventListener {
*
* @param array $options Options passed from model::save(), see $options of model::save().
* @return boolean True if validate operation should continue, false to abort
* @link http://book.cakephp.org/view/1048/Callback-Methods#beforeValidate-1051
* @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate
*/
public function beforeValidate($options = array()) {
return true;
@ -3324,7 +3388,7 @@ class Model extends Object implements CakeEventListener {
* Called when a DataSource-level error occurs.
*
* @return void
* @link http://book.cakephp.org/view/1048/Callback-Methods#onError-1056
* @link http://book.cakephp.org/2.0/en/models/callback-methods.html#onerror
*/
public function onError() {
}

View file

@ -80,6 +80,10 @@ class CakeResponse {
* @var array
*/
protected $_mimeTypes = array(
'html' => array('text/html', '*/*'),
'json' => 'application/json',
'xml' => array('application/xml', 'text/xml'),
'rss' => 'application/rss+xml',
'ai' => 'application/postscript',
'bcpio' => 'application/x-bcpio',
'bin' => 'application/octet-stream',
@ -206,7 +210,6 @@ class CakeResponse {
'f90' => 'text/plain',
'h' => 'text/plain',
'hh' => 'text/plain',
'html' => array('text/html', '*/*'),
'htm' => array('text/html', '*/*'),
'ics' => 'text/calendar',
'm' => 'text/plain',
@ -218,7 +221,6 @@ class CakeResponse {
'tpl' => 'text/template',
'txt' => 'text/plain',
'text' => 'text/plain',
'xml' => array('application/xml', 'text/xml'),
'avi' => 'video/x-msvideo',
'fli' => 'video/x-fli',
'mov' => 'video/quicktime',
@ -261,12 +263,10 @@ class CakeResponse {
'pdb' => 'chemical/x-pdb',
'xyz' => 'chemical/x-pdb',
'javascript' => 'text/javascript',
'json' => 'application/json',
'form' => 'application/x-www-form-urlencoded',
'file' => 'multipart/form-data',
'xhtml' => array('application/xhtml+xml', 'application/xhtml', 'text/xhtml'),
'xhtml-mobile' => 'application/vnd.wap.xhtml+xml',
'rss' => 'application/rss+xml',
'atom' => 'application/atom+xml',
'amf' => 'application/x-amf',
'wap' => array('text/vnd.wap.wml', 'text/vnd.wap.wmlscript', 'image/vnd.wap.wbmp'),
@ -328,7 +328,7 @@ class CakeResponse {
/**
* Holds cookies to be sent to the client
*
*
* @var array
*/
protected $_cookies = array();
@ -384,7 +384,7 @@ class CakeResponse {
* Sets the cookies that have been added via static method CakeResponse::addCookie()
* before any other output is sent to the client.
* Will set the cookies in the order they have been set.
*
*
* @return void
*/
protected function _setCookies() {
@ -595,7 +595,7 @@ class CakeResponse {
* Sets the response content type. It can be either a file extension
* which will be mapped internally to a mime-type or a string representing a mime-type
* if $contentType is null the current content type is returned
* if $contentType is an associative array, it will be stored as a content type definition
* if $contentType is an associative array, content type definitions will be stored/replaced
*
* ### Setting the content type
*
@ -605,9 +605,9 @@ class CakeResponse {
*
* e.g `type();`
*
* ### Storing a content type definition
* ### Storing content type definitions
*
* e.g `type(array('keynote' => 'application/keynote'));`
* e.g `type(array('keynote' => 'application/keynote', 'bat' => 'application/bat'));`
*
* ### Replacing a content type definition
*
@ -621,9 +621,9 @@ class CakeResponse {
return $this->_contentType;
}
if (is_array($contentType)) {
$type = key($contentType);
$defitition = current($contentType);
$this->_mimeTypes[$type] = $defitition;
foreach ($contentType as $type => $definition) {
$this->_mimeTypes[$type] = $definition;
}
return $this->_contentType;
}
if (isset($this->_mimeTypes[$contentType])) {
@ -800,12 +800,12 @@ class CakeResponse {
/**
* Sets the Cache-Control must-revalidate directive.
* must-revalidate indicates that the response should not be served
* stale by a cache under any cirumstance without first revalidating
* must-revalidate indicates that the response should not be served
* stale by a cache under any cirumstance without first revalidating
* with the origin.
* If called with no parameters, this function will return wheter must-revalidate is present.
*
* @param int $seconds if null, the method will return the current
* @param int $seconds if null, the method will return the current
* must-revalidate value
* @return boolean
*/
@ -886,8 +886,8 @@ class CakeResponse {
}
/**
* Sets the response as Not Modified by removing any body contents
* setting the status code to "304 Not Modified" and removing all
* Sets the response as Not Modified by removing any body contents
* setting the status code to "304 Not Modified" and removing all
* conflicting headers
*
* @return void
@ -911,11 +911,11 @@ class CakeResponse {
/**
* Sets the Vary header for the response, if an array is passed,
* values will be imploded into a comma separated string. If no
* parameters are passed, then an array with the current Vary header
* values will be imploded into a comma separated string. If no
* parameters are passed, then an array with the current Vary header
* value is returned
*
* @param string|array $cacheVariances a single Vary string or a array
* @param string|array $cacheVariances a single Vary string or a array
* containig the list for variances.
* @return array
**/
@ -932,22 +932,22 @@ class CakeResponse {
/**
* Sets the response Etag, Etags are a strong indicative that a response
* can be cached by a HTTP client. A bad way of generaing Etags is
* creating a hash of the response output, instead generate a unique
* hash of the unique components that identifies a request, such as a
* modification time, a resource Id, and anything else you consider it
* can be cached by a HTTP client. A bad way of generaing Etags is
* creating a hash of the response output, instead generate a unique
* hash of the unique components that identifies a request, such as a
* modification time, a resource Id, and anything else you consider it
* makes it unique.
*
* Second parameter is used to instuct clients that the content has
* changed, but sematicallly, it can be used as the same thing. Think
* for instance of a page with a hit counter, two different page views
* are equivalent, but they differ by a few bytes. This leaves off to
* Second parameter is used to instuct clients that the content has
* changed, but sematicallly, it can be used as the same thing. Think
* for instance of a page with a hit counter, two different page views
* are equivalent, but they differ by a few bytes. This leaves off to
* the Client the decision of using or not the cached page.
*
* If no parameters are passed, current Etag header is returned.
*
* @param string $hash the unique has that identifies this resposnse
* @param boolean $weak whether the response is semantically the same as
* @param boolean $weak whether the response is semantically the same as
* other with th same hash or not
* @return string
**/
@ -965,7 +965,7 @@ class CakeResponse {
* Returns a DateTime object initialized at the $time param and using UTC
* as timezone
*
* @param string|int|DateTime $time
* @param string|int|DateTime $time
* @return DateTime
*/
protected function _getUTCDate($time = null) {
@ -1043,16 +1043,16 @@ class CakeResponse {
}
/**
* Checks whether a response has not been modified according to the 'If-None-Match'
* (Etags) and 'If-Modified-Since' (last modification date) request
* headers headers. If the response is detected to be not modified, it
* Checks whether a response has not been modified according to the 'If-None-Match'
* (Etags) and 'If-Modified-Since' (last modification date) request
* headers headers. If the response is detected to be not modified, it
* is marked as so accordingly so the client can be informed of that.
*
* In order to mark a response as not modified, you need to set at least
* the Last-Modified response header or a response etag to be compared
* In order to mark a response as not modified, you need to set at least
* the Last-Modified response header or a response etag to be compared
* with the request itself
*
* @return boolean whether the response was marked as not modified or
* @return boolean whether the response was marked as not modified or
* not
**/
public function checkNotModified(CakeRequest $request) {
@ -1087,19 +1087,19 @@ class CakeResponse {
/**
* Getter/Setter for cookie configs
*
*
* This method acts as a setter/getter depending on the type of the argument.
* If the method is called with no arguments, it returns all configurations.
*
*
* If the method is called with a string as argument, it returns either the
* given configuration if it is set, or null, if it's not set.
*
*
* If the method is called with an array as argument, it will set the cookie
* configuration to the cookie container.
*
*
* @param $options Either null to get all cookies, string for a specific cookie
* or array to set cookie.
*
*
* ### Options (when setting a configuration)
* - name: The Cookie name
* - value: Value of the cookie
@ -1108,21 +1108,21 @@ class CakeResponse {
* - domain: Domain the cookie is for.
* - secure: Is the cookie https?
* - httpOnly: Is the cookie available in the client?
*
*
* ## Examples
*
*
* ### Getting all cookies
*
*
* `$this->cookie()`
*
*
* ### Getting a certain cookie configuration
*
*
* `$this->cookie('MyCookie')`
*
*
* ### Setting a cookie configuration
*
*
* `$this->cookie((array) $options)`
*
*
* @return mixed
*/
public function cookie($options = null) {

View file

@ -1238,9 +1238,6 @@ class CakeEmail {
$formatted[] = '';
continue;
}
if ($line[0] === '.') {
$line = '.' . $line;
}
if (!preg_match('/\<[a-z]/i', $line)) {
$formatted = array_merge($formatted, explode("\n", wordwrap($line, self::LINE_LENGTH_SHOULD, "\n")));
continue;

View file

@ -168,7 +168,16 @@ class SmtpTransport extends AbstractTransport {
$headers = $this->_cakeEmail->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject'));
$headers = $this->_headersToString($headers);
$message = implode("\r\n", $this->_cakeEmail->message());
$lines = $this->_cakeEmail->message();
$messages = array();
foreach ($lines as $line) {
if ((!empty($line)) && ($line[0] === '.')) {
$messages[] = '.' . $line;
} else {
$messages[] = $line;
}
}
$message = implode("\r\n", $messages);
$this->_smtpSend($headers . "\r\n\r\n" . $message . "\r\n\r\n\r\n.");
$this->_content = array('headers' => $headers, 'message' => $message);
}

View file

@ -478,8 +478,11 @@ class CakeRoute {
* @return string Composed route string.
*/
protected function _writeUrl($params) {
if (isset($params['prefix'], $params['action'])) {
$params['action'] = str_replace($params['prefix'] . '_', '', $params['action']);
if (isset($params['prefix'])) {
$prefixed = $params['prefix'] . '_';
}
if (isset($prefixed, $params['action']) && strpos($params['action'], $prefixed) === 0) {
$params['action'] = substr($params['action'], strlen($prefixed) * -1);
unset($params['prefix']);
}

View file

@ -157,7 +157,7 @@ class Router {
*
* @var string
*/
protected static $_routeClass = 'CakeRoute';
protected static $_routeClass = 'CakeRoute';
/**
* Set the default route class to use or return the current one
@ -893,8 +893,9 @@ class Router {
list($args, $named) = array(Hash::filter($args), Hash::filter($named));
foreach (self::$_prefixes as $prefix) {
if (!empty($url[$prefix])) {
$url['action'] = str_replace($prefix . '_', '', $url['action']);
$prefixed = $prefix . '_';
if (!empty($url[$prefix]) && strpos($url['action'], $prefixed) === 0) {
$url['action'] = substr($url['action'], strlen($prefixed) * -1);
break;
}
}
@ -956,12 +957,19 @@ class Router {
$out = '';
if (is_array($q)) {
$q = array_merge($extra, $q);
$q = array_merge($q, $extra);
} else {
$out = $q;
$q = $extra;
}
$out .= http_build_query($q, null, $join);
$addition = http_build_query($q, null, $join);
if ($out && $addition && substr($out, strlen($join) * -1, strlen($join)) != $join) {
$out .= $join;
}
$out .= $addition;
if (isset($out[0]) && $out[0] != '?') {
$out = '?' . $out;
}

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case
* @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Cache
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Cache.Engine
* @since CakePHP(tm) v 1.2.0.5434
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Cache.Engine
* @since CakePHP(tm) v 1.2.0.5434
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Cache.Engine
* @since CakePHP(tm) v 1.2.0.5434
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Cache.Engine
* @since CakePHP(tm) v 1.2.0.5434
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Cache.Engine
* @since CakePHP(tm) v 1.2.0.5434
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Configure
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
@ -21,11 +21,24 @@ App::uses('IniReader', 'Configure');
class IniReaderTest extends CakeTestCase {
/**
* The test file that will be read.
* Test data to serialize and unserialize.
*
* @var string
* @var array
*/
public $file;
public $testData = array(
'One' => array(
'two' => 'value',
'three' => array(
'four' => 'value four'
),
'is_null' => null,
'bool_false' => false,
'bool_true' => true,
),
'Asset' => array(
'timestamp' => 'force'
),
);
/**
* setup
@ -92,6 +105,8 @@ class IniReaderTest extends CakeTestCase {
$this->assertTrue(isset($config['database']['db']['username']));
$this->assertEquals('mark', $config['database']['db']['username']);
$this->assertEquals(3, $config['nesting']['one']['two']['three']);
$this->assertFalse(isset($config['database.db.username']));
$this->assertFalse(isset($config['database']['db.username']));
}
/**
@ -125,4 +140,49 @@ class IniReaderTest extends CakeTestCase {
$config = $reader->read('nested');
$this->assertTrue($config['bools']['test_on']);
}
/**
* test dump method.
*
* @return void
*/
public function testDump() {
$reader = new IniReader(TMP);
$result = $reader->dump('test.ini', $this->testData);
$this->assertTrue($result > 0);
$expected = <<<INI
[One]
two = value
three.four = value four
is_null = null
bool_false = false
bool_true = true
[Asset]
timestamp = force
INI;
$file = TMP . 'test.ini';
$result = file_get_contents($file);
unlink($file);
$this->assertTextEquals($expected, $result);
}
/**
* Test that dump() makes files read() can read.
*
* @return void
*/
public function testDumpRead() {
$reader = new IniReader(TMP);
$reader->dump('test.ini', $this->testData);
$result = $reader->read('test.ini');
unlink(TMP . 'test.ini');
$expected = $this->testData;
$expected['One']['is_null'] = false;
$this->assertEquals($expected, $result);
}
}

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Configure
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
@ -20,6 +20,26 @@ App::uses('PhpReader', 'Configure');
class PhpReaderTest extends CakeTestCase {
/**
* Test data to serialize and unserialize.
*
* @var array
*/
public $testData = array(
'One' => array(
'two' => 'value',
'three' => array(
'four' => 'value four'
),
'is_null' => null,
'bool_false' => false,
'bool_true' => true,
),
'Asset' => array(
'timestamp' => 'force'
),
);
/**
* setup
*
@ -96,4 +116,55 @@ class PhpReaderTest extends CakeTestCase {
$this->assertTrue(isset($result['plugin_load']));
CakePlugin::unload();
}
/**
* Test dumping data to PHP format.
*
* @return void
*/
public function testDump() {
$reader = new PhpReader(TMP);
$result = $reader->dump('test.php', $this->testData);
$this->assertTrue($result > 0);
$expected = <<<PHP
<?php
\$config = array (
'One' =>
array (
'two' => 'value',
'three' =>
array (
'four' => 'value four',
),
'is_null' => NULL,
'bool_false' => false,
'bool_true' => true,
),
'Asset' =>
array (
'timestamp' => 'force',
),
);
PHP;
$file = TMP . 'test.php';
$contents = file_get_contents($file);
unlink($file);
$this->assertTextEquals($expected, $contents);
}
/**
* Test that dump() makes files read() can read.
*
* @return void
*/
public function testDumpRead() {
$reader = new PhpReader(TMP);
$reader->dump('test.php', $this->testData);
$result = $reader->read('test.php');
unlink(TMP . 'test.php');
$this->assertEquals($this->testData, $result);
}
}

View file

@ -38,7 +38,10 @@ class AllConsoleLibsTest extends PHPUnit_Framework_TestSuite {
if (!$file->isFile() || strpos($file, 'All') === 0) {
continue;
}
$suite->addTestFile($file->getRealPath());
$fileName = $file->getRealPath();
if (substr($fileName, -4) === '.php') {
$suite->addTestFile($file->getRealPath());
}
}
return $suite;
}

View file

@ -107,15 +107,15 @@ class TemplateTaskTest extends CakeTestCase {
$result = $this->Task->getThemePath();
$this->assertEquals($defaultTheme, $result);
$this->Task->templatePaths = array('default' => $defaultTheme, 'other' => '/some/path');
$this->Task->templatePaths = array('other' => '/some/path', 'default' => $defaultTheme);
$this->Task->params['theme'] = 'other';
$result = $this->Task->getThemePath();
$this->assertEquals('/some/path', $result);
$this->Task->params = array();
$result = $this->Task->getThemePath();
$this->assertEquals($defaultTheme, $result);
$this->assertEquals('default', $this->Task->params['theme']);
$this->assertEquals('/some/path', $result);
$this->assertEquals('other', $this->Task->params['theme']);
}
/**
@ -134,7 +134,7 @@ class TemplateTaskTest extends CakeTestCase {
$result = $this->Task->generate('classes', 'test_object', array('test' => 'foo'));
$expected = "I got rendered\nfoo";
$this->assertEquals($expected, $result);
$this->assertTextEquals($expected, $result);
}
/**

View file

@ -487,21 +487,83 @@ class TestTaskTest extends CakeTestCase {
$this->assertContains("'app.articles_tag'", $result);
}
/**
* test baking component test files,
*
* @return void
*/
public function testBakeComponentTest() {
$this->Task->expects($this->once())->method('createFile')->will($this->returnValue(true));
$result = $this->Task->bake('Component', 'Example');
$this->assertContains("App::uses('ExampleComponent', 'Controller/Component')", $result);
$this->assertContains('class ExampleComponentTest extends CakeTestCase', $result);
$this->assertContains('function setUp()', $result);
$this->assertContains("\$Collection = new ComponentCollection()", $result);
$this->assertContains("\$this->Example = new ExampleComponent(\$Collection)", $result);
$this->assertContains('function tearDown()', $result);
$this->assertContains('unset($this->Example)', $result);
}
/**
* test baking behavior test files,
*
* @return void
*/
public function testBakeBehaviorTest() {
$this->Task->expects($this->once())->method('createFile')->will($this->returnValue(true));
$result = $this->Task->bake('Behavior', 'Example');
$this->assertContains("App::uses('ExampleBehavior', 'Model/Behavior')", $result);
$this->assertContains('class ExampleBehaviorTest extends CakeTestCase', $result);
$this->assertContains('function setUp()', $result);
$this->assertContains("\$this->Example = new ExampleBehavior()", $result);
$this->assertContains('function tearDown()', $result);
$this->assertContains('unset($this->Example)', $result);
}
/**
* test baking helper test files,
*
* @return void
*/
public function testBakeHelperTest() {
$this->Task->expects($this->once())->method('createFile')->will($this->returnValue(true));
$result = $this->Task->bake('Helper', 'Example');
$this->assertContains("App::uses('ExampleHelper', 'View/Helper')", $result);
$this->assertContains('class ExampleHelperTest extends CakeTestCase', $result);
$this->assertContains('function setUp()', $result);
$this->assertContains("\$View = new View()", $result);
$this->assertContains("\$this->Example = new ExampleHelper(\$View)", $result);
$this->assertContains('function tearDown()', $result);
$this->assertContains('unset($this->Example)', $result);
}
/**
* test Constructor generation ensure that constructClasses is called for controllers
*
* @return void
*/
public function testGenerateConstructor() {
$result = $this->Task->generateConstructor('controller', 'PostsController');
$result = $this->Task->generateConstructor('controller', 'PostsController', null);
$expected = array('', "new TestPostsController();\n", "\$this->Posts->constructClasses();\n");
$this->assertEquals($expected, $result);
$result = $this->Task->generateConstructor('model', 'Post');
$result = $this->Task->generateConstructor('model', 'Post', null);
$expected = array('', "ClassRegistry::init('Post');\n", '');
$this->assertEquals($expected, $result);
$result = $this->Task->generateConstructor('helper', 'FormHelper');
$result = $this->Task->generateConstructor('helper', 'FormHelper', null);
$expected = array("\$View = new View();\n", "new FormHelper(\$View);\n", '');
$this->assertEquals($expected, $result);
}

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc.
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc.
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Console
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc.
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc.
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Console
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc.
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc.
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Console
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc.
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc.
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Console
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
@ -437,7 +437,7 @@ class ShellDispatcherTest extends CakeTestCase {
*/
public function testDispatchShellWithMain() {
$Dispatcher = new TestShellDispatcher();
$Mock = $this->getMock('Shell', array(), array(&$Dispatcher), 'MockWithMainShell');
$Mock = $this->getMock('Shell', array(), array(), 'MockWithMainShell');
$Mock->expects($this->once())->method('initialize');
$Mock->expects($this->once())->method('loadTasks');
@ -460,9 +460,9 @@ class ShellDispatcherTest extends CakeTestCase {
*/
public function testDispatchShellWithoutMain() {
$Dispatcher = new TestShellDispatcher();
$Shell = $this->getMock('Shell', array(), array(&$Dispatcher), 'MockWithoutMainShell');
$Shell = $this->getMock('Shell', array(), array(), 'MockWithoutMainShell');
$Shell = new MockWithoutMainShell($Dispatcher);
$Shell = new MockWithoutMainShell();
$this->mockObjects[] = $Shell;
$Shell->expects($this->once())->method('initialize');

View file

@ -11,7 +11,7 @@
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Console
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -349,14 +349,14 @@ class DbAclTest extends CakeTestCase {
* @return void
*/
public function testCheckMissingPermission() {
$this->Acl->check('users', 'NonExistant', 'read');
$this->Acl->check('users', 'NonExistent', 'read');
}
/**
* testDbAclCascadingDeny function
*
* Setup the acl permissions such that Bobs inherits from admin.
* deny Admin delete access to a specific resource, check the permisssions are inherited.
* deny Admin delete access to a specific resource, check the permissions are inherited.
*
* @return void
*/
@ -483,7 +483,7 @@ class DbAclTest extends CakeTestCase {
/**
* debug function - to help editing/creating test cases for the ACL component
*
* To check the overal ACL status at any time call $this->__debug();
* To check the overall ACL status at any time call $this->__debug();
* Generates a list of the current aro and aco structures and a grid dump of the permissions that are defined
* Only designed to work with the db based ACL
*

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Controller.Component
* @since CakePHP(tm) v 1.2.0.5435
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Controller.Component
* @since CakePHP(tm) v 1.2.0.5347
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Controller.Component
* @since CakePHP(tm) v 1.2.0.5435
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -6,14 +6,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Controller.Component
* @since CakePHP(tm) v 1.2.0.5347
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -6,14 +6,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Controller.Component
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Controller.Component
* @since CakePHP(tm) v 1.2.0.5435
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Controller.Component
* @since CakePHP(tm) v 1.2.0.5435
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Controller.Component
* @since CakePHP(tm) v 1.2.0.5436
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -11,7 +11,7 @@
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Controller
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Controller
* @since CakePHP(tm) v 1.2.0.5436
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -6,14 +6,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Controller
* @since CakePHP(tm) v 1.2.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -728,7 +728,8 @@ class ControllerTest extends CakeTestCase {
array(303, "See Other"),
array(304, "Not Modified"),
array(305, "Use Proxy"),
array(307, "Temporary Redirect")
array(307, "Temporary Redirect"),
array(403, "Forbidden"),
);
}

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Controller
* @since CakePHP(tm) v 1.2.0.5436
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Controller
* @since CakePHP(tm) v 1.2.0.5436
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -6,14 +6,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Core
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
@ -362,4 +362,47 @@ class ConfigureTest extends CakeTestCase {
$this->assertNull(Configure::read('debug'));
$this->assertNull(Configure::read('test'));
}
/**
* @expectedException ConfigureException
*/
public function testDumpNoAdapter() {
Configure::dump(TMP . 'test.php', 'does_not_exist');
}
/**
* test dump integrated with the PhpReader.
*
* @return void
*/
public function testDump() {
Configure::config('test_reader', new PhpReader(TMP));
$result = Configure::dump('config_test.php', 'test_reader');
$this->assertTrue($result > 0);
$result = file_get_contents(TMP . 'config_test.php');
$this->assertContains('<?php', $result);
$this->assertContains('$config = ', $result);
@unlink(TMP . 'config_test.php');
}
/**
* Test dumping only some of the data.
*
* @return
*/
public function testDumpPartial() {
Configure::config('test_reader', new PhpReader(TMP));
$result = Configure::dump('config_test.php', 'test_reader', array('Error'));
$this->assertTrue($result > 0);
$result = file_get_contents(TMP . 'config_test.php');
$this->assertContains('<?php', $result);
$this->assertContains('$config = ', $result);
$this->assertContains('Error', $result);
$this->assertNotContains('debug', $result);
@unlink(TMP . 'config_test.php');
}
}

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Core
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Error
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Error
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
@ -639,7 +639,7 @@ class ExceptionRendererTest extends CakeTestCase {
->with('missingHelper')
->will($this->throwException($exception));
$ExceptionRenderer->controller->expects($this->at(4))
$ExceptionRenderer->controller->expects($this->at(5))
->method('render')
->with('error500')
->will($this->returnValue(true));
@ -671,7 +671,7 @@ class ExceptionRendererTest extends CakeTestCase {
->with('error400')
->will($this->throwException($exception));
$ExceptionRenderer->controller->expects($this->at(3))
$ExceptionRenderer->controller->expects($this->at(4))
->method('render')
->with('error500')
->will($this->returnValue(true));

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.I18n
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.I18n
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.I18n
* @since CakePHP(tm) v 1.2.0.6833
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Log
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Log.Engine
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Model
* @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Model.Behavior
* @since CakePHP(tm) v 1.2.0.5669
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,21 +4,18 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Model.Behavior
* @since CakePHP(tm) v 1.2.0.5669
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
}
App::uses('Model', 'Model');
App::uses('AppModel', 'Model');
@ -110,7 +107,11 @@ class TranslateBehaviorTest extends CakeTestCase {
$TestModel->locale = false;
$result = $TestModel->read(null, 1);
$expected = array('TranslatedItem' => array('id' => 1, 'slug' => 'first_translated'));
$expected = array('TranslatedItem' => array(
'id' => 1,
'slug' => 'first_translated',
'translated_article_id' => 1,
));
$this->assertEquals($expected, $result);
$result = $TestModel->find('all', array('fields' => array('slug')));
@ -138,7 +139,7 @@ class TranslateBehaviorTest extends CakeTestCase {
$result = $TestModel->read(null, 1);
$expected = array(
'TranslatedItem' => array('id' => 1, 'slug' => 'first_translated'),
'TranslatedItem' => array('id' => 1, 'slug' => 'first_translated', 'translated_article_id' => 1),
'Title' => array(
array('id' => 1, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Title #1'),
array('id' => 3, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titel #1'),
@ -194,7 +195,8 @@ class TranslateBehaviorTest extends CakeTestCase {
'slug' => 'first_translated',
'locale' => 'eng',
'title' => 'Title #1',
'content' => 'Content #1'
'content' => 'Content #1',
'translated_article_id' => 1,
)
);
$this->assertEquals($expected, $result);
@ -207,7 +209,8 @@ class TranslateBehaviorTest extends CakeTestCase {
'slug' => 'first_translated',
'locale' => 'eng',
'title' => 'Title #1',
'content' => 'Content #1'
'content' => 'Content #1',
'translated_article_id' => 1,
)
),
array(
@ -216,7 +219,8 @@ class TranslateBehaviorTest extends CakeTestCase {
'slug' => 'second_translated',
'locale' => 'eng',
'title' => 'Title #2',
'content' => 'Content #2'
'content' => 'Content #2',
'translated_article_id' => 1,
)
),
array(
@ -225,7 +229,8 @@ class TranslateBehaviorTest extends CakeTestCase {
'slug' => 'third_translated',
'locale' => 'eng',
'title' => 'Title #3',
'content' => 'Content #3'
'content' => 'Content #3',
'translated_article_id' => 1,
)
)
);
@ -250,7 +255,8 @@ class TranslateBehaviorTest extends CakeTestCase {
'slug' => 'first_translated',
'locale' => 'eng',
'title' => 'Title #1',
'content' => 'Content #1'
'content' => 'Content #1',
'translated_article_id' => 1,
)
)
);
@ -264,7 +270,8 @@ class TranslateBehaviorTest extends CakeTestCase {
'slug' => 'first_translated',
'locale' => 'eng',
'title' => 'Title #1',
'content' => 'Content #1'
'content' => 'Content #1',
'translated_article_id' => 1,
)
)
);
@ -292,7 +299,8 @@ class TranslateBehaviorTest extends CakeTestCase {
'slug' => 'first_translated',
'locale' => 'eng',
'title' => 'Title #1',
'content' => 'Content #1'
'content' => 'Content #1',
'translated_article_id' => 1,
),
'Title' => array(
array('id' => 1, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Title #1'),
@ -313,17 +321,35 @@ class TranslateBehaviorTest extends CakeTestCase {
$result = $TestModel->find('all', array('fields' => array('TranslatedItem.title')));
$expected = array(
array(
'TranslatedItem' => array('id' => 1, 'locale' => 'eng', 'title' => 'Title #1', 'slug' => 'first_translated'),
'TranslatedItem' => array(
'id' => 1,
'locale' => 'eng',
'title' => 'Title #1',
'slug' => 'first_translated',
'translated_article_id' => 1,
),
'Title' => array(array('foreign_key' => 1, 'content' => 'Title #1')),
'Content' => array(array('foreign_key' => 1, 'content' => 'Content #1'))
),
array(
'TranslatedItem' => array('id' => 2, 'locale' => 'eng', 'title' => 'Title #2', 'slug' => 'second_translated'),
'TranslatedItem' => array(
'id' => 2,
'locale' => 'eng',
'title' => 'Title #2',
'slug' => 'second_translated',
'translated_article_id' => 1,
),
'Title' => array(array('foreign_key' => 2, 'content' => 'Title #2')),
'Content' => array(array('foreign_key' => 2, 'content' => 'Content #2'))
),
array(
'TranslatedItem' => array('id' => 3, 'locale' => 'eng', 'title' => 'Title #3','slug' => 'third_translated'),
'TranslatedItem' => array(
'id' => 3,
'locale' => 'eng',
'title' => 'Title #3',
'slug' => 'third_translated',
'translated_article_id' => 1,
),
'Title' => array(array('foreign_key' => 3, 'content' => 'Title #3')),
'Content' => array(array('foreign_key' => 3, 'content' => 'Content #3'))
)
@ -349,7 +375,8 @@ class TranslateBehaviorTest extends CakeTestCase {
'slug' => 'first_translated',
'locale' => 'deu',
'title' => 'Titel #1',
'content' => 'Inhalt #1'
'content' => 'Inhalt #1',
'translated_article_id' => 1,
)
);
$this->assertEquals($expected, $result);
@ -361,7 +388,7 @@ class TranslateBehaviorTest extends CakeTestCase {
'slug' => 'first_translated',
'locale' => 'deu',
'content' => 'Inhalt #1',
'title' => 'Titel #1'
'title' => 'Titel #1',
)
),
array(
@ -369,7 +396,7 @@ class TranslateBehaviorTest extends CakeTestCase {
'slug' => 'second_translated',
'locale' => 'deu',
'title' => 'Titel #2',
'content' => 'Inhalt #2'
'content' => 'Inhalt #2',
)
),
array(
@ -377,7 +404,7 @@ class TranslateBehaviorTest extends CakeTestCase {
'slug' => 'third_translated',
'locale' => 'deu',
'title' => 'Titel #3',
'content' => 'Inhalt #3'
'content' => 'Inhalt #3',
)
)
);
@ -406,7 +433,8 @@ class TranslateBehaviorTest extends CakeTestCase {
'slug' => 'first_translated',
'locale' => 'rus',
'title' => '',
'content' => ''
'content' => '',
'translated_article_id' => 1,
)
);
$this->assertEquals($expected, $result);
@ -490,7 +518,12 @@ class TranslateBehaviorTest extends CakeTestCase {
$TestModel = new TranslatedItem();
$TestModel->locale = 'spa';
$data = array('slug' => 'fourth_translated', 'title' => 'Leyenda #4', 'content' => 'Contenido #4');
$data = array(
'slug' => 'fourth_translated',
'title' => 'Leyenda #4',
'content' => 'Contenido #4',
'translated_article_id' => 1,
);
$TestModel->create($data);
$TestModel->save();
$result = $TestModel->read();
@ -508,7 +541,7 @@ class TranslateBehaviorTest extends CakeTestCase {
$TestModel = new TranslatedItem();
$TestModel->locale = 'spa';
$oldData = array('slug' => 'fourth_translated', 'title' => 'Leyenda #4');
$oldData = array('slug' => 'fourth_translated', 'title' => 'Leyenda #4', 'translated_article_id' => 1);
$TestModel->create($oldData);
$TestModel->save();
$id = $TestModel->id;
@ -545,7 +578,14 @@ class TranslateBehaviorTest extends CakeTestCase {
$result = $TestModel->read();
$expected = array(
'TranslatedItem' => array('id' => 4, 'slug' => 'new_translated', 'locale' => 'eng', 'title' => 'New title', 'content' => 'New content'),
'TranslatedItem' => array(
'id' => 4,
'slug' => 'new_translated',
'locale' => 'eng',
'title' => 'New title',
'content' => 'New content',
'translated_article_id' => null,
),
'Title' => array(
array('id' => 21, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 4, 'field' => 'title', 'content' => 'New title'),
array('id' => 22, 'locale' => 'spa', 'model' => 'TranslatedItem', 'foreign_key' => 4, 'field' => 'title', 'content' => 'Nuevo leyenda')
@ -582,7 +622,14 @@ class TranslateBehaviorTest extends CakeTestCase {
$TestModel->bindTranslation($translations, false);
$result = $TestModel->read(null, 1);
$expected = array(
'TranslatedItem' => array('id' => '1', 'slug' => 'first_translated', 'locale' => 'eng', 'title' => 'New Title #1', 'content' => 'New Content #1'),
'TranslatedItem' => array(
'id' => '1',
'slug' => 'first_translated',
'locale' => 'eng',
'title' => 'New Title #1',
'content' => 'New Content #1',
'translated_article_id' => 1,
),
'Title' => array(
array('id' => 1, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'New Title #1'),
array('id' => 3, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Neue Titel #1'),
@ -625,7 +672,14 @@ class TranslateBehaviorTest extends CakeTestCase {
$result['Title'] = Hash::sort($result['Title'], '{n}.id', 'asc');
$result['Content'] = Hash::sort($result['Content'], '{n}.id', 'asc');
$expected = array(
'TranslatedItem' => array('id' => 1, 'slug' => 'first_translated', 'locale' => 'cze', 'title' => 'Titulek #1', 'content' => 'Upraveny obsah #1'),
'TranslatedItem' => array(
'id' => 1,
'slug' => 'first_translated',
'locale' => 'cze',
'title' => 'Titulek #1',
'content' => 'Upraveny obsah #1',
'translated_article_id' => 1,
),
'Title' => array(
array('id' => 1, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Updated Title #1'),
array('id' => 3, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titel #1'),
@ -641,6 +695,49 @@ class TranslateBehaviorTest extends CakeTestCase {
$this->assertEquals($expected, $result);
}
/**
* Test that saveAll() works with hasMany associations that contain
* translations.
*
* @return void
*/
public function testSaveAllTranslatedAssociations() {
$this->loadFixtures('Translate', 'TranslateArticle', 'TranslatedItem', 'TranslatedArticle', 'User');
$Model = new TranslatedArticle();
$Model->locale = 'eng';
$data = array(
'TranslatedArticle' => array(
'id' => 4,
'user_id' => 1,
'published' => 'Y',
'title' => 'Title (eng) #1',
'body' => 'Body (eng) #1'
),
'TranslatedItem' => array(
array(
'slug' => '',
'title' => 'Nuevo leyenda #1',
'content' => 'Upraveny obsah #1'
),
array(
'slug' => '',
'title' => 'New Title #2',
'content' => 'New Content #2'
),
)
);
$result = $Model->saveAll($data);
$this->assertTrue($result);
$result = $Model->TranslatedItem->find('all', array(
'conditions' => array('translated_article_id' => $Model->id)
));
$this->assertCount(2, $result);
$this->assertEquals($data['TranslatedItem'][0]['title'], $result[0]['TranslatedItem']['title']);
$this->assertEquals($data['TranslatedItem'][1]['title'], $result[1]['TranslatedItem']['title']);
}
/**
* testValidation method
*
@ -652,11 +749,13 @@ class TranslateBehaviorTest extends CakeTestCase {
$TestModel = new TranslatedItem();
$TestModel->locale = 'eng';
$TestModel->validate['title'] = '/Only this title/';
$data = array('TranslatedItem' => array(
'id' => 1,
'title' => array('eng' => 'New Title #1', 'deu' => 'Neue Titel #1', 'cze' => 'Novy Titulek #1'),
'content' => array('eng' => 'New Content #1', 'deu' => 'Neue Inhalt #1', 'cze' => 'Novy Obsah #1')
));
$data = array(
'TranslatedItem' => array(
'id' => 1,
'title' => array('eng' => 'New Title #1', 'deu' => 'Neue Titel #1', 'cze' => 'Novy Titulek #1'),
'content' => array('eng' => 'New Content #1', 'deu' => 'Neue Inhalt #1', 'cze' => 'Novy Obsah #1')
)
);
$TestModel->create();
$this->assertFalse($TestModel->save($data));
$this->assertEquals(array('This field cannot be left blank'), $TestModel->validationErrors['title']);
@ -739,7 +838,8 @@ class TranslateBehaviorTest extends CakeTestCase {
'slug' => 'first_translated',
'locale' => 'eng',
'title' => 'Another Title #1',
'content' => 'Another Content #1'
'content' => 'Another Content #1',
'translated_article_id' => 1,
)
);
$this->assertEquals($expected, $result);
@ -751,7 +851,7 @@ class TranslateBehaviorTest extends CakeTestCase {
* @return void
*/
public function testTranslateWithAssociations() {
$this->loadFixtures('TranslateArticle', 'TranslatedArticle', 'User', 'Comment', 'ArticlesTag', 'Tag');
$this->loadFixtures('TranslateArticle', 'TranslatedArticle', 'TranslatedItem', 'User', 'Comment', 'ArticlesTag', 'Tag');
$TestModel = new TranslatedArticle();
$TestModel->locale = 'eng';
@ -775,6 +875,23 @@ class TranslateBehaviorTest extends CakeTestCase {
'password' => '5f4dcc3b5aa765d61d8327deb882cf99',
'created' => '2007-03-17 01:16:23',
'updated' => '2007-03-17 01:18:31'
),
'TranslatedItem' => array(
array(
'id' => 1,
'translated_article_id' => 1,
'slug' => 'first_translated'
),
array(
'id' => 2,
'translated_article_id' => 1,
'slug' => 'second_translated'
),
array(
'id' => 3,
'translated_article_id' => 1,
'slug' => 'third_translated'
),
)
);
$this->assertEquals($expected, $result);
@ -854,7 +971,8 @@ class TranslateBehaviorTest extends CakeTestCase {
'slug' => 'first_translated',
'locale' => 'eng',
'content' => 'Content #1',
'title' => 'Title #1'
'title' => 'Title #1',
'translated_article_id' => 1,
));
$this->assertEquals($expected, $result);
}

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Model.Behavior
* @since CakePHP(tm) v 1.2.0.5330
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -6,14 +6,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Model.Behavior
* @since CakePHP(tm) v 1.2.0.5330
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -6,14 +6,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Model.Behavior
* @since CakePHP(tm) v 1.2.0.5330
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -6,14 +6,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Model.Behavior
* @since CakePHP(tm) v 1.2.0.5330
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -5,14 +5,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Model
* @since CakePHP(tm) v 1.2.0.5550
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -10,7 +10,7 @@
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Model
* @since CakePHP(tm) v 1.2.0.5550
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Model.Datasource
* @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

View file

@ -4,14 +4,14 @@
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The Open Group Test Suite License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Model.Datasource
* @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)

Some files were not shown because too many files have changed in this diff Show more