Merge branch '1.3' into 2.0

Conflicts:
	app/webroot/index.php
	cake/console/templates/skel/webroot/index.php
	cake/libs/cake_session.php
	cake/libs/controller/components/email.php
	cake/libs/controller/scaffold.php
	cake/libs/model/datasources/dbo/dbo_oracle.php
	cake/libs/model/model_behavior.php
	cake/libs/view/pages/home.ctp
	cake/tests/cases/libs/controller/components/acl.test.php
	cake/tests/cases/libs/file.test.php
This commit is contained in:
mark_story 2010-06-26 12:29:20 -04:00
commit 929bb5769e
84 changed files with 977 additions and 226 deletions

View file

@ -1,7 +1,7 @@
;<?php die() ?>
; SVN FILE: $Id$
;/**
; * Short description for file.
; * ACL configuration
; *
; *
; * PHP versions 4 and 5

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* Routes configuration
*
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* CSS helping functions
*
* PHP versions 4 and 5
*
@ -21,14 +21,16 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
header('HTTP/1.1 404 Not Found');
exit('File Not Found');
}
/**
* Enter description here...
* Ensure required classes are available.
*/
if (!class_exists('File')) {
uses('file');
}
/**
* Enter description here...
* Make clean CSS
*
* @param unknown_type $path
* @param unknown_type $name
@ -44,7 +46,7 @@ if (!class_exists('File')) {
return $output;
}
/**
* Enter description here...
* Write CSS cache
*
* @param unknown_type $path
* @param unknown_type $content

View file

@ -82,6 +82,3 @@
$Dispatcher = new Dispatcher();
$Dispatcher->dispatch();
}
if (Configure::read() > 0) {
echo "<!-- " . round(microtime(true) - $TIME_START, 4) . "s -->";
}

View file

@ -18,5 +18,5 @@
// @license MIT License (http://www.opensource.org/licenses/mit-license.php)
// +--------------------------------------------------------------------------------------------+ //
////////////////////////////////////////////////////////////////////////////////////////////////////
1.3.0
1.3.2

View file

@ -17,4 +17,4 @@
* @since CakePHP(tm) v 1.1.11.4062
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
return $config['Cake.version'] = '1.3.0';
return $config['Cake.version'] = '1.3.2';

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* Path configuration
*
* In this file you set paths to different directories used by Cake.
*

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* CakePHP Console Shell
*
* PHP versions 4 and 5
*

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* Internationalization Management Shell
*
* PHP versions 4 and 5
*

View file

@ -487,7 +487,7 @@ class ExtractTask extends Shell {
foreach ($this->__paths as $path) {
$Folder = new Folder($path);
$files = $Folder->findRecursive('.*\.(php|ctp|thtml|inc|tpl)', true);
$this->__files += $files;
$this->__files = array_merge($this->__files, $files);
}
}
}

View file

@ -54,7 +54,8 @@ class TemplateTask extends Shell {
protected function _findThemes() {
$paths = App::path('shells');
$core = array_pop($paths);
$core = preg_replace('#libs' . DS . '$#', '', $core);
$separator = DS === '/' ? '/' : '\\\\';
$core = preg_replace('#libs' . $separator . '$#', '', $core);
$paths[] = $core;
$Folder =& new Folder($core . 'templates' . DS . 'default');
$contents = $Folder->read();

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* Application level Controller
*
* This file is application-wide controller file. You can put all
* application-wide controller-related methods here.
@ -22,7 +22,7 @@
*/
/**
* Short description for class.
* Application Controller
*
* Add your application-wide methods in the class below, your controllers
* will inherit them.

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* Application level View Helper
*
* This file is application-wide helper file. You can put all
* application-wide helper-related methods here.

View file

@ -1,7 +1,7 @@
;<?php exit() ?>
; SVN FILE: $Id$
;/**
; * Short description for file.
; * ACL Configuration
; *
; *
; * PHP versions 4 and 5

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* Routes Configuration
*
* In this file, you set up routes to your controllers and their actions.
* Routes are very important mechanism that allows you to freely connect

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* CSS Functions
*
* PHP versions 4 and 5
*
@ -23,14 +23,14 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
}
/**
* Enter description here...
* Ensure required files are included
*/
if (!class_exists('File')) {
require LIBS . 'file.php';
}
/**
* Enter description here...
* Make clean CSS
*
* @param unknown_type $path
* @param unknown_type $name
@ -47,7 +47,7 @@ if (!class_exists('File')) {
}
/**
* Enter description here...
* Write CSS cache
*
* @param unknown_type $path
* @param unknown_type $content

View file

@ -82,6 +82,3 @@
$Dispatcher = new Dispatcher();
$Dispatcher->dispatch();
}
if (Configure::read() > 0) {
echo "<!-- " . round(microtime(true) - $TIME_START, 4) . "s -->";
}

View file

@ -161,7 +161,7 @@ class Dispatcher extends Object {
} else {
$controller->data = null;
}
if (array_key_exists('return', $this->params) && $this->params['return'] == 1) {
if (isset($this->params['return']) && $this->params['return'] == 1) {
$controller->autoRender = false;
}
if (!empty($this->params['bare'])) {

View file

@ -210,7 +210,11 @@ class FileEngine extends CacheEngine {
$now = time();
$threshold = $now - $this->settings['duration'];
}
$prefixLength = strlen($this->settings['prefix']);
while (($entry = $dir->read()) !== false) {
if (substr($entry, 0, $prefixLength) !== $this->settings['prefix']) {
continue;
}
if ($this->_setKey($entry) === false) {
continue;
}

View file

@ -95,7 +95,7 @@ class CakeLog {
*
* For an explaination of these parameters, see CakeLog::write()
*
* @param string $key The keyname for this logger, used to revmoe the logger later.
* @param string $key The keyname for this logger, used to remove the logger later.
* @param array $config Array of configuration information for the logger
* @return boolean success of configuration.
* @throws Exception

View file

@ -114,14 +114,6 @@ class CakeSession extends Object {
*/
public $id = null;
/**
* Session Started
*
* @var boolean
* @access protected
*/
protected $_started = false;
/**
* Hostname
*
@ -136,7 +128,7 @@ class CakeSession extends Object {
* @var ineteger
* @access public
*/
var $timeout = null;
public $timeout = null;
/**
* Constructor.
@ -214,7 +206,7 @@ class CakeSession extends Object {
session_write_close();
}
$this->__initSession();
$this->_started = $this->__startSession();
$this->__startSession();
return $this->started();
}
@ -225,7 +217,7 @@ class CakeSession extends Object {
* @return boolean True if session has been started.
*/
function started() {
if (isset($_SESSION) && $this->_started) {
if (isset($_SESSION) && session_id()) {
return true;
}
return false;
@ -456,29 +448,13 @@ class CakeSession extends Object {
*/
function __initSession() {
$iniSet = function_exists('ini_set');
if ($iniSet && env('HTTPS')) {
ini_set('session.cookie_secure', 1);
}
switch ($this->security) {
case 'high':
$this->cookieLifeTime = Configure::read('Session.timeout') * Security::inactiveMins();
if ($iniSet) {
ini_set('session.referer_check', $this->host);
}
break;
case 'medium':
$this->cookieLifeTime = Configure::read('Session.timeout') * Security::inactiveMins();
if ($iniSet) {
ini_set('session.referer_check', $this->host);
}
break;
case 'low':
default:
$this->cookieLifeTime = Configure::read('Session.timeout') * Security::inactiveMins();
break;
if ($iniSet && ($this->security === 'high' || $this->security === 'medium')) {
ini_set('session.referer_check', $this->host);
}
$this->cookieLifeTime = Configure::read('Session.timeout') * Security::inactiveMins();
switch (Configure::read('Session.save')) {
case 'cake':
@ -781,5 +757,5 @@ class CakeSession extends Object {
$return = $model->deleteAll(array($model->alias . ".expires <" => $expires), false, false);
return $return;
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* Application level Controller
*
* This file is application-wide controller file. You can put all
* application-wide controller-related methods here.

View file

@ -467,7 +467,7 @@ class AuthComponent extends Object {
'loginAction' => array(
'controller' => Inflector::underscore(Inflector::pluralize($model)),
'action' => 'login',
'plugin' => $plugin,
'plugin' => Inflector::underscore($plugin),
),
'sessionKey' => 'Auth.' . $model,
'logoutRedirect' => $this->loginAction,

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* Cookie Component
*
* PHP versions 4 and 5
*

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* Email Component
*
* PHP versions 4 and 5
*
@ -228,9 +228,7 @@ class EmailComponent extends Object{
* @access public
* @link http://book.cakephp.org/view/1290/Sending-A-Message-Using-SMTP
*/
public $smtpOptions = array(
'port'=> 25, 'host' => 'localhost', 'timeout' => 30
);
public $smtpOptions = array();
/**
* Placeholder for any errors that might happen with the
@ -355,7 +353,11 @@ class EmailComponent extends Object{
}
}
$message = $this->_wrap($content);
if ($this->sendAs === 'text') {
$message = $this->_wrap($content);
} else {
$message = $this->_wrap($content, 998);
}
if ($this->template === null) {
$message = $this->_formatMessage($message);
@ -674,10 +676,11 @@ class EmailComponent extends Object{
* Wrap the message using EmailComponent::$lineLength
*
* @param string $message Message to wrap
* @param integer $lineLength Max length of line
* @return array Wrapped message
* @access private
* @access protected
*/
function _wrap($message) {
function _wrap($message, $lineLength = null) {
$message = $this->_strip($message, true);
$message = str_replace(array("\r\n","\r"), "\n", $message);
$lines = explode("\n", $message);
@ -688,11 +691,15 @@ class EmailComponent extends Object{
$this->lineLength = $this->_lineLength;
}
if (!$lineLength) {
$lineLength = $this->lineLength;
}
foreach ($lines as $line) {
if (substr($line, 0, 1) == '.') {
$line = '.' . $line;
}
$formatted = array_merge($formatted, explode("\n", wordwrap($line, $this->lineLength, "\n", true)));
$formatted = array_merge($formatted, explode("\n", wordwrap($line, $lineLength, "\n", true)));
}
$formatted[] = '';
return $formatted;
@ -785,7 +792,14 @@ class EmailComponent extends Object{
function _smtp() {
App::import('Core', array('CakeSocket'));
$this->__smtpConnection =& new CakeSocket(array_merge(array('protocol'=>'smtp'), $this->smtpOptions));
$defaults = array(
'host' => 'localhost',
'port' => 25,
'protocol' => 'smtp',
'timeout' => 30
);
$this->smtpOptions = array_merge($defaults, $this->smtpOptions);
$this->__smtpConnection =& new CakeSocket($this->smtpOptions);
if (!$this->__smtpConnection->connect()) {
$this->smtpError = $this->__smtpConnection->lastError();
@ -804,7 +818,7 @@ class EmailComponent extends Object{
$host = 'localhost';
}
if (!$this->_smtpSend("HELO {$host}", '250')) {
if (!$this->_smtpSend("EHLO {$host}", '250') && !$this->_smtpSend("HELO {$host}", '250')) {
return false;
}
@ -864,22 +878,34 @@ class EmailComponent extends Object{
}
/**
* Private method for sending data to SMTP connection
* Protected method for sending data to SMTP connection
*
* @param string $data data to be sent to SMTP server
* @param mixed $checkCode code to check for in server response, false to skip
* @return bool Success
* @access private
* @access protected
*/
function _smtpSend($data, $checkCode = '250') {
if (!is_null($data)) {
$this->__smtpConnection->write($data . "\r\n");
}
if ($checkCode !== false) {
$response = $this->__smtpConnection->read();
while ($checkCode !== false) {
$response = '';
$startTime = time();
while (substr($response, -2) !== "\r\n" && ((time() - $startTime) < $this->smtpOptions['timeout'])) {
$response .= $this->__smtpConnection->read();
}
if (substr($response, -2) !== "\r\n") {
$this->smtpError = 'timeout';
return false;
}
$response = end(explode("\r\n", rtrim($response, "\r\n")));
if (preg_match('/^(' . $checkCode . ')/', $response, $code)) {
return $code[0];
if (preg_match('/^(' . $checkCode . ')(.)/', $response, $code)) {
if ($code[2] === '-') {
continue;
}
return $code[1];
}
$this->smtpError = $response;
return false;

View file

@ -276,7 +276,7 @@ class RequestHandlerComponent extends Object {
$msg = $statusCode[$code];
$controller->header("HTTP/1.1 {$code} {$msg}");
}
echo $this->requestAction($url, array('return'));
echo $this->requestAction($url, array('return', 'bare' => false));
$this->_stop();
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* Security Component
*
* PHP versions 4 and 5
*
@ -18,8 +18,9 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', array('String', 'Security'));
/**
* Short description for file.
* SecurityComponent
*
* @package cake
* @subpackage cake.cake.libs.controller.components

View file

@ -793,8 +793,11 @@ class Controller extends Object {
$errors = array();
foreach ($objects as $object) {
$this->{$object->alias}->set($object->data);
$errors = array_merge($errors, $this->{$object->alias}->invalidFields());
if (isset($this->{$object->alias})) {
$object =& $this->{$object->alias};
}
$object->set($object->data);
$errors = array_merge($errors, $object->invalidFields());
}
return $this->validationErrors = (!empty($errors) ? $errors : false);

View file

@ -542,11 +542,17 @@ if (!class_exists('ThemeView')) {
App::import('View', 'Theme');
}
/**
* ScaffoldView provides specific view file loading features for scaffolded views.
*
* @package cake.libs.view
*/
class ScaffoldView extends ThemeView {
/**
* Override _getViewFileName
* Override _getViewFileName Appends special scaffolding views in.
*
* @param string $name name of the view file to get.
* @return string action
*/
protected function _getViewFileName($name = null) {

View file

@ -178,7 +178,6 @@ class File {
while (!feof($this->handle)) {
$data .= fgets($this->handle, 4096);
}
$data = trim($data);
if ($this->lock !== null) {
flock($this->handle, LOCK_UN);
@ -186,7 +185,7 @@ class File {
if ($bytes === false) {
$this->close();
}
return $data;
return trim($data);
}
/**

View file

@ -957,7 +957,7 @@ class HttpSocket extends CakeSocket {
foreach ($cookies as $name => $cookie) {
$header[] = $name.'='.$this->_escapeToken($cookie['value'], array(';'));
}
$header = $this->_buildHeader(array('Cookie' => $header), 'pragmatic');
$header = $this->_buildHeader(array('Cookie' => implode('; ', $header)), 'pragmatic');
return $header;
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* Internationalization
*
* PHP versions 4 and 5
*

View file

@ -121,7 +121,7 @@ class Inflector {
'/(shoe|slave)s$/i' => '\1',
'/(o)es$/i' => '\1',
'/ouses$/' => 'ouse',
'/uses$/' => 'us',
'/([^a])uses$/' => '\1us',
'/([m|l])ice$/i' => '\1ouse',
'/(x|ch|ss|sh)es$/i' => '\1',
'/(m)ovies$/i' => '\1\2ovie',
@ -367,7 +367,10 @@ class Inflector {
} else {
$_this->{$var}[$rule] = array_merge($pattern, $_this->{$var}[$rule]);
}
unset($rules[$rule], $_this->{$var}['cache' . ucfirst($rule)], $_this->{$var}['merged'][$rule]);
unset($rules[$rule], $_this->{$var}['cache' . ucfirst($rule)]);
if (isset($_this->{$var}['merged'][$rule])) {
unset($_this->{$var}['merged'][$rule]);
}
if ($type === 'plural') {
$_this->_pluralized = $_this->_tableize = array();
} elseif ($type === 'singular') {

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* Localization
*
* PHP versions 4 and 5
*
@ -19,7 +19,7 @@
*/
/**
* Short description for file.
* Localization
*
* @package cake
* @subpackage cake.cake.libs

View file

@ -21,7 +21,7 @@
*/
/**
* Short description for file
* ACL behavior
*
* @package cake
* @subpackage cake.cake.libs.model.behaviors

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* Translate behavior
*
* PHP versions 4 and 5
*
@ -19,7 +19,7 @@
*/
/**
* Short description for file.
* Translate behavior
*
* @package cake
* @subpackage cake.cake.libs.model.behaviors
@ -29,6 +29,8 @@ class TranslateBehavior extends ModelBehavior {
/**
* Used for runtime configuration of model
*
* @var array
*/
public $runtime = array();
@ -45,7 +47,8 @@ class TranslateBehavior extends ModelBehavior {
* $config could be empty - and translations configured dynamically by
* bindTranslation() method
*
* @param array $config
* @param Model $model Model the behavior is being attached to.
* @param array $config Array of configuration information.
* @return mixed
*/
public function setup(&$model, $config = array()) {
@ -65,8 +68,9 @@ class TranslateBehavior extends ModelBehavior {
}
/**
* Callback
* Cleanup Callback unbinds bound translations and deletes setting information.
*
* @param Model $model Model being detached.
* @return void
*/
public function cleanup(&$model) {
@ -78,7 +82,8 @@ class TranslateBehavior extends ModelBehavior {
/**
* beforeFind Callback
*
* @param array $query
* @param Model $model Model find is being run on.
* @param array $query Array of Query parameters.
* @return array Modified query
*/
public function beforeFind(&$model, $query) {
@ -202,8 +207,9 @@ class TranslateBehavior extends ModelBehavior {
/**
* afterFind Callback
*
* @param array $results
* @param boolean $primary
* @param Model $model Model find was run on
* @param array $results Array of model results.
* @param boolean $primary Did the find originate on $model.
* @return array Modified results
*/
public function afterFind(&$model, $results, $primary) {
@ -246,6 +252,7 @@ class TranslateBehavior extends ModelBehavior {
/**
* beforeValidate Callback
*
* @param Model $model Model invalidFields was called on.
* @return boolean
*/
public function beforeValidate(&$model) {
@ -278,7 +285,8 @@ class TranslateBehavior extends ModelBehavior {
/**
* afterSave Callback
*
* @param boolean $created
* @param Model $model Model the callback is called on
* @param boolean $created Whether or not the save created a record.
* @return void
*/
public function afterSave(&$model, $created) {
@ -321,6 +329,7 @@ class TranslateBehavior extends ModelBehavior {
/**
* afterDelete Callback
*
* @param Model $model Model the callback was run on.
* @return void
*/
public function afterDelete(&$model) {
@ -332,6 +341,7 @@ class TranslateBehavior extends ModelBehavior {
/**
* Get selected locale for model
*
* @param Model $model Model the locale needs to be set/get on.
* @return mixed string or false
*/
protected function _getLocale(&$model) {
@ -348,8 +358,12 @@ class TranslateBehavior extends ModelBehavior {
}
/**
* Get instance of model for translations
* Get instance of model for translations.
*
* If the model has a translateModel property set, this will be used as the class
* name to find/use. If no translateModel property is found 'I18nModel' will be used.
*
* @param Model $model Model to get a translatemodel for.
* @return object
*/
public function &translateModel(&$model) {
@ -452,8 +466,9 @@ class TranslateBehavior extends ModelBehavior {
* Unbind translation for fields, optionally unbinds hasMany association for
* fake field
*
* @param object instance of model
* @param mixed string with field, or array(field1, field2=>AssocName, field3), or null for unbind all original translations
* @param object $model instance of model
* @param mixed $fields string with field, or array(field1, field2=>AssocName, field3), or null for
* unbind all original translations
* @return bool
*/
function unbindTranslation(&$model, $fields = null) {

View file

@ -241,7 +241,6 @@ class CakeSchema extends Object {
if (is_object($Object) && $Object->useTable !== false) {
$Object->setDataSource($connection);
$table = $db->fullTableName($Object, false);
if (in_array($table, $currentTables)) {
$key = array_search($table, $currentTables);
if (empty($tables[$table])) {
@ -258,7 +257,7 @@ class CakeSchema extends Object {
if (is_object($Object->$class)) {
$withTable = $db->fullTableName($Object->$class, false);
if (in_array($withTable, $currentTables)) {
$key = array_search($table, $currentTables);
$key = array_search($withTable, $currentTables);
$tables[$withTable] = $this->__columns($Object->$class);
$tables[$withTable]['indexes'] = $db->index($Object->$class);
$tables[$withTable]['tableParameters'] = $db->readTableParameters($withTable);
@ -444,7 +443,7 @@ class CakeSchema extends Object {
$tables = array();
foreach ($new as $table => $fields) {
if ($table == 'missing') {
break;
continue;
}
if (!array_key_exists($table, $old)) {
$tables[$table]['add'] = $fields;

View file

@ -272,9 +272,12 @@ class ConnectionManager extends Object {
if ($plugin) {
$filename = Inflector::underscore($classname);
} else {
$filename = $config['datasource'] . '_source';
$classname = Inflector::camelize(strtolower($filename));
$filename = Inflector::underscore($config['datasource']);
}
if (substr($filename, -7) != '_source') {
$filename .= '_source';
}
$classname = Inflector::camelize(strtolower($filename));
}
return compact('filename', 'classname', 'parent', 'plugin');
}

View file

@ -91,7 +91,7 @@ class DataSource extends Object {
public $endQuote = null;
/**
* Enter description here...
* Result
*
* @var array
* @access protected

View file

@ -19,7 +19,7 @@
*/
/**
* Short description for class.
* MS SQL layer for DBO
*
* Long description for class
*

View file

@ -507,9 +507,9 @@ class DboMysqlBase extends DboSource {
class DboMysql extends DboMysqlBase {
/**
* Enter description here...
* Datasource description
*
* @var unknown_type
* @var string
*/
public $description = "MySQL DBO Driver";
@ -727,7 +727,7 @@ class DboMysql extends DboMysqlBase {
while ($j < $numFields) {
$column = mysql_fetch_field($results, $j);
if (!empty($column->table) && strpos($column->name, '__') === false) {
if (!empty($column->table) && strpos($column->name, $this->virtualFieldSeparator) === false) {
$this->map[$index++] = array($column->table, $column->name);
} else {
$this->map[$index++] = array(0, $column->name);

View file

@ -30,9 +30,9 @@ App::import('Datasource', 'DboMysql');
class DboMysqli extends DboMysqlBase {
/**
* Enter description here...
* Datasource Description
*
* @var unknown_type
* @var string
*/
public $description = "Mysqli DBO Driver";

View file

@ -19,7 +19,7 @@
*/
/**
* Short description for class.
* Oracle layer for DBO.
*
* Long description for class
*
@ -29,17 +29,17 @@
class DboOracle extends DboSource {
/**
* Enter description here...
* Configuration options
*
* @var unknown_type
* @var array
* @access public
*/
public $config = array();
/**
* Enter description here...
* Alias
*
* @var unknown_type
* @var string
*/
public $alias = '';
@ -56,9 +56,9 @@ class DboOracle extends DboSource {
private $__transactionStarted = false;
/**
* Enter description here...
* Column definitions
*
* @var unknown_type
* @var array
* @access public
*/
public $columns = array(
@ -77,25 +77,25 @@ class DboOracle extends DboSource {
'inet' => array('name' => 'inet'));
/**
* Enter description here...
* Connection object
*
* @var unknown_type
* @var mixed
* @access protected
*/
public $connection;
/**
* Enter description here...
* Query limit
*
* @var unknown_type
* @var int
* @access protected
*/
protected $_limit = -1;
/**
* Enter description here...
* Query offset
*
* @var unknown_type
* @var int
* @access protected
*/
protected $_offset = 0;
@ -109,25 +109,25 @@ class DboOracle extends DboSource {
protected $_map;
/**
* Enter description here...
* Current Row
*
* @var unknown_type
* @var mixed
* @access protected
*/
protected $_currentRow;
/**
* Enter description here...
* Number of rows
*
* @var unknown_type
* @var int
* @access protected
*/
protected $_numRows;
/**
* Enter description here...
* Query results
*
* @var unknown_type
* @var mixed
* @access protected
*/
protected $_results;
@ -372,9 +372,10 @@ class DboOracle extends DboSource {
}
/**
* Enter description here...
* Fetch result row
*
* @return unknown
* @return array
* @access public
*/
public function fetchRow() {
if ($this->_currentRow >= $this->_numRows) {
@ -435,10 +436,11 @@ class DboOracle extends DboSource {
}
/**
* Enter description here...
* Create trigger
*
* @param unknown_type $table
* @return unknown
* @param string $table
* @return mixed
* @access public
*/
public function createTrigger($table) {
$sql = "CREATE OR REPLACE TRIGGER pk_$table" . "_trigger BEFORE INSERT ON $table FOR EACH ROW BEGIN SELECT pk_$table.NEXTVAL INTO :NEW.ID FROM DUAL; END;";

View file

@ -29,9 +29,9 @@
class DboSqlite extends DboSource {
/**
* Enter description here...
* Datasource Description
*
* @var unknown_type
* @var string
*/
public $description = "SQLite DBO Driver";

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* Dbo Source
*
* PHP versions 4 and 5
*
@ -97,6 +97,13 @@ class DboSource extends DataSource {
'rollback' => 'ROLLBACK'
);
/**
* Separator string for virtualField composition
*
* @var string
*/
public $virtualFieldSeparator = '__';
/**
* List of table engine specific parameters used on table creating
*
@ -422,10 +429,10 @@ class DboSource extends DataSource {
public function fetchVirtualField(&$result) {
if (isset($result[0]) && is_array($result[0])) {
foreach ($result[0] as $field => $value) {
if (strpos($field, '__') === false) {
if (strpos($field, $this->virtualFieldSeparator) === false) {
continue;
}
list($alias, $virtual) = explode('__', $field);
list($alias, $virtual) = explode($this->virtualFieldSeparator, $field);
if (!ClassRegistry::isKeySet($alias)) {
return;
@ -898,6 +905,7 @@ class DboSource extends DataSource {
}
if (!empty($ins)) {
$ins = array_unique($ins);
$fetch = $this->fetchAssociated($model, $query, $ins);
}
@ -929,10 +937,10 @@ class DboSource extends DataSource {
}
}
if (!empty($ins)) {
$ins = array_unique($ins);
if (count($ins) > 1) {
$query = str_replace('{$__cakeID__$}', '(' .implode(', ', $ins) .')', $query);
$query = str_replace('= (', 'IN (', $query);
$query = str_replace('= (', 'IN (', $query);
} else {
$query = str_replace('{$__cakeID__$}',$ins[0], $query);
}
@ -1033,7 +1041,6 @@ class DboSource extends DataSource {
$query = str_replace('{$__cakeID__$}', implode(', ', $ids), $query);
if (count($ids) > 1) {
$query = str_replace('= (', 'IN (', $query);
$query = str_replace('= (', 'IN (', $query);
}
return $this->fetchAll($query, $model->cacheQueries, $model->alias);
}
@ -1865,7 +1872,7 @@ class DboSource extends DataSource {
protected function _constructVirtualFields(&$model, $alias, $fields) {
$virtual = array();
foreach ($fields as $field) {
$virtualField = $this->name("{$alias}__{$field}");
$virtualField = $this->name($alias . $this->virtualFieldSeparator . $field);
$expression = $this->__quoteFields($model->getVirtualField($field));
$virtual[] = '(' .$expression . ") {$this->alias} {$virtualField}";
}
@ -2132,7 +2139,7 @@ class DboSource extends DataSource {
}
} elseif (is_array($value) && !empty($value) && !$valueInsert) {
$keys = array_keys($value);
if (array_keys($value) === array_values(array_keys($value))) {
if ($keys === array_values($keys)) {
$count = count($value);
if ($count === 1) {
$data = $this->__quoteFields($key) . ' = (';
@ -2362,6 +2369,9 @@ class DboSource extends DataSource {
}
}
continue;
} elseif (is_object($key) && isset($key->type) && $key->type === 'expression') {
$result[] = $key->value;
continue;
}
if (preg_match('/\\x20(ASC|DESC).*/i', $key, $_dir)) {
@ -2369,17 +2379,17 @@ class DboSource extends DataSource {
$key = preg_replace('/\\x20(ASC|DESC).*/i', '', $key);
}
$key = trim($key);
if (is_object($model) && $model->isVirtualField($key)) {
$key = '(' . $this->__quoteFields($model->getVirtualField($key)) . ')';
}
if (strpos($key, '.')) {
$key = preg_replace_callback('/([a-zA-Z0-9_]{1,})\\.([a-zA-Z0-9_]{1,})/', array(&$this, '__quoteMatchedField'), $key);
}
$key = trim($key);
if (!preg_match('/\s/', $key) && !strpos($key,'.')) {
if (is_object($model) && $model->isVirtualField($key)) {
$key = '('.$this->__quoteFields($model->getVirtualField($key)).')';
} else {
$key = $this->name($key);
}
if (!preg_match('/\s/', $key) && !strpos($key, '.')) {
$key = $this->name($key);
}
$key .= ' ' . trim($dir);
$result[] = $key;

View file

@ -26,7 +26,7 @@
App::import('Model', 'App');
/**
* Short description for file.
* ACL Node
*
*
* @package cake

View file

@ -1602,7 +1602,6 @@ class Model extends Object {
case ($options['validate'] === 'first'):
$options['validate'] = true;
$return = array();
continue;
break;
default:
if ($options['atomic']) {
@ -1616,6 +1615,10 @@ class Model extends Object {
break;
}
}
if ($options['atomic'] && !$validates) {
$db->rollback($this);
return false;
}
return $return;
}
$associations = $this->getAssociated();

View file

@ -80,7 +80,8 @@ class ModelBehavior extends Object {
*
* @param object $model Model using this behavior
* @param array $queryData Data used to execute this query, i.e. conditions, order, etc.
* @return boolean True if the operation should continue, false if it should abort
* @return mixed False if the operation should abort. An array will replace the value of $query.
* @access public
*/
public function beforeFind(&$model, $query) { }
@ -90,7 +91,8 @@ class ModelBehavior extends Object {
* @param object $model Model using this behavior
* @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
* @return mixed An array value will replace the value of $results - any other value will be ignored.
* @access public
*/
public function afterFind(&$model, $results, $primary) { }
@ -98,7 +100,8 @@ class ModelBehavior extends Object {
* Before validate callback
*
* @param object $model Model using this behavior
* @return boolean True if validate operation should continue, false to abort
* @return mixed False if the operation should abort. Any other result will continue.
* @access public
*/
public function beforeValidate(&$model) { }
@ -106,7 +109,8 @@ class ModelBehavior extends Object {
* Before save callback
*
* @param object $model Model using this behavior
* @return boolean True if the operation should continue, false if it should abort
* @return mixed False if the operation should abort. Any other result will continue.
* @access public
*/
public function beforeSave(&$model) { }
@ -123,7 +127,8 @@ class ModelBehavior extends Object {
*
* @param object $model Model using this behavior
* @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
* @return mixed False if the operation should abort. Any other result will continue.
* @access public
*/
public function beforeDelete(&$model, $cascade = true) { }
@ -167,7 +172,7 @@ class ModelBehavior extends Object {
case 5:
return $this->{$method}($model, $params[0], $params[1], $params[2], $params[3], $params[4]);
default:
array_unshift($params, $model);
$params = array_merge(array(&$model), $params);
return call_user_func_array(array(&$this, $method), $params);
break;
}
@ -467,7 +472,6 @@ class BehaviorCollection extends Object {
if (empty($this->_attached)) {
return true;
}
$_params = $params;
$options = array_merge(array('break' => false, 'breakOn' => array(null, false), 'modParams' => false), $options);
$count = count($this->_attached);

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* Core Security
*
* PHP versions 4 and 5
*

View file

@ -291,9 +291,10 @@ class Helper extends Object {
*
* And its value is one of:
*
* - 1
* - true
* - 'true'
* - '1' (string)
* - 1 (integer)
* - true (boolean)
* - 'true' (string)
*
* Then the value will be reset to be identical with key's name.
* If the value is not one of these 3, the parameter is not output.
@ -352,7 +353,7 @@ class Helper extends Object {
}
if (in_array($key, $minimizedAttributes)) {
if ($value === 1 || $value === true || $value === 'true' || $value == $key) {
if ($value === 1 || $value === true || $value === 'true' || $value === '1' || $value == $key) {
$attribute = sprintf($attributeFormat, $key, $key);
}
} else {

View file

@ -1,6 +1,6 @@
<?php
/**
* Short description for file.
* Application level View Helper
*
* This file is application-wide helper file. You can put all
* application-wide helper-related methods here.

View file

@ -304,6 +304,7 @@ class FormHelper extends AppHelper {
unset($options['default']);
$htmlAttributes = array_merge($options, $htmlAttributes);
$this->fields = array();
if (isset($this->params['_Token']) && !empty($this->params['_Token'])) {
$append .= $this->hidden('_Token.key', array(
'value' => $this->params['_Token']['key'], 'id' => 'Token' . mt_rand())
@ -680,9 +681,10 @@ class FormHelper extends AppHelper {
* - `after` - Content to place after the label + input.
* - `between` - Content to place between the label + input.
* - `format` - format template for element order. Any element that is not in the array, will not be in the output.
* Default input format order: array('before', 'label', 'between', 'input', 'after', 'error')
* Default checkbox format order: array('before', 'input', 'between', 'label', 'after', 'error')
* Hidden input will not be formatted
* - Default input format order: array('before', 'label', 'between', 'input', 'after', 'error')
* - Default checkbox format order: array('before', 'input', 'between', 'label', 'after', 'error')
* - Hidden input will not be formatted
* - Radio buttons cannot have the order of input and label elements controlled with these settings.
*
* @param string $fieldName This should be "Modelname.fieldname"
* @param array $options Each type of input takes different options.
@ -735,7 +737,7 @@ class FormHelper extends AppHelper {
$options['type'] = 'hidden';
}
}
if (preg_match('/_id$/', $fieldKey)) {
if (preg_match('/_id$/', $fieldKey) && $options['type'] !== 'hidden') {
$options['type'] = 'select';
}

View file

@ -69,7 +69,7 @@ class NumberHelper extends AppHelper {
*
* @param float $number A floating point number.
* @param integer $precision The precision of the returned number.
* @return float Enter description here...
* @return float Formatted float.
* @access public
* @link http://book.cakephp.org/view/1454/precision
*/

View file

@ -123,7 +123,7 @@ class TextHelper extends AppHelper {
'$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->link($matches[0], $matches[0],' . $options . ');'), $text);
return preg_replace_callback('#(?<!href="|">)(?<!http://|https://|ftp://|nntp://)(www\.[^\n\%\ <]+[^<\n\%\,\.\ <])(?<!\))#i',
create_function('$matches', '$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->link($matches[0], "http://" . strtolower($matches[0]),' . $options . ');'), $text);
create_function('$matches', '$Html = new HtmlHelper(); $Html->tags = $Html->loadConfig(); return $Html->link($matches[0], "http://" . $matches[0],' . $options . ');'), $text);
}
/**

View file

@ -21,7 +21,7 @@ if (Configure::read() == 0):
endif;
?>
<h2><?php echo sprintf(__('Release Notes for CakePHP %s.', true), Configure::version()); ?></h2>
<a href="http://cakephp.lighthouseapp.com/projects/42648/changelog-1-3-0"><?php echo __('Read the changelog'); ?> </a>
<a href="http://cakephp.lighthouseapp.com/projects/42648/changelog-1-3-2"><?php __('Read the changelog'); ?> </a>
<?php
if (Configure::read() > 0):
Debugger::checkSecurityKeys();
@ -106,7 +106,7 @@ You can also add some CSS styles for your pages at: APP/webroot/css.');
<p>
<?php
echo $this->Html->link(
sprintf('<strong>%s</strong>%s', __('new'), __('CakePHP 1.3 Docs')),
sprintf('<strong>%s</strong>%s', __('new', true), __('CakePHP 1.3 Docs', true)),
'http://book.cakephp.org/view/875/x1-3-Collection',
array('target' => '_blank', 'escape' => false)
);

View file

@ -35,7 +35,8 @@ class ThemeView extends View {
/**
* Constructor for ThemeView sets $this->theme.
*
* @param Controller $controller
* @param Controller $controller Controller object to be rendered.
* @param boolean $register Should the view be registered in the registry.
*/
function __construct(&$controller, $register = true) {
parent::__construct($controller, $register);
@ -45,7 +46,7 @@ class ThemeView extends View {
/**
* Return all possible paths to find view files in order
*
* @param string $plugin
* @param string $plugin The name of the plugin views are being found for.
* @param boolean $cached Set to true to force dir scan.
* @return array paths
* @access protected

View file

@ -152,4 +152,33 @@ class ExtractTaskTest extends CakeTestCase {
$Folder = new Folder($path);
$Folder->delete();
}
function getTests() {
return array('start', 'startCase', 'testExtractMultiplePaths', 'endCase', 'end');
}
/**
* test extract can read more than one path.
*
* @return void
*/
function testExtractMultiplePaths() {
$path = TMP . 'tests' . DS . 'extract_task_test';
new Folder($path . DS . 'locale', true);
$this->Task->interactive = false;
$this->Task->params['paths'] =
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'pages,' .
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'posts';
$this->Task->params['output'] = $path . DS;
$this->Task->Dispatch->expectNever('stderr');
$this->Task->Dispatch->expectNever('_stop');
$this->Task->execute();
$result = file_get_contents($path . DS . 'default.pot');
$pattern = '/msgid "Add User"/';
$this->assertPattern($pattern, $result);
}
}

View file

@ -627,8 +627,7 @@ array(
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
STRINGEND;
$this->assertPattern('/' . preg_quote($expected, '/') . '/', $result);
$this->assertPattern('/' . preg_quote(str_replace("\r\n", "\n", $expected), '/') . '/', $result);
}
/**

View file

@ -273,6 +273,34 @@ class FileEngineTest extends CakeTestCase {
Cache::config('default', array('engine' => 'File', 'path' => CACHE));
}
/**
* test that clear() doesn't wipe files not in the current engine's prefix.
*
* @return void
*/
function testClearWithPrefixes() {
$FileOne =& new FileEngine();
$FileOne->init(array(
'prefix' => 'prefix_one_',
'duration' => DAY
));
$FileTwo =& new FileEngine();
$FileTwo->init(array(
'prefix' => 'prefix_two_',
'duration' => DAY
));
$data1 = $data2 = $expected = 'content to cache';
$FileOne->write('key_one', $data1, DAY);
$FileTwo->write('key_two', $data2, DAY);
$this->assertEqual($FileOne->read('key_one'), $expected);
$this->assertEqual($FileTwo->read('key_two'), $expected);
$FileOne->clear(false);
$this->assertEqual($FileTwo->read('key_two'), $expected, 'secondary config was cleared by accident.');
}
/**
* testKeyPath method
*

View file

@ -175,6 +175,10 @@ class CakeSessionTest extends CakeTestCase {
$_SESSION = null;
$this->assertFalse($this->Session->started());
$this->assertTrue($this->Session->start());
$session = new CakeSession(null, false);
$this->assertTrue($session->started());
unset($session);
}
/**

View file

@ -114,6 +114,14 @@ class FixtureImportTestModel extends Model {
public $useTable = 'fixture_tests';
public $useDbConfig = 'test_suite';
}
class FixturePrefixTest extends Model {
public $name = 'FixturePrefix';
public $useTable = '_tests';
public $tablePrefix = 'fixture';
public $useDbConfig = 'test_suite';
}
Mock::generate('DboSource', 'FixtureMockDboSource');
/**
@ -162,7 +170,14 @@ class CakeTestFixtureTest extends CakeTestCase {
$Fixture->primaryKey = 'my_random_key';
$Fixture->init();
$this->assertEqual($Fixture->primaryKey, 'my_random_key');
}
/**
* test that init() correctly sets the fixture table when the connection or model have prefixes defined.
*
* @return void
*/
function testInitDbPrefix() {
$this->_initDb();
$Source =& new CakeTestFixtureTestFixture();
$Source->create($this->db);
@ -194,6 +209,30 @@ class CakeTestFixtureTest extends CakeTestCase {
$Source->drop($this->db);
}
/**
* test init with a model that has a tablePrefix declared.
*
* @return void
*/
function testInitModelTablePrefix() {
$this->_initDb();
$Source =& new CakeTestFixtureTestFixture();
$Source->create($this->db);
$Source->insert($this->db);
$Fixture =& new CakeTestFixtureImportFixture();
unset($Fixture->table);
$Fixture->fields = $Fixture->records = null;
$Fixture->import = array('model' => 'FixturePrefixTest', 'connection' => 'test_suite', 'records' => false);
$Fixture->init();
$this->assertEqual($Fixture->table, 'fixture_tests');
$keys = array_flip(ClassRegistry::keys());
$this->assertFalse(array_key_exists('fixtureimporttestmodel', $keys));
$Source->drop($this->db);
}
/**
* testImport
*

View file

@ -1431,6 +1431,16 @@ class AuthTest extends CakeTestCase {
$this->assertEqual($user, $expected);
$sessionKey = $this->Controller->Auth->sessionKey;
$this->assertEqual('Auth.TestPluginAuthUser', $sessionKey);
$this->Controller->Auth->loginAction = null;
$this->Controller->Auth->__setDefaults();
$loginAction = $this->Controller->Auth->loginAction;
$expected = array(
'controller' => 'test_plugin_auth_users',
'action' => 'login',
'plugin' => 'test_plugin'
);
$this->assertEqual($loginAction, $expected);
// Reverting changes
Cache::delete('object_map', '_cake_core_');
@ -1456,7 +1466,7 @@ class AuthTest extends CakeTestCase {
$Dispatcher =& new Dispatcher();
$Dispatcher->dispatch('/ajax_auth/add', array('return' => 1));
$result = ob_get_clean();
$this->assertEqual("Ajax!\nthis is the test element", $result);
$this->assertEqual("Ajax!\nthis is the test element", str_replace("\r\n", "\n", $result));
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
}

View file

@ -109,6 +109,16 @@ class EmailTestComponent extends EmailComponent {
return $this->__message;
}
/**
* Convenience getter for testing.
*
* @access protected
* @return string
*/
function _getMessage() {
return $this->__message;
}
/**
* Convenience method for testing.
*
@ -234,6 +244,30 @@ class EmailComponentTest extends CakeTestCase {
return str_replace(array("\r\n", "\r"), "\n", $string);
}
/**
* testSmtpConfig method
*
* @access public
* @return void
*/
function testSmtpConfig() {
$this->Controller->EmailTest->delivery = 'smtp';
$this->Controller->EmailTest->smtpOptions = array();
$this->Controller->EmailTest->send('anything');
$config = array(
'host' => 'localhost',
'port' => 25,
'protocol' => 'smtp',
'timeout' => 30
);
$this->assertEqual($config, $this->Controller->EmailTest->smtpOptions);
$this->Controller->EmailTest->smtpOptions = array('port' => 80);
$this->Controller->EmailTest->send('anything');
$config['port'] = 80;
$this->assertEqual($config, $this->Controller->EmailTest->smtpOptions);
}
/**
* testBadSmtpSend method
*
@ -295,6 +329,62 @@ TEMPDOC;
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
}
/**
* testSmtpEhlo method
*
* @access public
* @return void
*/
function testSmtpEhlo() {
if (!$this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) {
return;
}
$connection =& new CakeSocket(array('protocol'=>'smtp', 'host' => 'localhost', 'port' => 25));
$this->Controller->EmailTest->setConnectionSocket($connection);
$this->Controller->EmailTest->smtpOptions['timeout'] = 10;
$this->assertTrue($connection->connect());
$this->assertTrue($this->Controller->EmailTest->smtpSend(null, '220') !== false);
$this->skipIf($this->Controller->EmailTest->smtpSend('EHLO locahost', '250') === false, '%s do not support EHLO.');
$connection->disconnect();
$this->Controller->EmailTest->to = 'postmaster@localhost';
$this->Controller->EmailTest->from = 'noreply@example.com';
$this->Controller->EmailTest->subject = 'Cake SMTP test';
$this->Controller->EmailTest->replyTo = 'noreply@example.com';
$this->Controller->EmailTest->template = null;
$this->Controller->EmailTest->delivery = 'smtp';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->Controller->EmailTest->_debug = true;
$this->Controller->EmailTest->sendAs = 'text';
$expect = <<<TEMPDOC
<pre>Host: localhost
Port: 25
Timeout: 30
To: postmaster@localhost
From: noreply@example.com
Subject: Cake SMTP test
Header:
To: postmaster@localhost
From: noreply@example.com
Reply-To: noreply@example.com
Subject: Cake SMTP test
X-Mailer: CakePHP Email Component
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bitParameters:
Message:
This is the body of the message
</pre>
TEMPDOC;
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
}
/**
* testSmtpSendMultipleTo method
@ -545,6 +635,7 @@ TEXTBLOC;
function testSmtpSendSocket() {
$this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost');
$this->Controller->EmailTest->smtpOptions['timeout'] = 10;
$socket =& new CakeSocket(array_merge(array('protocol'=>'smtp'), $this->Controller->EmailTest->smtpOptions));
$this->Controller->EmailTest->setConnectionSocket($socket);
@ -994,4 +1085,35 @@ HTMLBLOC;
$this->assertNoPattern('/Message-ID:/', $result);
}
/**
* testSendMessage method
*
* @access public
* @return void
*/
function testSendMessage() {
$this->Controller->EmailTest->delivery = 'getMessage';
$this->Controller->EmailTest->lineLength = 70;
$text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';
$this->Controller->EmailTest->sendAs = 'text';
$result = $this->Controller->EmailTest->send($text);
$expected = array(
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do',
'eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'',
''
);
$this->assertEqual($expected, $result);
$text = 'Lorem ipsum dolor sit amet, <b>consectetur</b> adipisicing elit, sed do <span>eiusmod tempor</span> incididunt ut labore et dolore magna aliqua.';
$this->Controller->EmailTest->sendAs = 'html';
$result = $this->Controller->EmailTest->send($text);
$expected = array(
$text,
'',
''
);
$this->assertEqual($expected, $result);
}
}

View file

@ -79,6 +79,18 @@ class RequestHandlerTestController extends Controller {
echo "one: $one two: $two";
$this->autoRender = false;
}
/**
* test method for testing layout rendering when isAjax()
*
* @return void
*/
function ajax2_layout() {
if ($this->autoLayout) {
$this->layout = 'ajax2';
}
$this->destination();
}
}
/**
@ -592,6 +604,34 @@ class RequestHandlerComponentTest extends CakeTestCase {
App::build();
}
/**
* test that ajax requests involving redirects don't force no layout
* this would cause the ajax layout to not be rendered.
*
* @return void
*/
function testAjaxRedirectAsRequestActionStillRenderingLayout() {
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
$this->_init();
App::build(array(
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
), true);
$this->Controller->RequestHandler = new NoStopRequestHandler($this);
$this->Controller->RequestHandler->expectOnce('_stop');
ob_start();
$this->Controller->RequestHandler->beforeRedirect(
$this->Controller, array('controller' => 'request_handler_test', 'action' => 'ajax2_layout')
);
$result = ob_get_clean();
$this->assertPattern('/posts index/', $result, 'RequestAction redirect failed.');
$this->assertPattern('/Ajax!/', $result, 'Layout was not rendered.');
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
App::build();
}
/**
* test that the beforeRedirect callback properly converts
* array urls into their correct string ones, and adds base => false so
@ -604,7 +644,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
Router::setRequestInfo(array(
array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'named' => array(), 'form' => array(), 'url' => array('url' => 'accounts/'), 'bare' => 0),
array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'named' => array(), 'form' => array(), 'url' => array('url' => 'accounts/')),
array('base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/')
));

View file

@ -1226,7 +1226,7 @@ class ControllerTest extends CakeTestCase {
$TestController->ControllerComment->invalidate('some_field', 'error_message');
$TestController->ControllerComment->invalidate('some_field2', 'error_message2');
$comment = new ControllerComment;
$comment =& new ControllerComment();
$comment->set('someVar', 'data');
$result = $TestController->validateErrors($comment);
$expected = array('some_field' => 'error_message', 'some_field2' => 'error_message2');
@ -1234,6 +1234,23 @@ class ControllerTest extends CakeTestCase {
$this->assertEqual($TestController->validate($comment), 2);
}
/**
* test that validateErrors works with any old model.
*
* @return void
*/
function testValidateErrorsOnArbitraryModels() {
$TestController =& new TestController();
$Post = new ControllerPost();
$Post->validate = array('title' => 'notEmpty');
$Post->set('title', '');
$result = $TestController->validateErrors($Post);
$expected = array('title' => 'This field cannot be left blank');
$this->assertEqual($result, $expected);
}
/**
* testPostConditions method
*

View file

@ -104,6 +104,9 @@ class FileTest extends CakeTestCase {
* @return void
*/
function testRead() {
$file = __FILE__;
$this->File =& new File($file);
$result = $this->File->read();
$expecting = file_get_contents(__FILE__);
$this->assertEqual($result, $expecting);
@ -112,7 +115,7 @@ class FileTest extends CakeTestCase {
$this->File->lock = true;
$result = $this->File->read();
$expecting = file_get_contents(__FILE__);
$this->assertEqual($result, $expecting);
$this->assertEqual($result, trim($expecting));
$this->File->lock = null;
$data = $expecting;
@ -445,7 +448,7 @@ class FileTest extends CakeTestCase {
* @return void
*/
function _getTmpFile($paintSkip = true) {
$tmpFile = TMP.'tests'.DS.'cakephp.file.test.tmp';
$tmpFile = TMP . 'tests' . DS . 'cakephp.file.test.tmp';
if (is_writable(dirname($tmpFile)) && (!file_exists($tmpFile) || is_writable($tmpFile))) {
return $tmpFile;
};
@ -454,7 +457,7 @@ class FileTest extends CakeTestCase {
$caller = 'test';
if (function_exists('debug_backtrace')) {
$trace = debug_backtrace();
$caller = $trace[1]['function'].'()';
$caller = $trace[1]['function'] . '()';
}
$assertLine = new SimpleStackTrace(array(__FUNCTION__));
$assertLine = $assertLine->traceMethod();

View file

@ -1389,7 +1389,7 @@ class HttpSocketTest extends CakeTestCase {
'path' => '/accounts'
)
);
$expect = "Cookie: foo=bar\r\nCookie: people=jim,jack,johnny\";\"\r\n";
$expect = "Cookie: foo=bar; people=jim,jack,johnny\";\"\r\n";
$result = $this->Socket->buildCookies($cookies);
$this->assertEqual($result, $expect);
}

View file

@ -42,16 +42,6 @@ class InflectorTest extends CakeTestCase {
*/
public $Inflector = null;
/**
* setUp method
*
* @access public
* @return void
*/
function setUp() {
$this->Inflector = Inflector::getInstance();
}
/**
* testInstantiation method
*
@ -59,7 +49,8 @@ class InflectorTest extends CakeTestCase {
* @return void
*/
function testInstantiation() {
$this->assertEqual(Inflector::getInstance(), $this->Inflector);
$Inflector =& Inflector::getInstance();
$this->assertEqual(Inflector::getInstance(), $Inflector);
}
/**
@ -119,6 +110,8 @@ class InflectorTest extends CakeTestCase {
$this->assertEqual(Inflector::singularize('genetic_analyses'), 'genetic_analysis');
$this->assertEqual(Inflector::singularize('doctor_diagnoses'), 'doctor_diagnosis');
$this->assertEqual(Inflector::singularize('parantheses'), 'paranthesis');
$this->assertEqual(Inflector::singularize('Causes'), 'Cause');
$this->assertEqual(Inflector::singularize('colossuses'), 'colossus');
$this->assertEqual(Inflector::singularize(''), '');
}
@ -336,6 +329,19 @@ class InflectorTest extends CakeTestCase {
$this->assertEqual(Inflector::humanize('file_systems'), 'File Systems');
}
/**
* This test if run in isolation should not cause errors in PHP4.
*
* @return void
*/
function testRulesNoErrorPHP4() {
Inflector::rules('plural', array(
'rules' => array(),
'irregular' => array(),
'uninflected' => array('pays')
));
}
/**
* testCustomPluralRule method
*
@ -452,13 +458,4 @@ class InflectorTest extends CakeTestCase {
$this->assertEqual(Inflector::singularize('Atlas'), 'Atlas');
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
unset($this->Inflector);
}
}

View file

@ -194,6 +194,10 @@ class L10nTest extends CakeTestCase {
$result = $l10n->map(array('nld', 'nl'));
$expected = array('nld' => 'nl', 'nl' => 'dut');
$this->assertEqual($result, $expected);
$result = $l10n->map(array('nld'));
$expected = array('nld' => 'nl');
$this->assertEqual($result, $expected);
$result = $l10n->map(array('eng', 'en'));
$expected = array('eng' => 'en', 'en' => 'eng');
@ -745,6 +749,18 @@ class L10nTest extends CakeTestCase {
);
$this->assertEqual($result, $expected);
$result = $l10n->catalog('nl');
$expected = array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr');
$this->assertEqual($result, $expected);
$result = $l10n->catalog('nld');
$expected = array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr');
$this->assertEqual($result, $expected);
$result = $l10n->catalog('dut');
$expected = array('language' => 'Dutch (Standard)', 'locale' => 'dut', 'localeFallback' => 'dut', 'charset' => 'utf-8', 'direction' => 'ltr');
$this->assertEqual($result, $expected);
$result = $l10n->catalog(array('nb'));
$expected = array(
'nb' => array('language' => 'Norwegian Bokmal', 'locale' => 'nob', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr')

View file

@ -460,19 +460,19 @@ class SchemaPrefixAuthUser extends CakeTestModel {
*
* @var string
*/
var $name = 'SchemaPrefixAuthUser';
public $name = 'SchemaPrefixAuthUser';
/**
* table prefix
*
* @var string
*/
var $tablePrefix = 'auth_';
public $tablePrefix = 'auth_';
/**
* useTable
*
* @var string
*/
var $useTable = 'users';
public $useTable = 'users';
}
/**
@ -575,6 +575,13 @@ class CakeSchemaTest extends CakeTestCase {
'models' => array('SchemaPost')
));
$this->assertFalse(isset($read['tables']['missing']['posts']), 'Posts table was not read from tablePrefix %s');
$read = $this->Schema->read(array(
'connection' => 'test_suite',
'name' => 'TestApp',
'models' => array('SchemaComment', 'SchemaTag', 'SchemaPost')
));
$this->assertFalse(isset($read['tables']['missing']['posts_tags']), 'Join table marked as missing %s');
}
/**
@ -743,6 +750,45 @@ class CakeSchemaTest extends CakeTestCase {
),
);
$this->assertEqual($expected, $compare);
$tables = array(
'missing' => array(
'categories' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'),
'created' => array('type' => 'datetime', 'null' => false, 'default' => NULL),
'modified' => array('type' => 'datetime', 'null' => false, 'default' => NULL),
'name' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 100),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)),
'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'MyISAM')
)
),
'ratings' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'),
'foreign_key' => array('type' => 'integer', 'null' => false, 'default' => NULL),
'model' => array('type' => 'varchar', 'null' => false, 'default' => NULL),
'value' => array('type' => 'float', 'null' => false, 'length' => '5,2', 'default' => NULL),
'created' => array('type' => 'datetime', 'null' => false, 'default' => NULL),
'modified' => array('type' => 'datetime', 'null' => false, 'default' => NULL),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)),
'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'MyISAM')
)
);
$compare = $New->compare($this->Schema, $tables);
$expected = array(
'ratings' => array(
'add' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'),
'foreign_key' => array('type' => 'integer', 'null' => false, 'default' => NULL),
'model' => array('type' => 'varchar', 'null' => false, 'default' => NULL),
'value' => array('type' => 'float', 'null' => false, 'length' => '5,2', 'default' => NULL),
'created' => array('type' => 'datetime', 'null' => false, 'default' => NULL),
'modified' => array('type' => 'datetime', 'null' => false, 'default' => NULL),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)),
'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'MyISAM')
)
)
);
$this->assertEqual($expected, $compare);
}
/**

View file

@ -276,4 +276,65 @@ class ConnectionManagerTest extends CakeTestCase {
$source = ConnectionManager::create(null, $config);
$this->assertEqual($source, null);
}
/**
* testConnectionData method
*
* @access public
* @return void
*/
function testConnectionData() {
App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
'datasources' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS . 'datasources' . DS)
));
$expected = array(
'filename' => 'test2_source',
'classname' => 'Test2Source',
'parent' => '',
'plugin' => ''
);
ConnectionManager::create('connection1', array('datasource' => 'Test2'));
$connections = ConnectionManager::enumConnectionObjects();
$this->assertEqual($expected, $connections['connection1']);
ConnectionManager::create('connection2', array('datasource' => 'Test2Source'));
$connections = ConnectionManager::enumConnectionObjects();
$this->assertEqual($expected, $connections['connection2']);
ConnectionManager::create('connection3', array('datasource' => 'TestPlugin.Test'));
$connections = ConnectionManager::enumConnectionObjects();
$expected['filename'] = 'test_source';
$expected['classname'] = 'TestSource';
$expected['plugin'] = 'TestPlugin';
$this->assertEqual($expected, $connections['connection3']);
ConnectionManager::create('connection4', array('datasource' => 'TestPlugin.TestSource'));
$connections = ConnectionManager::enumConnectionObjects();
$this->assertEqual($expected, $connections['connection4']);
ConnectionManager::create('connection5', array('datasource' => 'Test2Other'));
$connections = ConnectionManager::enumConnectionObjects();
$expected['filename'] = 'test2_other_source';
$expected['classname'] = 'Test2OtherSource';
$expected['plugin'] = '';
$this->assertEqual($expected, $connections['connection5']);
ConnectionManager::create('connection6', array('datasource' => 'Test2OtherSource'));
$connections = ConnectionManager::enumConnectionObjects();
$this->assertEqual($expected, $connections['connection6']);
ConnectionManager::create('connection7', array('datasource' => 'TestPlugin.TestOther'));
$connections = ConnectionManager::enumConnectionObjects();
$expected['filename'] = 'test_other_source';
$expected['classname'] = 'TestOtherSource';
$expected['plugin'] = 'TestPlugin';
$this->assertEqual($expected, $connections['connection7']);
ConnectionManager::create('connection8', array('datasource' => 'TestPlugin.TestOtherSource'));
$connections = ConnectionManager::enumConnectionObjects();
$this->assertEqual($expected, $connections['connection8']);
}
}

View file

@ -753,4 +753,22 @@ class DboMysqlTest extends CakeTestCase {
$this->assertEqual($result, 'cp1250');
}
/**
* test that changing the virtualFieldSeparator allows for __ fields.
*
* @return void
*/
function testVirtualFieldSeparators() {
$model =& new CakeTestModel(array('table' => 'binary_tests', 'ds' => 'test_suite', 'name' => 'BinaryTest'));
$model->virtualFields = array(
'other__field' => 'SUM(id)'
);
$this->db->virtualFieldSeparator = '_$_';
$result = $this->db->fields($model, null, array('data', 'other__field'));
$expected = array('`BinaryTest`.`data`', '(SUM(id)) AS BinaryTest_$_other__field');
$this->assertEqual($result, $expected);
}
}

View file

@ -2966,6 +2966,19 @@ class DboSourceTest extends CakeTestCase {
);
$this->assertEqual($result, $expected);
}
/**
* test that order() will accept objects made from DboSource::expression
*
* @return void
*/
function testOrderWithExpression() {
$expression = $this->testDb->expression("CASE Sample.id WHEN 1 THEN 'Id One' ELSE 'Other Id' END AS case_col");
$result = $this->testDb->order($expression);
$expected = " ORDER BY CASE Sample.id WHEN 1 THEN 'Id One' ELSE 'Other Id' END AS case_col";
$this->assertEqual($result, $expected);
}
/**
* testMergeAssociations method
*
@ -4302,7 +4315,7 @@ class DboSourceTest extends CakeTestCase {
' WHERE Article.id = ' . $this->db->fullTableName('comments') . '.article_id'
);
$conditions = array('two' => 2);
$result = $this->db->conditions($conditions,true,false,$Article);
$result = $this->db->conditions($conditions, true, false, $Article);
$expected = '(1 + 1) = 2';
$this->assertEqual($expected, $result);
@ -4339,6 +4352,11 @@ class DboSourceTest extends CakeTestCase {
$result = $this->db->order($order, 'ASC', $Article);
$expected = ' ORDER BY (1 + 1) ASC, (NOW()) ASC';
$this->assertEqual($expected, $result);
$order = array('Article.two', 'Article.this_moment');
$result = $this->db->order($order, 'ASC', $Article);
$expected = ' ORDER BY (1 + 1) ASC, (NOW()) ASC';
$this->assertEqual($expected, $result);
}
/**
@ -4407,4 +4425,19 @@ class DboSourceTest extends CakeTestCase {
$expected = " GROUP BY (YEAR(`Article`.`created`))";
$this->assertEqual($expected, $result);
}
/**
* test the permutations of fullTableName()
*
* @return void
*/
function testFullTablePermutations() {
$Article =& ClassRegistry::init('Article');
$result = $this->testDb->fullTableName($Article, false);
$this->assertEqual($result, 'articles');
$Article->tablePrefix = 'tbl_';
$result = $this->testDb->fullTableName($Article, false);
$this->assertEqual($result, 'tbl_articles');
}
}

View file

@ -7221,15 +7221,15 @@ class ModelReadTest extends BaseModelTest {
$dbo =& $Post->getDataSource();
$Post->virtualFields = array('other_field' => 'Post.id + 1');
$result = $Post->find('first',array(
$result = $Post->find('first', array(
'conditions' => array('other_field' => 3),
'limit' => 1
));
$this->assertEqual($result['Post']['id'], 2);
$Post->virtualFields = array('other_field' => 'Post.id + 1');
$result = $Post->find('all',array(
'fields' => array($dbo->calculate($Post, 'max',array('other_field')))
$result = $Post->find('all', array(
'fields' => array($dbo->calculate($Post, 'max', array('other_field')))
));
$this->assertEqual($result[0][0]['other_field'], 4);

View file

@ -3032,6 +3032,34 @@ class ModelWriteTest extends BaseModelTest {
), array('validate' => 'only'));
}
/**
* test saveAll with transactions and ensure there is no missing rollback.
*
* @return void
*/
function testSaveAllTransactionNoRollback() {
$this->loadFixtures('Post');
Mock::generate('DboSource', 'MockTransactionDboSource');
$db = ConnectionManager::create('mock_transaction', array(
'datasource' => 'MockTransactionDbo',
));
$db->expectOnce('rollback');
$Post =& new Post();
$Post->useDbConfig = 'mock_transaction';
$Post->validate = array(
'title' => array('rule' => array('notEmpty'))
);
$data = array(
array('author_id' => 1, 'title' => 'New Fourth Post'),
array('author_id' => 1, 'title' => '')
);
$Post->saveAll($data, array('atomic' => true));
}
/**
* testSaveAllTransaction method
*

View file

@ -162,6 +162,21 @@ class HelperTestPostsTag extends Model {
}
}
class TestHelper extends Helper {
/**
* expose a method as public
*
* @param string $options
* @param string $exclude
* @param string $insertBefore
* @param string $insertAfter
* @return void
*/
function parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) {
return $this->_parseAttributes($options, $exclude, $insertBefore, $insertAfter);
}
}
/**
* HelperTest class
*
@ -720,4 +735,23 @@ class HelperTest extends CakeTestCase {
Configure::write('App.www_root', $webRoot);
}
/**
* test parsing attributes.
*
* @return void
*/
function testParseAttributeCompact() {
$helper =& new TestHelper();
$compact = array('compact', 'checked', 'declare', 'readonly', 'disabled',
'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize');
foreach ($compact as $attribute) {
foreach (array('true', true, 1, '1', $attribute) as $value) {
$attrs = array($attribute => $value);
$expected = ' ' . $attribute . '="' . $attribute . '"';
$this->assertEqual($helper->parseAttributes($attrs), $expected, '%s Failed on ' . $value);
}
}
}
}

View file

@ -313,6 +313,7 @@ class UserForm extends CakeTestModel {
'other' => array('type' => 'text', 'null' => true, 'default' => null, 'length' => null),
'stuff' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 10),
'something' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 255),
'active' => array('type' => 'boolean', 'null' => false, 'default' => false),
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
);
@ -750,6 +751,17 @@ class FormHelperTest extends CakeTestCase {
$this->assertTags($result, $expected);
}
/**
* test that create() clears the fields property so it starts fresh
*
* @return void
*/
function testCreateClearingFields() {
$this->Form->fields = array('model_id');
$this->Form->create('Contact');
$this->assertEqual($this->Form->fields, array());
}
/**
* Tests form hash generation with model-less data
*
@ -1829,6 +1841,41 @@ class FormHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
}
/**
* test input() with checkbox creation
*
* @return void
*/
function testInputCheckbox() {
$result = $this->Form->input('User.active', array('label' => false, 'checked' => true));
$expected = array(
'div' => array('class' => 'input checkbox'),
'input' => array('type' => 'hidden', 'name' => 'data[User][active]', 'value' => '0', 'id' => 'UserActive_'),
array('input' => array('type' => 'checkbox', 'name' => 'data[User][active]', 'value' => '1', 'id' => 'UserActive', 'checked' => 'checked')),
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('User.active', array('label' => false, 'checked' => 1));
$expected = array(
'div' => array('class' => 'input checkbox'),
'input' => array('type' => 'hidden', 'name' => 'data[User][active]', 'value' => '0', 'id' => 'UserActive_'),
array('input' => array('type' => 'checkbox', 'name' => 'data[User][active]', 'value' => '1', 'id' => 'UserActive', 'checked' => 'checked')),
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('User.active', array('label' => false, 'checked' => '1'));
$expected = array(
'div' => array('class' => 'input checkbox'),
'input' => array('type' => 'hidden', 'name' => 'data[User][active]', 'value' => '0', 'id' => 'UserActive_'),
array('input' => array('type' => 'checkbox', 'name' => 'data[User][active]', 'value' => '1', 'id' => 'UserActive', 'checked' => 'checked')),
'/div'
);
$this->assertTags($result, $expected);
}
/**
* test form->input() with datetime, date and time types
*
@ -1952,6 +1999,7 @@ class FormHelperTest extends CakeTestCase {
));
$this->assertPattern('/for\="created-month"/', $result);
}
/**
* Test generating checkboxes in a loop.
*
@ -1972,6 +2020,7 @@ class FormHelperTest extends CakeTestCase {
$this->assertTags($result, $expected);
}
}
/**
* test form->input() with select type inputs.
*
@ -2118,6 +2167,29 @@ class FormHelperTest extends CakeTestCase {
$this->assertTags($result, $expected);
}
/**
* test that input() and a non standard primary key makes a hidden input by default.
*
* @return void
*/
function testInputWithNonStandardPrimaryKeyMakesHidden() {
$this->Form->create('User');
$this->Form->fieldset = array(
'User' => array(
'fields' => array(
'model_id' => array('type' => 'integer')
),
'validates' => array(),
'key' => 'model_id'
)
);
$result = $this->Form->input('model_id');
$expected = array(
'input' => array('type' => 'hidden', 'name' => 'data[User][model_id]', 'id' => 'UserModelId'),
);
$this->assertTags($result, $expected);
}
/**
* test that overriding the magic select type widget is possible
*
@ -3522,6 +3594,20 @@ class FormHelperTest extends CakeTestCase {
);
$this->assertTags($result, $expected);
$result = $this->Form->checkbox('Model.field', array('checked' => 1));
$expected = array(
'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField', 'checked' => 'checked'))
);
$this->assertTags($result, $expected);
$result = $this->Form->checkbox('Model.field', array('checked' => true));
$expected = array(
'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField', 'checked' => 'checked'))
);
$this->assertTags($result, $expected);
$this->Form->validationErrors['Model']['field'] = 1;
$this->Form->data['Contact']['published'] = 1;
$result = $this->Form->checkbox('Contact.published', array('id' => 'theID'));

View file

@ -267,15 +267,19 @@ class TextHelperTest extends CakeTestCase {
$this->assertPattern('#^' . $expected . '$#', $result);
$text = 'Text with a partial WWW.cakephp.org URL';
$expected = 'Text with a partial <a href="http://www.cakephp.org"\s*>WWW.cakephp.org</a> URL';
$expected = 'Text with a partial <a href="http://WWW.cakephp.org"\s*>WWW.cakephp.org</a> URL';
$result = $this->Text->autoLinkUrls($text);
$this->assertPattern('#^' . $expected . '$#', $result);
$text = 'Text with a partial WWW.cakephp.org &copy; URL';
$expected = 'Text with a partial <a href="http://www.cakephp.org"\s*>WWW.cakephp.org</a> &copy; URL';
$expected = 'Text with a partial <a href="http://WWW.cakephp.org"\s*>WWW.cakephp.org</a> &copy; URL';
$result = $this->Text->autoLinkUrls($text, array('escape' => false));
$this->assertPattern('#^' . $expected . '$#', $result);
$text = 'Text with a url www.cot.ag/cuIb2Q and more';
$expected = 'Text with a url <a href="http://www.cot.ag/cuIb2Q">www.cot.ag/cuIb2Q</a> and more';
$result = $this->Text->autoLinkUrls($text);
$this->assertEqual($expected, $result);
}
/**

View file

@ -40,7 +40,7 @@ class MediaController extends Controller {
* @var string 'Media'
* @access public
*/
var $name = 'Media';
public $name = 'Media';
/**
* index download
@ -70,7 +70,7 @@ class TestMediaView extends MediaView {
* @var array
* @access public
*/
var $headers = array();
public $headers = array();
/**
* active property to mock the status of a remote connection
@ -78,7 +78,7 @@ class TestMediaView extends MediaView {
* @var boolean true
* @access public
*/
var $active = true;
public $active = true;
function _output() {
$this->headers = $this->_headers;

View file

@ -74,6 +74,7 @@ class CakeTestFixture {
$db->cacheSources = false;
$this->fields = $model->schema(true);
$this->fields[$model->primaryKey]['key'] = 'primary';
$this->table = $db->fullTableName($model, false);
ClassRegistry::config(array('ds' => 'test_suite'));
ClassRegistry::flush();
} elseif (isset($import['table'])) {
@ -91,7 +92,7 @@ class CakeTestFixture {
$this->records = array();
$query = array(
'fields' => $db->fields($model, null, array_keys($this->fields)),
'table' => $db->fullTableName($model->table),
'table' => $db->fullTableName($model),
'alias' => $model->alias,
'conditions' => array(),
'order' => null,

View file

@ -0,0 +1,27 @@
<?php
class Test2OtherSource extends DataSource {
function describe($model) {
return compact('model');
}
function listSources() {
return array('test_source');
}
function create($model, $fields = array(), $values = array()) {
return compact('model', 'fields', 'values');
}
function read($model, $queryData = array()) {
return compact('model', 'queryData');
}
function update($model, $fields = array(), $values = array()) {
return compact('model', 'fields', 'values');
}
function delete($model, $id) {
return compact('model', 'id');
}
}

View file

@ -0,0 +1,27 @@
<?php
class Test2Source extends DataSource {
function describe($model) {
return compact('model');
}
function listSources() {
return array('test_source');
}
function create($model, $fields = array(), $values = array()) {
return compact('model', 'fields', 'values');
}
function read($model, $queryData = array()) {
return compact('model', 'queryData');
}
function update($model, $fields = array(), $values = array()) {
return compact('model', 'fields', 'values');
}
function delete($model, $id) {
return compact('model', 'id');
}
}

View file

@ -0,0 +1,27 @@
<?php
class TestOtherSource extends DataSource {
function describe($model) {
return compact('model');
}
function listSources() {
return array('test_source');
}
function create($model, $fields = array(), $values = array()) {
return compact('model', 'fields', 'values');
}
function read($model, $queryData = array()) {
return compact('model', 'queryData');
}
function update($model, $fields = array(), $values = array()) {
return compact('model', 'fields', 'values');
}
function delete($model, $id) {
return compact('model', 'id');
}
}