Merge branch '2.0' into 2.0-request

Conflicts:
	cake/dispatcher.php
	cake/libs/controller/components/request_handler.php
	cake/libs/view/helpers/form.php
	cake/tests/cases/libs/controller/components/request_handler.test.php
	cake/tests/cases/libs/controller/controller.test.php
	cake/tests/cases/libs/view/helpers/js.test.php
	cake/tests/cases/libs/view/helpers/paginator.test.php
This commit is contained in:
mark_story 2010-06-27 23:21:11 -04:00
commit ecf7811b7a
329 changed files with 1885 additions and 898 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

@ -157,6 +157,11 @@
/**
* The name of CakePHP's session cookie.
*
* Note the guidelines for Session names states: "The session name references
* the session id in cookies and URLs. It should contain only alphanumeric
* characters."
* @link http://php.net/session_name
*/
Configure::write('Session.cookie', 'CAKEPHP');
@ -183,8 +188,8 @@
* Valid values:
*
* 'high' Session timeout in 'Session.timeout' x 10
* 'medium' Session timeout in 'Session.timeout' x 100
* 'low' Session timeout in 'Session.timeout' x 300
* 'medium' Session timeout in 'Session.timeout' x 5040
* 'low' Session timeout in 'Session.timeout' x 2628000
*
* CakePHP session IDs are also regenerated between requests if
* 'Security.level' is set to 'high'.

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

@ -4,16 +4,16 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing
* @package cake
* @subpackage cake.cake.tests.libs
* @subpackage cake.app.webroot
* @since CakePHP(tm) v 1.2.0.4433
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/

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

@ -432,7 +432,7 @@ class ShellDispatcher {
$printOptions = '(' . implode('/', $options) . ')';
}
if ($default == null) {
if ($default === null) {
$this->stdout($prompt . " $printOptions \n" . '> ', false);
} else {
$this->stdout($prompt . " $printOptions \n" . "[$default] > ", false);

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

@ -551,13 +551,13 @@ class Shell extends Object {
}
/**
* Creates the proper singular model key for associations
* Creates the proper underscored model key for associations
*
* @param string $name Controller class name
* @param string $name Model class name
* @return string Singular model key
*/
protected function _modelKey($name) {
return Inflector::underscore(Inflector::singularize($name)) . '_id';
return Inflector::underscore($name) . '_id';
}
/**

View file

@ -57,7 +57,7 @@ class ControllerTask extends BakeTask {
*/
public function execute() {
if (empty($this->args)) {
$this->_interactive();
return $this->_interactive();
}
if (isset($this->args[0])) {
@ -175,7 +175,7 @@ class ControllerTask extends BakeTask {
);
}
} else {
list($wannaBakeCrud, $wannaBakeCrud) = $this->_askAboutMethods();
list($wannaBakeCrud, $wannaBakeAdminCrud) = $this->_askAboutMethods();
}
if (strtolower($wannaBakeCrud) == 'y') {
@ -186,6 +186,7 @@ class ControllerTask extends BakeTask {
$actions .= $this->bakeActions($controllerName, $admin, strtolower($wannaUseSession) == 'y');
}
$baked = false;
if ($this->interactive === true) {
$this->confirmController($controllerName, $useDynamicScaffold, $helpers, $components);
$looksGood = $this->in(__('Look okay?'), array('y','n'), 'y');
@ -202,6 +203,7 @@ class ControllerTask extends BakeTask {
$this->bakeTest($controllerName);
}
}
return $baked;
}
/**
@ -282,7 +284,7 @@ class ControllerTask extends BakeTask {
$controllerPath = $this->_controllerPath($controllerName);
$pluralName = $this->_pluralName($currentModelName);
$singularName = Inflector::variable($currentModelName);
$singularHumanName = $this->_singularHumanName($currentModelName);
$singularHumanName = $this->_singularHumanName($controllerName);
$pluralHumanName = $this->_pluralName($controllerName);
$this->Template->set(compact('admin', 'controllerPath', 'pluralName', 'singularName', 'singularHumanName',

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 = str_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

@ -94,14 +94,12 @@ class TestTask extends BakeTask {
$this->out(sprintf(__('Path: %s'), $this->path));
$this->hr();
$selection = null;
if ($type) {
$type = Inflector::camelize($type);
if (!in_array($type, $this->classTypes)) {
unset($type);
$this->error(sprintf('Incorrect type provided. Please choose one of %s', implode(', ', $this->classTypes)));
}
}
if (!$type) {
} else {
$type = $this->getObjectType();
}
$className = $this->getClassName($type);

View file

@ -195,6 +195,7 @@ class ViewTask extends BakeTask {
$actions = $this->_methodsToBake();
}
$this->bakeActions($actions, $vars);
$actions = null;
}
}
}
@ -290,7 +291,7 @@ class ViewTask extends BakeTask {
$primaryKey = $modelObj->primaryKey;
$displayField = $modelObj->displayField;
$singularVar = Inflector::variable($modelClass);
$singularHumanName = $this->_singularHumanName($modelClass);
$singularHumanName = $this->_singularHumanName($this->controllerName);
$schema = $modelObj->schema(true);
$fields = array_keys($schema);
$associations = $this->__associations($modelObj);

View file

@ -6,14 +6,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.cake.console.libs
* @since CakePHP(tm) v 1.2.0.4433

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

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2009, 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-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.cake.tests.libs
* @since CakePHP(tm) v 1.2.0.4433

View file

@ -147,6 +147,7 @@ class Dispatcher extends Object {
'base' => $request->base
)));
}
return $this->_invoke($controller, $request);
}

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
*
@ -130,6 +122,14 @@ class CakeSession extends Object {
*/
public $host = null;
/**
* Session timeout multiplier factor
*
* @var ineteger
* @access public
*/
public $timeout = null;
/**
* Constructor.
*
@ -206,7 +206,7 @@ class CakeSession extends Object {
session_write_close();
}
$this->__initSession();
$this->_started = $this->__startSession();
$this->__startSession();
return $this->started();
}
@ -217,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;
@ -448,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 = 0;
if ($iniSet) {
ini_set('session.referer_check', $this->host);
}
break;
case 'medium':
$this->cookieLifeTime = 7 * 86400;
if ($iniSet) {
ini_set('session.referer_check', $this->host);
}
break;
case 'low':
default:
$this->cookieLifeTime = 788940000;
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':
@ -591,15 +575,14 @@ class CakeSession extends Object {
if ((Configure::read('Session.checkAgent') === false || $this->_userAgent == $this->read('Config.userAgent')) && $this->time <= $this->read('Config.time')) {
$time = $this->read('Config.time');
$this->write('Config.time', $this->sessionTime);
if (Configure::read('Security.level') === 'high') {
$check = $this->read('Config.timeout');
$check = $check - 1;
$check -= 1;
$this->write('Config.timeout', $check);
if (time() > ($time - (Security::inactiveMins() * Configure::read('Session.timeout')) + 2) || $check < 1) {
$this->renew();
$this->write('Config.timeout', 10);
$this->write('Config.timeout', Security::inactiveMins());
}
}
$this->valid = true;
@ -611,7 +594,7 @@ class CakeSession extends Object {
} else {
$this->write('Config.userAgent', $this->_userAgent);
$this->write('Config.time', $this->sessionTime);
$this->write('Config.timeout', 10);
$this->write('Config.timeout', Security::inactiveMins());
$this->valid = true;
$this->__setError(1, 'Session is valid');
}
@ -738,21 +721,7 @@ class CakeSession extends Object {
* @access private
*/
function __write($id, $data) {
switch (Configure::read('Security.level')) {
case 'medium':
$factor = 100;
break;
case 'low':
$factor = 300;
break;
case 'high':
default:
$factor = 10;
break;
}
$expires = time() + Configure::read('Session.timeout') * $factor;
$expires = time() + Configure::read('Session.timeout') * Security::inactiveMins();
$model =& ClassRegistry::getObject('Session');
$return = $model->save(compact('id', 'data', 'expires'));
return $return;
@ -788,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

@ -22,7 +22,7 @@
*
* @package cake
* @subpackage cake.cake.libs.controller
* @link http://book.cakephp.org/view/62/Components
* @link http://book.cakephp.org/view/993/Components
*/
class Component extends Object {

View file

@ -456,7 +456,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

@ -224,8 +224,9 @@ class RequestHandlerComponent extends Object {
*
* @param object $controller A reference to the controller
* @param mixed $url A string or array containing the redirect location
* @param mixed HTTP Status for redirect
*/
public function beforeRedirect(&$controller, $url) {
public function beforeRedirect(&$controller, $url, $status = null) {
if (!$this->request->is('ajax')) {
return;
}
@ -235,7 +236,13 @@ class RequestHandlerComponent extends Object {
if (is_array($url)) {
$url = Router::url($url + array('base' => false));
}
echo $this->requestAction($url, array('return'));
if (!empty($status)) {
$statusCode = $controller->httpCodes($status);
$code = key($statusCode);
$msg = $statusCode[$code];
$controller->header("HTTP/1.1 {$code} {$msg}");
}
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
@ -109,7 +110,6 @@ class SecurityComponent extends Object {
/**
* An associative array of usernames/passwords used for HTTP-authenticated logins.
* If using digest authentication, passwords should be MD5-hashed.
*
* @var array
* @access public

View file

@ -841,8 +841,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

@ -474,11 +474,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
@ -172,6 +172,7 @@ class L10n {
/* Urdu */ 'urd' => 'ur',
/* Venda */ 'ven' => 've',
/* Vietnamese */ 'vie' => 'vi',
/* Welsh */ 'cym' => 'cy',
/* Xhosa */ 'xho' => 'xh',
/* Yiddish */ 'yid' => 'yi',
/* Zulu */ 'zul' => 'zu');
@ -315,6 +316,7 @@ class L10n {
'ur' => array('language' => 'Urdu', 'locale' => 'urd', 'localeFallback' => 'urd', 'charset' => 'utf-8', 'direction' => 'rtl'),
've' => array('language' => 'Venda', 'locale' => 'ven', 'localeFallback' => 'ven', 'charset' => 'utf-8', 'direction' => 'ltr'),
'vi' => array('language' => 'Vietnamese', 'locale' => 'vie', 'localeFallback' => 'vie', 'charset' => 'utf-8', 'direction' => 'ltr'),
'cy' => array('language' => 'Welsh', 'locale' => 'cym', 'localeFallback' => 'cym', 'charset' => 'utf-8', 'direction' => 'ltr'),
'xh' => array('language' => 'Xhosa', 'locale' => 'xho', 'localeFallback' => 'xho', 'charset' => 'utf-8', 'direction' => 'ltr'),
'yi' => array('language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8', 'direction' => 'ltr'),
'zh' => array('language' => 'Chinese', 'locale' => 'chi', 'localeFallback' => 'chi', 'charset' => 'utf-8', 'direction' => 'ltr'),

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";
@ -726,8 +726,8 @@ class DboMysql extends DboMysqlBase {
$j = 0;
while ($j < $numFields) {
$column = mysql_fetch_field($results,$j);
if (!empty($column->table)) {
$column = mysql_fetch_field($results, $j);
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

@ -1263,7 +1263,7 @@ class Model extends Object {
}
}
if (isset($this->data[$this->alias][$this->primaryKey]) && empty($this->data[$this->alias][$this->primaryKey])) {
if (empty($this->data[$this->alias][$this->primaryKey])) {
unset($this->data[$this->alias][$this->primaryKey]);
}
$fields = $values = array();
@ -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;
}
@ -361,6 +366,7 @@ class BehaviorCollection extends Object {
* @return void
*/
public function detach($name) {
list($plugin, $name) = pluginSplit($name);
if (isset($this->{$name})) {
$this->{$name}->cleanup(ClassRegistry::getObject($this->modelName));
unset($this->{$name});
@ -466,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

@ -156,7 +156,7 @@ class Sanitize {
* @static
*/
public static function stripScripts($str) {
return preg_replace('/(<link[^>]+rel="[^"]*stylesheet"[^>]*>|<img[^>]*>|style="[^"]*")|<script[^>]*>.*?<\/script>|<style[^>]*>.*?<\/style>|<!--.*?-->/i', '', $str);
return preg_replace('/(<link[^>]+rel="[^"]*stylesheet"[^>]*>|<img[^>]*>|style="[^"]*")|<script[^>]*>.*?<\/script>|<style[^>]*>.*?<\/style>|<!--.*?-->/is', '', $str);
}
/**

View file

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

View file

@ -381,13 +381,13 @@ class Validation {
}
if ($return === true && preg_match('/@(' . self::$__pattern['hostname'] . ')$/i', $check, $regs)) {
$host = gethostbynamel($regs[1]);
$return = is_array($host);
$isWindows = (DIRECTORY_SEPARATOR === '\\');
if (!$isWindows || (version_compare(PHP_VERSION, '5.3.0', '>=') && $isWindows)) {
$return = $return && getmxrr($regs[1], $mxhosts);
if (function_exists('getmxrr') && getmxrr($regs[1], $mxhosts)) {
return true;
}
return $return;
if (function_exists('checkdnsrr') && checkdnsrr($regs[1], 'MX')) {
return true;
}
return is_array(gethostbynamel($regs[1]));
}
return false;
}

View file

@ -290,9 +290,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.
@ -351,7 +352,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

@ -211,7 +211,7 @@ class FormHelper extends AppHelper {
}
}
$object =& $this->_introspectModel($model);
$object = $this->_introspectModel($model);
$this->setEntity($model . '.', true);
$modelEntity = $this->model();
@ -304,6 +304,7 @@ class FormHelper extends AppHelper {
unset($options['default']);
$htmlAttributes = array_merge($options, $htmlAttributes);
$this->fields = array();
if (isset($this->request['_Token']) && !empty($this->request['_Token'])) {
$append .= $this->hidden('_Token.key', array(
'value' => $this->request['_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

@ -252,9 +252,13 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
if (isset($options['update'])) {
$wrapCallbacks = isset($options['wrapCallbacks']) ? $options['wrapCallbacks'] : true;
if ($wrapCallbacks) {
$success = '$("' . $options['update'] . '").html(data);';
$success = $this->jQueryObject . '("' . $options['update'] . '").html(data);';
} else {
$success = 'function (data, textStatus) {$("' . $options['update'] . '").html(data);}';
$success = sprintf(
'function (data, textStatus) {%s("%s").html(data);}',
$this->jQueryObject,
$options['update']
);
}
$options['dataType'] = 'html';
$options['success'] = $success;
@ -267,7 +271,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
}
$options = $this->_prepareCallbacks('request', $options);
$options = $this->_parseOptions($options, $callbacks);
return '$.ajax({' . $options .'});';
return $this->jQueryObject . '.ajax({' . $options .'});';
}
/**

View file

@ -302,17 +302,22 @@ class JsHelper extends AppHelper {
list($options, $htmlOptions) = $this->_getHtmlOptions($options);
$out = $this->Html->link($title, $url, $htmlOptions);
$this->get('#' . $htmlOptions['id']);
$requestString = '';
$requestString = $event = '';
if (isset($options['confirm'])) {
$requestString = $this->confirmReturn($options['confirm']);
unset($options['confirm']);
}
$buffer = isset($options['buffer']) ? $options['buffer'] : null;
$safe = isset($options['safe']) ? $options['safe'] : true;
unset($options['buffer'], $options['safe']);
$requestString .= $this->request($url, $options);
if (!empty($requestString)) {
$event = $this->event('click', $requestString, $options);
$event = $this->event('click', $requestString, $options + array('buffer' => $buffer));
}
if (isset($options['buffer']) && $options['buffer'] == false) {
$opts = array_intersect_key(array('safe' => null), $options);
if (isset($buffer) && !$buffer) {
$opts = array('safe' => $safe);
$out .= $this->Html->scriptBlock($event, $opts);
}
return $out;
@ -352,8 +357,16 @@ class JsHelper extends AppHelper {
* Forms submitting with this method, cannot send files. Files do not transfer over XmlHttpRequest
* and require an iframe or flash.
*
* ### Options
*
* - `url` The url you wish the XHR request to submit to.
* - `confirm` A string to use for a confirm() message prior to submitting the request.
* - `method` The method you wish the form to send by, defaults to POST
* - `buffer` Whether or not you wish the script code to be buffered, defaults to true.
* - Also see options for JsHelper::request() and JsHelper::event()
*
* @param string $title The display text of the submit button.
* @param array $options Array of options to use.
* @param array $options Array of options to use. See the options for the above mentioned methods.
* @return string Completed submit button.
*/
public function submit($caption = null, $options = array()) {
@ -380,12 +393,17 @@ class JsHelper extends AppHelper {
$options['method'] = 'post';
}
$options['dataExpression'] = true;
$buffer = isset($options['buffer']) ? $options['buffer'] : null;
$safe = isset($options['safe']) ? $options['safe'] : true;
unset($options['buffer'], $options['safe']);
$requestString .= $this->request($url, $options);
if (!empty($requestString)) {
$event = $this->event('click', $requestString, $options);
$event = $this->event('click', $requestString, $options + array('buffer' => $buffer));
}
if (isset($options['buffer']) && $options['buffer'] == false) {
$opts = array_intersect_key(array('safe' => null), $options);
if (isset($buffer) && !$buffer) {
$opts = array('safe' => $safe);
$out .= $this->Html->scriptBlock($event, $opts);
}
return $out;
@ -423,7 +441,7 @@ class JsHelper extends AppHelper {
*
* @package cake.view.helpers
*/
class JsBaseEngineHelper extends AppHelper {
abstract class JsBaseEngineHelper extends AppHelper {
/**
* Determines whether native JSON extension is used for encoding. Set by object constructor.
*
@ -749,10 +767,7 @@ class JsBaseEngineHelper extends AppHelper {
* @param string $selector The selector that is targeted
* @return object instance of $this. Allows chained methods.
*/
public function get($selector) {
trigger_error(sprintf(__('%s does not have get() implemented'), get_class($this)), E_USER_WARNING);
return $this;
}
abstract public function get($selector);
/**
* Add an event to the script cache. Operates on the currently selected elements.
@ -767,9 +782,7 @@ class JsBaseEngineHelper extends AppHelper {
* @param array $options Options for the event.
* @return string completed event handler
*/
public function event($type, $callback, $options = array()) {
trigger_error(sprintf(__('%s does not have event() implemented'), get_class($this)), E_USER_WARNING);
}
abstract public function event($type, $callback, $options = array());
/**
* Create a domReady event. This is a special event in many libraries
@ -777,9 +790,7 @@ class JsBaseEngineHelper extends AppHelper {
* @param string $functionBody The code to run on domReady
* @return string completed domReady method
*/
public function domReady($functionBody) {
trigger_error(sprintf(__('%s does not have domReady() implemented'), get_class($this)), E_USER_WARNING);
}
abstract public function domReady($functionBody);
/**
* Create an iteration over the current selection result.
@ -787,9 +798,7 @@ class JsBaseEngineHelper extends AppHelper {
* @param string $callback The function body you wish to apply during the iteration.
* @return string completed iteration
*/
function each($callback) {
trigger_error(sprintf(__('%s does not have each() implemented'), get_class($this)), E_USER_WARNING);
}
abstract public function each($callback);
/**
* Trigger an Effect.
@ -814,9 +823,7 @@ class JsBaseEngineHelper extends AppHelper {
* @param array $options Array of options for the effect.
* @return string completed string with effect.
*/
public function effect($name, $options) {
trigger_error(sprintf(__('%s does not have effect() implemented'), get_class($this)), E_USER_WARNING);
}
abstract public function effect($name, $options);
/**
* Make an XHR request
@ -843,9 +850,7 @@ class JsBaseEngineHelper extends AppHelper {
* @param array $options Array of options. See above for cross library supported options
* @return string XHR request.
*/
public function request($url, $options = array()) {
trigger_error(sprintf(__('%s does not have request() implemented'), get_class($this)), E_USER_WARNING);
}
abstract public function request($url, $options = array());
/**
* Create a draggable element. Works on the currently selected element.
@ -866,9 +871,7 @@ class JsBaseEngineHelper extends AppHelper {
* @param array $options Options array see above.
* @return string Completed drag script
*/
public function drag($options = array()) {
trigger_error(sprintf(__('%s does not have drag() implemented'), get_class($this)), E_USER_WARNING);
}
abstract public function drag($options = array());
/**
* Create a droppable element. Allows for draggable elements to be dropped on it.
@ -887,9 +890,7 @@ class JsBaseEngineHelper extends AppHelper {
*
* @return string Completed drop script
*/
public function drop($options = array()) {
trigger_error(sprintf(__('%s does not have drop() implemented'), get_class($this)), E_USER_WARNING);
}
abstract public function drop($options = array());
/**
* Create a sortable element.
@ -912,9 +913,7 @@ class JsBaseEngineHelper extends AppHelper {
* @param array $options Array of options for the sortable. See above.
* @return string Completed sortable script.
*/
public function sortable() {
trigger_error(sprintf(__('%s does not have sortable() implemented'), get_class($this)), E_USER_WARNING);
}
abstract public function sortable();
/**
* Create a slider UI widget. Comprised of a track and knob.
@ -936,10 +935,7 @@ class JsBaseEngineHelper extends AppHelper {
*
* @return string Completed slider script
*/
public function slider() {
trigger_error(sprintf(__('%s does not have slider() implemented'), get_class($this)), E_USER_WARNING);
}
abstract public function slider();
/**
* Serialize the form attached to $selector.
* Pass `true` for $isForm if the current selection is a form element.
@ -954,11 +950,7 @@ class JsBaseEngineHelper extends AppHelper {
* @param array $options options for serialization generation.
* @return string completed form serialization script
*/
public function serializeForm() {
trigger_error(
sprintf(__('%s does not have serializeForm() implemented'), get_class($this)), E_USER_WARNING
);
}
abstract public function serializeForm();
/**
* Parse an options assoc array into an Javascript object literal.

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

@ -191,18 +191,10 @@ class PaginatorHelper extends AppHelper {
}
if (isset($options['sort']) && !empty($options['sort'])) {
if (preg_match('/(?:\w+\.)?(\w+)/', $options['sort'], $result) && isset($result[1])) {
if ($result[0] == $this->defaultModel()) {
return $result[1];
}
}
return $options['sort'];
} elseif (isset($options['order']) && is_array($options['order'])) {
return key($options['order']);
} elseif (isset($options['order']) && is_string($options['order'])) {
if (preg_match('/(?:\w+\.)?(\w+)/', $options['order'], $result) && isset($result[1])) {
return $result[1];
}
return $options['order'];
}
return null;
@ -303,13 +295,18 @@ class PaginatorHelper extends AppHelper {
unset($options['direction']);
$sortKey = $this->sortKey($options['model']);
$isSorted = ($sortKey === $key || $sortKey === $this->defaultModel() . '.' . $key);
$defaultModel = $this->defaultModel();
$isSorted = (
$sortKey === $key ||
$sortKey === $defaultModel . '.' . $key ||
$key === $defaultModel . '.' . $sortKey
);
if ($isSorted) {
$dir = $this->sortDir($options['model']) === 'asc' ? 'desc' : 'asc';
$class = $dir === 'asc' ? 'desc' : 'asc';
if (!empty($options['class'])) {
$options['class'] .= $class;
$options['class'] .= ' ' . $class;
} else {
$options['class'] = $class;
}

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,8 +106,8 @@ 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.2 Docs')),
'http://book.cakephp.org',
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

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases
* @since CakePHP(tm) v 1.2.0.4206

View file

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, Cake Software Foundation, Inc.
*
* Licensed under The Open Group Test Suite License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc.
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.console
* @since CakePHP(tm) v 1.2.0.5432

View file

@ -310,20 +310,20 @@ class ControllerTaskTest extends CakeTestCase {
$this->assertTrue(strpos($result, "\$this->set('articles', \$this->paginate());") !== false);
$this->assertTrue(strpos($result, 'function view($id = null)') !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(sprintf(__('Invalid %s'), 'article'));") !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(__('Invalid article'));") !== false);
$this->assertTrue(strpos($result, "\$this->set('article', \$this->Article->read(null, \$id)") !== false);
$this->assertTrue(strpos($result, 'function add()') !== false);
$this->assertTrue(strpos($result, 'if (!empty($this->data))') !== false);
$this->assertTrue(strpos($result, 'if ($this->Article->save($this->data))') !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(sprintf(__('The %s has been saved'), 'article'));") !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(__('The article has been saved'));") !== false);
$this->assertTrue(strpos($result, 'function edit($id = null)') !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(sprintf(__('The %s could not be saved. Please, try again.'), 'article'));") !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(__('The article could not be saved. Please, try again.'));") !== false);
$this->assertTrue(strpos($result, 'function delete($id = null)') !== false);
$this->assertTrue(strpos($result, 'if ($this->Article->delete($id))') !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(sprintf(__('%s deleted'), 'Article'));") !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(__('Article deleted'));") !== false);
$result = $this->Task->bakeActions('Articles', 'admin_', true);
@ -352,13 +352,13 @@ class ControllerTaskTest extends CakeTestCase {
$this->assertTrue(strpos($result, "\$this->set('articles', \$this->paginate());") !== false);
$this->assertTrue(strpos($result, 'function view($id = null)') !== false);
$this->assertTrue(strpos($result, "\$this->flash(sprintf(__('Invalid %s'), 'article'), array('action' => 'index'))") !== false);
$this->assertTrue(strpos($result, "\$this->flash(__('Invalid article'), array('action' => 'index'))") !== false);
$this->assertTrue(strpos($result, "\$this->set('article', \$this->Article->read(null, \$id)") !== false);
$this->assertTrue(strpos($result, 'function add()') !== false);
$this->assertTrue(strpos($result, 'if (!empty($this->data))') !== false);
$this->assertTrue(strpos($result, 'if ($this->Article->save($this->data))') !== false);
$this->assertTrue(strpos($result, "\$this->flash(sprintf(__('The %s has been saved.'), 'article'), array('action' => 'index'))") !== false);
$this->assertTrue(strpos($result, "\$this->flash(__('The article has been saved.'), array('action' => 'index'))") !== false);
$this->assertTrue(strpos($result, 'function edit($id = null)') !== false);
$this->assertTrue(strpos($result, "\$this->Article->Tag->find('list')") !== false);
@ -366,7 +366,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->assertTrue(strpos($result, 'function delete($id = null)') !== false);
$this->assertTrue(strpos($result, 'if ($this->Article->delete($id))') !== false);
$this->assertTrue(strpos($result, "\$this->flash(sprintf(__('%s deleted'), 'Article'), array('action' => 'index'))") !== false);
$this->assertTrue(strpos($result, "\$this->flash(__('Article deleted'), array('action' => 'index'))") !== false);
}
/**
@ -411,6 +411,35 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticlesController/')));
}
/**
* test Interactive mode.
*
* @return void
* @access public
*/
public function testInteractiveAdminMethodsNotInteractive() {
$this->Task->connection = 'test_suite';
$this->Task->interactive = true;
$this->Task->path = '/my/path';
$this->Task->setReturnValue('in', '1');
$this->Task->setReturnValueAt(1, 'in', 'y'); // build interactive
$this->Task->setReturnValueAt(2, 'in', 'n'); // build no scaffolds
$this->Task->setReturnValueAt(3, 'in', 'y'); // build normal methods
$this->Task->setReturnValueAt(4, 'in', 'y'); // build admin methods
$this->Task->setReturnValueAt(5, 'in', 'n'); // helpers?
$this->Task->setReturnValueAt(6, 'in', 'n'); // components?
$this->Task->setReturnValueAt(7, 'in', 'y'); // use sessions
$this->Task->setReturnValueAt(8, 'in', 'y'); // looks good
$this->Task->setReturnValue('createFile', true);
$this->Task->Project->setReturnValue('getPrefix', 'admin_');
$result = $this->Task->execute();
$this->assertPattern('/admin_index/', $result);
$filename = '/my/path/articles_controller.php';
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticlesController/')));
}
/**
* test that execute runs all when the first arg == all
*

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

@ -286,10 +286,10 @@ class ViewTaskTest extends CakeTestCase {
);
$result = $this->Task->getContent('view', $vars);
$this->assertPattern('/Delete .+Test View Model/', $result);
$this->assertPattern('/Edit .+Test View Model/', $result);
$this->assertPattern('/List .+Test View Models/', $result);
$this->assertPattern('/New .+Test View Model/', $result);
$this->assertPattern('/Delete Test View Model/', $result);
$this->assertPattern('/Edit Test View Model/', $result);
$this->assertPattern('/List Test View Models/', $result);
$this->assertPattern('/New Test View Model/', $result);
$this->assertPattern('/testViewModel\[\'TestViewModel\'\]\[\'id\'\]/', $result);
$this->assertPattern('/testViewModel\[\'TestViewModel\'\]\[\'name\'\]/', $result);
@ -318,10 +318,10 @@ class ViewTaskTest extends CakeTestCase {
);
$result = $this->Task->getContent('admin_view', $vars);
$this->assertPattern('/Delete .+Test View Model/', $result);
$this->assertPattern('/Edit .+Test View Model/', $result);
$this->assertPattern('/List .+Test View Models/', $result);
$this->assertPattern('/New .+Test View Model/', $result);
$this->assertPattern('/Delete Test View Model/', $result);
$this->assertPattern('/Edit Test View Model/', $result);
$this->assertPattern('/List Test View Models/', $result);
$this->assertPattern('/New Test View Model/', $result);
$this->assertPattern('/testViewModel\[\'TestViewModel\'\]\[\'id\'\]/', $result);
$this->assertPattern('/testViewModel\[\'TestViewModel\'\]\[\'name\'\]/', $result);
@ -330,7 +330,7 @@ class ViewTaskTest extends CakeTestCase {
$result = $this->Task->getContent('admin_add', $vars);
$this->assertPattern("/input\('name'\)/", $result);
$this->assertPattern("/input\('body'\)/", $result);
$this->assertPattern('/List .+Test View Models/', $result);
$this->assertPattern('/List Test View Models/', $result);
Configure::write('Routing', $_back);
}
@ -390,7 +390,7 @@ class ViewTaskTest extends CakeTestCase {
));
$this->Task->expectAt(1, 'createFile', array(
TMP . 'view_task_comments' . DS . 'edit.ctp',
new PatternExpectation('/Edit .+View Task Comment/')
new PatternExpectation('/Edit View Task Comment/')
));
$this->Task->expectAt(2, 'createFile', array(
TMP . 'view_task_comments' . DS . 'index.ctp',
@ -552,11 +552,11 @@ class ViewTaskTest extends CakeTestCase {
));
$this->Task->expectAt(2, 'createFile', array(
TMP . 'view_task_comments' . DS . 'add.ctp',
new PatternExpectation('/Add .+View Task Comment/')
new PatternExpectation('/Add View Task Comment/')
));
$this->Task->expectAt(3, 'createFile', array(
TMP . 'view_task_comments' . DS . 'edit.ctp',
new PatternExpectation('/Edit .+View Task Comment/')
new PatternExpectation('/Edit View Task Comment/')
));
$this->Task->execute();
@ -607,11 +607,11 @@ class ViewTaskTest extends CakeTestCase {
));
$this->Task->expectAt(2, 'createFile', array(
TMP . 'view_task_comments' . DS . 'admin_add.ctp',
new PatternExpectation('/Add .+View Task Comment/')
new PatternExpectation('/Add View Task Comment/')
));
$this->Task->expectAt(3, 'createFile', array(
TMP . 'view_task_comments' . DS . 'admin_edit.ctp',
new PatternExpectation('/Edit .+View Task Comment/')
new PatternExpectation('/Edit View Task Comment/')
));
$this->Task->execute();
@ -634,4 +634,5 @@ class ViewTaskTest extends CakeTestCase {
$result = $this->Task->getTemplate('admin_add');
$this->assertEqual($result, 'form');
}
}

View file

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases
* @since CakePHP(tm) v 1.2.0.4206

View file

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.5432

View file

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs.cache
* @since CakePHP(tm) v 1.2.0.5434

View file

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs.cache
* @since CakePHP(tm) v 1.2.0.5434
@ -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

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs.cache
* @since CakePHP(tm) v 1.2.0.5434

View file

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs.cache
* @since CakePHP(tm) v 1.2.0.5434

View file

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.5432

View file

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.4206
@ -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

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.4206

View file

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.cake.tests.libs
* @since CakePHP(tm) v 1.2.0.4667
@ -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

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.5432

View file

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.4206

View file

@ -6,14 +6,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.5432

View file

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs.controller
* @since CakePHP(tm) v 1.2.0.5436

View file

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
* @since CakePHP(tm) v 1.2.0.5435

View file

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.cake.tests.cases.libs.controller.components
* @since CakePHP(tm) v 1.2.0.5347
@ -1426,6 +1426,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_');
@ -1451,7 +1461,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

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
* @since CakePHP(tm) v 1.2.0.5435

View file

@ -6,14 +6,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.cake.tests.cases.libs.controller.components
* @since CakePHP(tm) v 1.2.0.5347
@ -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

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
* @since CakePHP(tm) v 1.2.0.5435
@ -22,6 +22,7 @@ App::import('Component', array('RequestHandler'));
Mock::generatePartial('RequestHandlerComponent', 'NoStopRequestHandler', array('_stop'));
Mock::generate('CakeRequest', 'RequestHandlerMockCakeRequest');
Mock::generatePartial('Controller', 'RequestHandlerMockController', array('header'));
/**
* RequestHandlerTestController class
@ -79,6 +80,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();
}
}
/**
@ -537,6 +550,35 @@ 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->request = $this->Controller->request;
$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
@ -547,11 +589,9 @@ class RequestHandlerComponentTest extends CakeTestCase {
*/
function testBeforeRedirectCallbackWithArrayUrl() {
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
App::build(array(
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
), true);
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/')
));
@ -565,7 +605,24 @@ class RequestHandlerComponentTest extends CakeTestCase {
);
$result = ob_get_clean();
$this->assertEqual($result, 'one: first two: second');
App::build();
}
/**
* assure that beforeRedirect with a status code will correctly set the status header
*
* @return void
*/
function testBeforeRedirectCallingHeader() {
$controller =& new RequestHandlerMockController();
$RequestHandler =& new NoStopRequestHandler();
$RequestHandler->request = new RequestHandlerMockCakeRequest();
$RequestHandler->request->setReturnValue('is', true, array('ajax'));
$controller->expectOnce('header', array('HTTP/1.1 403 Forbidden'));
ob_start();
$RequestHandler->beforeRedirect($controller, 'request_handler_test/param_method/first/second', 403);
$result = ob_get_clean();
}
}

View file

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
* @since CakePHP(tm) v 1.2.0.5435

View file

@ -4,14 +4,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
* @since CakePHP(tm) v 1.2.0.5436
@ -339,4 +339,41 @@ class SessionComponentTest extends CakeTestCase {
$Session->destroy('Test');
$this->assertNull($Session->read('Test'));
}
/**
* testSessionTimeout method
*
* @access public
* @return void
*/
function testSessionTimeout() {
session_destroy();
Configure::write('Security.level', 'low');
$Session =& new SessionComponent();
$Session->write('Test', 'some value');
$this->assertEqual($_SESSION['Config']['timeout'], Security::inactiveMins());
$this->assertEqual($_SESSION['Config']['time'], $Session->sessionTime);
$this->assertEqual($Session->time, mktime());
$this->assertEqual($_SESSION['Config']['time'], $Session->time + (Security::inactiveMins() * Configure::read('Session.timeout')));
session_destroy();
Configure::write('Security.level', 'medium');
$Session =& new SessionComponent();
$Session->write('Test', 'some value');
$this->assertEqual($_SESSION['Config']['timeout'], Security::inactiveMins());
$this->assertEqual($_SESSION['Config']['time'], $Session->sessionTime);
$this->assertEqual($Session->time, mktime());
$this->assertEqual($_SESSION['Config']['time'], $Session->time + (Security::inactiveMins() * Configure::read('Session.timeout')));
session_destroy();
Configure::write('Security.level', 'high');
$Session =& new SessionComponent();
$Session->write('Test', 'some value');
$this->assertEqual($_SESSION['Config']['timeout'], Security::inactiveMins());
$this->assertEqual($_SESSION['Config']['time'], $Session->sessionTime);
$this->assertEqual($Session->time, mktime());
$this->assertEqual($_SESSION['Config']['time'], $Session->time + (Security::inactiveMins() * Configure::read('Session.timeout')));
}
}

View file

@ -1240,6 +1240,7 @@ class ControllerTest extends CakeTestCase {
$TestController->ControllerComment->invalidate('some_field', 'error_message');
$TestController->ControllerComment->invalidate('some_field2', 'error_message2');
$comment = new ControllerComment($request);
$comment->set('someVar', 'data');
$result = $TestController->validateErrors($comment);
@ -1248,6 +1249,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

@ -6,14 +6,14 @@
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* Copyright 2005-2010, 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-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs.controller
* @since CakePHP(tm) v 1.2.3

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