Merge branch '1.3-timestamp' into 1.3-misc

This commit is contained in:
mark_story 2009-09-24 00:22:18 -04:00
commit bf3fe1f4f6
34 changed files with 677 additions and 243 deletions

0
app/views/pages/empty Normal file
View file

0
app/webroot/files/empty Normal file
View file

View file

@ -490,7 +490,7 @@ if (!function_exists('file_put_contents')) {
$expires = strtotime($expires, $now); $expires = strtotime($expires, $now);
} }
switch (low($target)) { switch (strtolower($target)) {
case 'cache': case 'cache':
$filename = CACHE . $path; $filename = CACHE . $path;
break; break;

View file

@ -173,8 +173,8 @@ class ApiShell extends Shell {
foreach ($commands as $cmd) { foreach ($commands as $cmd) {
$this->out("{$cmd}\n\n"); $this->out("{$cmd}\n\n");
} }
} elseif (isset($commands[low($this->args[1])])) { } elseif (isset($commands[strtolower($this->args[1])])) {
$this->out($commands[low($this->args[1])] . "\n\n"); $this->out($commands[strtolower($this->args[1])] . "\n\n");
} else { } else {
$this->out("Command '" . $this->args[1] . "' not found"); $this->out("Command '" . $this->args[1] . "' not found");
} }

View file

@ -58,18 +58,12 @@ class SchemaShell extends Shell {
* @access public * @access public
*/ */
function startup() { function startup() {
$name = null; $name = $file = $path = $connection = null;
if (!empty($this->params['name'])) { if (!empty($this->params['name'])) {
$name = $this->params['name']; $name = $this->params['name'];
$this->params['file'] = Inflector::underscore($name); $this->params['file'] = Inflector::underscore($name);
} }
$path = $this->_getPath();
$path = null;
if (!empty($this->params['path'])) {
$path = $this->params['path'];
}
$file = null;
if (empty($this->params['file'])) { if (empty($this->params['file'])) {
$this->params['file'] = 'schema.php'; $this->params['file'] = 'schema.php';
} }
@ -78,7 +72,6 @@ class SchemaShell extends Shell {
} }
$file = $this->params['file']; $file = $this->params['file'];
$connection = null;
if (!empty($this->params['connection'])) { if (!empty($this->params['connection'])) {
$connection = $this->params['connection']; $connection = $this->params['connection'];
} }
@ -86,6 +79,23 @@ class SchemaShell extends Shell {
$this->Schema =& new CakeSchema(compact('name', 'path', 'file', 'connection')); $this->Schema =& new CakeSchema(compact('name', 'path', 'file', 'connection'));
} }
/**
* Get the correct path for the params. Uses path, and plugin to find the correct path.
* path param takes precedence over any plugins specified.
*
* @return mixed string to correct path or null.
**/
function _getPath() {
if (!empty($this->params['path'])) {
return $this->params['path'];
}
if (!empty($this->params['plugin'])) {
$pluginPath = $this->_pluginPath($this->params['plugin']);
return $pluginPath . 'config' . DS . 'schema' . DS;
}
return null;
}
/** /**
* Override main * Override main
* *
@ -107,7 +117,8 @@ class SchemaShell extends Shell {
$this->out($File->read()); $this->out($File->read());
$this->_stop(); $this->_stop();
} else { } else {
$this->err(__('Schema could not be found', true)); $file = $this->Schema->path . DS . $this->params['file'];
$this->err(sprintf(__('Schema file (%s) could not be found.', true), $file));
$this->_stop(); $this->_stop();
} }
} }

View file

@ -92,7 +92,7 @@ class ControllerTask extends Shell {
$actions= $this->bakeActions($controller, $admin); $actions= $this->bakeActions($controller, $admin);
} }
} }
if (!empty($this->args[2]) && $this->args[2] == 'admin') { if (!empty($this->args[2]) && $this->args[2] == 'admin') {
$admin = $this->Project->getAdmin(); $admin = $this->Project->getAdmin();
if ($admin) { if ($admin) {
@ -294,8 +294,8 @@ class ControllerTask extends Shell {
$controllerPath = $this->_controllerPath($controllerName); $controllerPath = $this->_controllerPath($controllerName);
$pluralName = $this->_pluralName($currentModelName); $pluralName = $this->_pluralName($currentModelName);
$singularName = Inflector::variable($currentModelName); $singularName = Inflector::variable($currentModelName);
$singularHumanName = Inflector::humanize($currentModelName); $singularHumanName = $this->_singularHumanName($currentModelName);
$pluralHumanName = Inflector::humanize($controllerName); $pluralHumanName = $this->_pluralName($controllerName);
$this->Template->set(compact('admin', 'controllerPath', 'pluralName', 'singularName', 'singularHumanName', $this->Template->set(compact('admin', 'controllerPath', 'pluralName', 'singularName', 'singularHumanName',
'pluralHumanName', 'modelObj', 'wannaUseSession', 'currentModelName')); 'pluralHumanName', 'modelObj', 'wannaUseSession', 'currentModelName'));

View file

@ -108,7 +108,7 @@ class DbConfigTask extends Shell {
$driver = $this->in('Driver:', array('db2', 'firebird', 'mssql', 'mysql', 'mysqli', 'odbc', 'oracle', 'postgres', 'sqlite', 'sybase'), 'mysql'); $driver = $this->in('Driver:', array('db2', 'firebird', 'mssql', 'mysql', 'mysqli', 'odbc', 'oracle', 'postgres', 'sqlite', 'sybase'), 'mysql');
$persistent = $this->in('Persistent Connection?', array('y', 'n'), 'n'); $persistent = $this->in('Persistent Connection?', array('y', 'n'), 'n');
if (low($persistent) == 'n') { if (strtolower($persistent) == 'n') {
$persistent = 'false'; $persistent = 'false';
} else { } else {
$persistent = 'true'; $persistent = 'true';
@ -124,7 +124,7 @@ class DbConfigTask extends Shell {
$port = $this->in('Port?', null, 'n'); $port = $this->in('Port?', null, 'n');
} }
if (low($port) == 'n') { if (strtolower($port) == 'n') {
$port = null; $port = null;
} }
@ -155,7 +155,7 @@ class DbConfigTask extends Shell {
while ($prefix == '') { while ($prefix == '') {
$prefix = $this->in('Table Prefix?', null, 'n'); $prefix = $this->in('Table Prefix?', null, 'n');
} }
if (low($prefix) == 'n') { if (strtolower($prefix) == 'n') {
$prefix = null; $prefix = null;
} }
@ -163,7 +163,7 @@ class DbConfigTask extends Shell {
while ($encoding == '') { while ($encoding == '') {
$encoding = $this->in('Table encoding?', null, 'n'); $encoding = $this->in('Table encoding?', null, 'n');
} }
if (low($encoding) == 'n') { if (strtolower($encoding) == 'n') {
$encoding = null; $encoding = null;
} }
@ -173,7 +173,7 @@ class DbConfigTask extends Shell {
$schema = $this->in('Table schema?', null, 'n'); $schema = $this->in('Table schema?', null, 'n');
} }
} }
if (low($schema) == 'n') { if (strtolower($schema) == 'n') {
$schema = null; $schema = null;
} }
@ -185,7 +185,7 @@ class DbConfigTask extends Shell {
$dbConfigs[] = $config; $dbConfigs[] = $config;
$doneYet = $this->in('Do you wish to add another database configuration?', null, 'n'); $doneYet = $this->in('Do you wish to add another database configuration?', null, 'n');
if (low($doneYet == 'n')) { if (strtolower($doneYet == 'n')) {
$done = true; $done = true;
} }
} }

View file

@ -419,7 +419,7 @@ class FixtureTask extends Shell {
$this->out('Parameters:'); $this->out('Parameters:');
$this->out("\t-count When using generated data, the number of records to include in the fixture(s)."); $this->out("\t-count When using generated data, the number of records to include in the fixture(s).");
$this->out("\t-connection Which database configuration to use for baking."); $this->out("\t-connection Which database configuration to use for baking.");
$this->out("\t-plugin lowercased_underscored name of plugin to bake fixtures for."); $this->out("\t-plugin CamelCased name of plugin to bake fixtures for.");
$this->out(""); $this->out("");
$this->_stop(); $this->_stop();
} }

View file

@ -405,7 +405,7 @@ class ModelTask extends Shell {
$guess = $methods['numeric']; $guess = $methods['numeric'];
} elseif ($metaData['type'] == 'boolean') { } elseif ($metaData['type'] == 'boolean') {
$guess = $methods['boolean']; $guess = $methods['boolean'];
} elseif ($metaData['type'] == 'datetime' || $metaData['type'] == 'date') { } elseif ($metaData['type'] == 'date') {
$guess = $methods['date']; $guess = $methods['date'];
} elseif ($metaData['type'] == 'time') { } elseif ($metaData['type'] == 'time') {
$guess = $methods['time']; $guess = $methods['time'];
@ -614,7 +614,7 @@ class ModelTask extends Shell {
$prompt = "{$model->name} {$type} {$associations[$type][$i]['alias']}"; $prompt = "{$model->name} {$type} {$associations[$type][$i]['alias']}";
$response = $this->in("{$prompt}?", array('y','n'), 'y'); $response = $this->in("{$prompt}?", array('y','n'), 'y');
if ('n' == low($response)) { if ('n' == strtolower($response)) {
unset($associations[$type][$i]); unset($associations[$type][$i]);
} elseif ($type == 'hasMany') { } elseif ($type == 'hasMany') {
unset($associations['hasOne'][$i]); unset($associations['hasOne'][$i]);
@ -637,7 +637,7 @@ class ModelTask extends Shell {
$prompt = __('Would you like to define some additional model associations?', true); $prompt = __('Would you like to define some additional model associations?', true);
$wannaDoMoreAssoc = $this->in($prompt, array('y','n'), 'n'); $wannaDoMoreAssoc = $this->in($prompt, array('y','n'), 'n');
$possibleKeys = $this->_generatePossibleKeys(); $possibleKeys = $this->_generatePossibleKeys();
while (low($wannaDoMoreAssoc) == 'y') { while (strtolower($wannaDoMoreAssoc) == 'y') {
$assocs = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'); $assocs = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
$this->out(__('What is the association type?', true)); $this->out(__('What is the association type?', true));
$assocType = intval($this->inOptions($assocs, __('Enter a number',true))); $assocType = intval($this->inOptions($assocs, __('Enter a number',true)));

View file

@ -184,7 +184,7 @@ class ProjectTask extends Shell {
function createHome($dir) { function createHome($dir) {
$app = basename($dir); $app = basename($dir);
$path = $dir . 'views' . DS . 'pages' . DS; $path = $dir . 'views' . DS . 'pages' . DS;
$source = CAKE_CORE_INCLUDE_PATH . DS . CAKE . 'console' . DS . 'templates' . DS .'default' . DS . 'views' . DS . 'home.ctp'; $source = CAKE . 'console' . DS . 'templates' . DS .'default' . DS . 'views' . DS . 'home.ctp';
include($source); include($source);
return $this->createFile($path.'home.ctp', $output); return $this->createFile($path.'home.ctp', $output);
} }

View file

@ -414,5 +414,30 @@ class TestTask extends Shell {
} }
return $path . Inflector::underscore($className) . '.test.php'; return $path . Inflector::underscore($className) . '.test.php';
} }
/**
* Show help file.
*
* @return void
**/
function help() {
$this->hr();
$this->out("Usage: cake bake test <type> <class>");
$this->hr();
$this->out('Commands:');
$this->out("");
$this->out("test model post\n\tbakes a test case for the post model.");
$this->out("");
$this->out("test controller comments\n\tbakes a test case for the comments controller.");
$this->out("");
$this->out('Arguments:');
$this->out("\t<type> Can be any of the following 'controller', 'model', 'helper',\n\t'component', 'behavior'.");
$this->out("\t<class> Any existing class for the chosen type.");
$this->out("");
$this->out("Parameters:");
$this->out("\t-plugin CamelCased name of plugin to bake tests for.");
$this->out("");
$this->_stop();
}
} }
?> ?>

View file

@ -284,9 +284,7 @@ class ViewTask extends Shell {
$primaryKey = $modelObj->primaryKey; $primaryKey = $modelObj->primaryKey;
$displayField = $modelObj->displayField; $displayField = $modelObj->displayField;
$singularVar = Inflector::variable($modelClass); $singularVar = Inflector::variable($modelClass);
$pluralVar = Inflector::variable($this->controllerName); $singularHumanName = $this->_singularHumanName($modelClass);
$singularHumanName = Inflector::humanize($modelClass);
$pluralHumanName = Inflector::humanize($this->controllerName);
$schema = $modelObj->schema(); $schema = $modelObj->schema();
$fields = array_keys($schema); $fields = array_keys($schema);
$associations = $this->__associations($modelObj); $associations = $this->__associations($modelObj);
@ -294,13 +292,13 @@ class ViewTask extends Shell {
$primaryKey = null; $primaryKey = null;
$displayField = null; $displayField = null;
$singularVar = Inflector::variable(Inflector::singularize($this->controllerName)); $singularVar = Inflector::variable(Inflector::singularize($this->controllerName));
$pluralVar = Inflector::variable($this->controllerName); $singularHumanName = $this->_singularHumanName($this->controllerName);
$singularHumanName = Inflector::humanize(Inflector::singularize($this->controllerName));
$pluralHumanName = Inflector::humanize($this->controllerName);
$fields = array(); $fields = array();
$schema = array(); $schema = array();
$associations = array(); $associations = array();
} }
$pluralVar = Inflector::variable($this->controllerName);
$pluralHumanName = $this->_pluralHumanName($this->controllerName);
return compact('modelClass', 'schema', 'primaryKey', 'displayField', 'singularVar', 'pluralVar', return compact('modelClass', 'schema', 'primaryKey', 'displayField', 'singularVar', 'pluralVar',
'singularHumanName', 'pluralHumanName', 'fields','associations'); 'singularHumanName', 'pluralHumanName', 'fields','associations');
@ -372,28 +370,12 @@ class ViewTask extends Shell {
/** /**
* Builds content from template and variables * Builds content from template and variables
* *
* @param string $template file to use * @param string $action name to generate content to
* @param array $vars passed for use in templates * @param array $vars passed for use in templates
* @return string content from template * @return string content from template
* @access public * @access public
*/ */
function getContent($template = null, $vars = null) { function getContent($action, $vars = null) {
if (!$template) {
$template = $this->template;
}
$action = $template;
$adminRoute = Configure::read('Routing.admin');
if (!empty($adminRoute) && strpos($template, $adminRoute) !== false) {
$template = str_replace($adminRoute . '_', '', $template);
}
if (in_array($template, array('add', 'edit'))) {
$action = $template;
$template = 'form';
} elseif (preg_match('@(_add|_edit)$@', $template)) {
$action = $template;
$template = str_replace(array('_add', '_edit'), '_form', $template);
}
if (!$vars) { if (!$vars) {
$vars = $this->__loadController(); $vars = $this->__loadController();
} }
@ -401,7 +383,7 @@ class ViewTask extends Shell {
$this->Template->set('action', $action); $this->Template->set('action', $action);
$this->Template->set('plugin', $this->plugin); $this->Template->set('plugin', $this->plugin);
$this->Template->set($vars); $this->Template->set($vars);
$output = $this->Template->generate('views', $template); $output = $this->Template->generate('views', $this->getTemplate($action));
if (!empty($output)) { if (!empty($output)) {
return $output; return $output;
@ -409,6 +391,30 @@ class ViewTask extends Shell {
return false; return false;
} }
/**
* Gets the template name based on the action name
*
* @param string $action name
* @return string template name
* @access public
*/
function getTemplate($action) {
if (!empty($this->template) && $action != $this->template) {
return $this->template;
}
$template = $action;
$adminRoute = Configure::read('Routing.admin');
if (!empty($adminRoute) && strpos($template, $adminRoute) !== false) {
$template = str_replace($adminRoute . '_', '', $template);
}
if (in_array($template, array('add', 'edit'))) {
$template = 'form';
} elseif (preg_match('@(_add|_edit)$@', $template)) {
$template = str_replace(array('_add', '_edit'), '_form', $template);
}
return $template;
}
/** /**
* Displays help contents * Displays help contents
* *

View file

@ -27,10 +27,10 @@
function <?php echo $admin ?>view($id = null) { function <?php echo $admin ?>view($id = null) {
if (!$id) { if (!$id) {
<?php if ($wannaUseSession): ?> <?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('Invalid <?php echo $singularHumanName ?>', true)); $this->Session->setFlash(__('Invalid <?php echo strtolower($singularHumanName) ?>', true));
$this->redirect(array('action' => 'index')); $this->redirect(array('action' => 'index'));
<?php else: ?> <?php else: ?>
$this->flash(__('Invalid <?php echo $singularHumanName; ?>', true), array('action' => 'index')); $this->flash(__('Invalid <?php echo strtolower($singularHumanName); ?>', true), array('action' => 'index'));
<?php endif; ?> <?php endif; ?>
} }
$this->set('<?php echo $singularName; ?>', $this-><?php echo $currentModelName; ?>->read(null, $id)); $this->set('<?php echo $singularName; ?>', $this-><?php echo $currentModelName; ?>->read(null, $id));
@ -42,14 +42,14 @@
$this-><?php echo $currentModelName; ?>->create(); $this-><?php echo $currentModelName; ?>->create();
if ($this-><?php echo $currentModelName; ?>->save($this->data)) { if ($this-><?php echo $currentModelName; ?>->save($this->data)) {
<?php if ($wannaUseSession): ?> <?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo $singularHumanName; ?> has been saved', true)); $this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved', true));
$this->redirect(array('action' => 'index')); $this->redirect(array('action' => 'index'));
<?php else: ?> <?php else: ?>
$this->flash(__('<?php echo $currentModelName; ?> saved.', true), array('action' => 'index')); $this->flash(__('<?php echo ucfirst(strtolower($currentModelName)); ?> saved.', true), array('action' => 'index'));
<?php endif; ?> <?php endif; ?>
} else { } else {
<?php if ($wannaUseSession): ?> <?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo $singularHumanName; ?> could not be saved. Please, try again.', true)); $this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.', true));
<?php endif; ?> <?php endif; ?>
} }
} }
@ -74,23 +74,23 @@
function <?php echo $admin; ?>edit($id = null) { function <?php echo $admin; ?>edit($id = null) {
if (!$id && empty($this->data)) { if (!$id && empty($this->data)) {
<?php if ($wannaUseSession): ?> <?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('Invalid <?php echo $singularHumanName; ?>', true)); $this->Session->setFlash(__('Invalid <?php echo strtolower($singularHumanName); ?>', true));
$this->redirect(array('action' => 'index')); $this->redirect(array('action' => 'index'));
<?php else: ?> <?php else: ?>
$this->flash(__('Invalid <?php echo $singularHumanName; ?>', true), array('action' => 'index')); $this->flash(__('Invalid <?php echo strtolower($singularHumanName); ?>', true), array('action' => 'index'));
<?php endif; ?> <?php endif; ?>
} }
if (!empty($this->data)) { if (!empty($this->data)) {
if ($this-><?php echo $currentModelName; ?>->save($this->data)) { if ($this-><?php echo $currentModelName; ?>->save($this->data)) {
<?php if ($wannaUseSession): ?> <?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo $singularHumanName; ?> has been saved', true)); $this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved', true));
$this->redirect(array('action' => 'index')); $this->redirect(array('action' => 'index'));
<?php else: ?> <?php else: ?>
$this->flash(__('The <?php echo $singularHumanName; ?> has been saved.', true), array('action' => 'index')); $this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.', true), array('action' => 'index'));
<?php endif; ?> <?php endif; ?>
} else { } else {
<?php if ($wannaUseSession): ?> <?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo $singularHumanName; ?> could not be saved. Please, try again.', true)); $this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.', true));
<?php endif; ?> <?php endif; ?>
} }
} }
@ -117,24 +117,24 @@
function <?php echo $admin; ?>delete($id = null) { function <?php echo $admin; ?>delete($id = null) {
if (!$id) { if (!$id) {
<?php if ($wannaUseSession): ?> <?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('Invalid id for <?php echo $singularHumanName; ?>', true)); $this->Session->setFlash(__('Invalid id for <?php echo strtolower($singularHumanName); ?>', true));
$this->redirect(array('action'=>'index')); $this->redirect(array('action'=>'index'));
<?php else: ?> <?php else: ?>
$this->flash(__('Invalid <?php echo $singularHumanName; ?>', true), array('action' => 'index')); $this->flash(__('Invalid <?php echo strtolower($singularHumanName); ?>', true), array('action' => 'index'));
<?php endif; ?> <?php endif; ?>
} }
if ($this-><?php echo $currentModelName; ?>->delete($id)) { if ($this-><?php echo $currentModelName; ?>->delete($id)) {
<?php if ($wannaUseSession): ?> <?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('<?php echo $singularHumanName; ?> deleted', true)); $this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted', true));
$this->redirect(array('action'=>'index')); $this->redirect(array('action'=>'index'));
<?php else: ?> <?php else: ?>
$this->flash(__('<?php echo $singularHumanName; ?> deleted', true), array('action' => 'index')); $this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted', true), array('action' => 'index'));
<?php endif; ?> <?php endif; ?>
} }
<?php if ($wannaUseSession): ?> <?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('<?php echo $singularHumanName; ?> was not deleted', true)); $this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted', true));
<?php else: ?> <?php else: ?>
$this->flash(__('<?php echo $singularHumanName; ?> was not deleted', true), array('action' => 'index')); $this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted', true), array('action' => 'index'));
<?php endif; ?> <?php endif; ?>
$this->redirect(array('action' => 'index')); $this->redirect(array('action' => 'index'));
} }

View file

@ -1,6 +1,4 @@
<?php <?php
/* SVN FILE: $Id$ */
/** /**
* Authentication component * Authentication component
* *
@ -9,24 +7,21 @@
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org) * CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) * Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* *
* Licensed under The MIT License * Licensed under The MIT License
* Redistributions of files must retain the above copyright notice. * Redistributions of files must retain the above copyright notice.
* *
* @filesource * @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
* @package cake * @package cake
* @subpackage cake.cake.libs.controller.components * @subpackage cake.cake.libs.controller.components
* @since CakePHP(tm) v 0.10.0.1076 * @since CakePHP(tm) v 0.10.0.1076
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License * @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/ */
App::import(array('Router', 'Security')); App::import('Core', array('Router', 'Security'), false);
/** /**
* Authentication control component class * Authentication control component class
@ -84,6 +79,14 @@ class AuthComponent extends Object {
*/ */
var $ajaxLogin = null; var $ajaxLogin = null;
/**
* The name of the layout element used on Session::setFlash
*
* @var string
* @access public
*/
var $flashLayout = 'default';
/** /**
* The name of the model that represents users which will be authenticated. Defaults to 'User'. * The name of the model that represents users which will be authenticated. Defaults to 'User'.
* *
@ -330,23 +333,24 @@ class AuthComponent extends Object {
} }
if ($loginAction == $url) { if ($loginAction == $url) {
if (empty($controller->data) || !isset($controller->data[$this->userModel])) { $model =& $this->getModel();
if (empty($controller->data) || !isset($controller->data[$model->alias])) {
if (!$this->Session->check('Auth.redirect') && env('HTTP_REFERER')) { if (!$this->Session->check('Auth.redirect') && env('HTTP_REFERER')) {
$this->Session->write('Auth.redirect', $controller->referer(null, true)); $this->Session->write('Auth.redirect', $controller->referer(null, true));
} }
return false; return false;
} }
$isValid = !empty($controller->data[$this->userModel][$this->fields['username']]) && $isValid = !empty($controller->data[$model->alias][$this->fields['username']]) &&
!empty($controller->data[$this->userModel][$this->fields['password']]); !empty($controller->data[$model->alias][$this->fields['password']]);
if ($isValid) { if ($isValid) {
$username = $controller->data[$this->userModel][$this->fields['username']]; $username = $controller->data[$model->alias][$this->fields['username']];
$password = $controller->data[$this->userModel][$this->fields['password']]; $password = $controller->data[$model->alias][$this->fields['password']];
$data = array( $data = array(
$this->userModel . '.' . $this->fields['username'] => $username, $model->alias . '.' . $this->fields['username'] => $username,
$this->userModel . '.' . $this->fields['password'] => $password $model->alias . '.' . $this->fields['password'] => $password
); );
if ($this->login($data)) { if ($this->login($data)) {
@ -357,13 +361,13 @@ class AuthComponent extends Object {
} }
} }
$this->Session->setFlash($this->loginError, 'default', array(), 'auth'); $this->Session->setFlash($this->loginError, $this->flashLayout, array(), 'auth');
$controller->data[$this->userModel][$this->fields['password']] = null; $controller->data[$model->alias][$this->fields['password']] = null;
return false; return false;
} else { } else {
if (!$this->user()) { if (!$this->user()) {
if (!$this->RequestHandler->isAjax()) { if (!$this->RequestHandler->isAjax()) {
$this->Session->setFlash($this->authError, 'default', array(), 'auth'); $this->Session->setFlash($this->authError, $this->flashLayout, array(), 'auth');
if (!empty($controller->params['url']) && count($controller->params['url']) >= 2) { if (!empty($controller->params['url']) && count($controller->params['url']) >= 2) {
$query = $controller->params['url']; $query = $controller->params['url'];
unset($query['url'], $query['ext']); unset($query['url'], $query['ext']);
@ -427,7 +431,7 @@ class AuthComponent extends Object {
return true; return true;
} }
$this->Session->setFlash($this->authError, 'default', array(), 'auth'); $this->Session->setFlash($this->authError, $this->flashLayout, array(), 'auth');
$controller->redirect($controller->referer(), null, true); $controller->redirect($controller->referer(), null, true);
return false; return false;
} }
@ -582,7 +586,7 @@ class AuthComponent extends Object {
* Takes a list of actions in the current controller for which authentication is not required, or * Takes a list of actions in the current controller for which authentication is not required, or
* no parameters to allow all actions. * no parameters to allow all actions.
* *
* @param string $action Controller action name * @param mixed $action Controller action name or array of actions
* @param string $action Controller action name * @param string $action Controller action name
* @param string ... etc. * @param string ... etc.
* @return void * @return void
@ -596,14 +600,14 @@ class AuthComponent extends Object {
if (isset($args[0]) && is_array($args[0])) { if (isset($args[0]) && is_array($args[0])) {
$args = $args[0]; $args = $args[0];
} }
$this->allowedActions = array_merge($this->allowedActions, $args); $this->allowedActions = array_merge($this->allowedActions, array_map('strtolower', $args));
} }
} }
/** /**
* Removes items from the list of allowed actions. * Removes items from the list of allowed actions.
* *
* @param string $action Controller action name * @param mixed $action Controller action name or array of actions
* @param string $action Controller action name * @param string $action Controller action name
* @param string ... etc. * @param string ... etc.
* @return void * @return void
@ -612,8 +616,11 @@ class AuthComponent extends Object {
*/ */
function deny() { function deny() {
$args = func_get_args(); $args = func_get_args();
if (isset($args[0]) && is_array($args[0])) {
$args = $args[0];
}
foreach ($args as $arg) { foreach ($args as $arg) {
$i = array_search($arg, $this->allowedActions); $i = array_search(strtolower($arg), $this->allowedActions);
if (is_int($i)) { if (is_int($i)) {
unset($this->allowedActions[$i]); unset($this->allowedActions[$i]);
} }
@ -698,7 +705,8 @@ class AuthComponent extends Object {
} }
if ($key == null) { if ($key == null) {
return array($this->userModel => $this->Session->read($this->sessionKey)); $model =& $this->getModel();
return array($model->alias => $this->Session->read($this->sessionKey));
} else { } else {
$user = $this->Session->read($this->sessionKey); $user = $this->Session->read($this->sessionKey);
if (isset($user[$key])) { if (isset($user[$key])) {
@ -764,10 +772,11 @@ class AuthComponent extends Object {
* @return boolean ACO node path * @return boolean ACO node path
* @access public * @access public
*/ */
function action($action = ':controller/:action') { function action($action = ':plugin/:controller/:action') {
$plugin = empty($this->params['plugin']) ? null : Inflector::camelize($this->params['plugin']) . '/';
return str_replace( return str_replace(
array(':controller', ':action'), array(':controller', ':action', ':plugin/'),
array(Inflector::camelize($this->params['controller']), $this->params['action']), array(Inflector::camelize($this->params['controller']), $this->params['action'], $plugin),
$this->actionPath . $action $this->actionPath . $action
); );
} }
@ -817,6 +826,7 @@ class AuthComponent extends Object {
} else { } else {
$conditions = $this->userScope; $conditions = $this->userScope;
} }
$model =& $this->getModel();
if (empty($user)) { if (empty($user)) {
$user = $this->user(); $user = $this->user();
if (empty($user)) { if (empty($user)) {
@ -827,51 +837,47 @@ class AuthComponent extends Object {
return null; return null;
} }
$user = $user->read(); $user = $user->read();
$user = $user[$this->userModel]; $user = $user[$model->alias];
} elseif (is_array($user) && isset($user[$this->userModel])) { } elseif (is_array($user) && isset($user[$model->alias])) {
$user = $user[$this->userModel]; $user = $user[$model->alias];
} }
if (is_array($user) && (isset($user[$this->fields['username']]) || isset($user[$this->userModel . '.' . $this->fields['username']]))) { if (is_array($user) && (isset($user[$this->fields['username']]) || isset($user[$model->alias . '.' . $this->fields['username']]))) {
if (isset($user[$this->fields['username']]) && !empty($user[$this->fields['username']]) && !empty($user[$this->fields['password']])) { if (isset($user[$this->fields['username']]) && !empty($user[$this->fields['username']]) && !empty($user[$this->fields['password']])) {
if (trim($user[$this->fields['username']]) == '=' || trim($user[$this->fields['password']]) == '=') { if (trim($user[$this->fields['username']]) == '=' || trim($user[$this->fields['password']]) == '=') {
return false; return false;
} }
$find = array( $find = array(
$this->userModel.'.'.$this->fields['username'] => $user[$this->fields['username']], $model->alias.'.'.$this->fields['username'] => $user[$this->fields['username']],
$this->userModel.'.'.$this->fields['password'] => $user[$this->fields['password']] $model->alias.'.'.$this->fields['password'] => $user[$this->fields['password']]
); );
} elseif (isset($user[$this->userModel . '.' . $this->fields['username']]) && !empty($user[$this->userModel . '.' . $this->fields['username']])) { } elseif (isset($user[$model->alias . '.' . $this->fields['username']]) && !empty($user[$model->alias . '.' . $this->fields['username']])) {
if (trim($user[$this->userModel . '.' . $this->fields['username']]) == '=' || trim($user[$this->userModel . '.' . $this->fields['password']]) == '=') { if (trim($user[$model->alias . '.' . $this->fields['username']]) == '=' || trim($user[$model->alias . '.' . $this->fields['password']]) == '=') {
return false; return false;
} }
$find = array( $find = array(
$this->userModel.'.'.$this->fields['username'] => $user[$this->userModel . '.' . $this->fields['username']], $model->alias.'.'.$this->fields['username'] => $user[$model->alias . '.' . $this->fields['username']],
$this->userModel.'.'.$this->fields['password'] => $user[$this->userModel . '.' . $this->fields['password']] $model->alias.'.'.$this->fields['password'] => $user[$model->alias . '.' . $this->fields['password']]
); );
} else { } else {
return false; return false;
} }
$model =& $this->getModel();
$data = $model->find(array_merge($find, $conditions), null, null, 0); $data = $model->find(array_merge($find, $conditions), null, null, 0);
if (empty($data) || empty($data[$this->userModel])) { if (empty($data) || empty($data[$model->alias])) {
return null; return null;
} }
} elseif (!empty($user) && is_string($user)) { } elseif (!empty($user) && is_string($user)) {
$model =& $this->getModel();
$data = $model->find(array_merge(array($model->escapeField() => $user), $conditions)); $data = $model->find(array_merge(array($model->escapeField() => $user), $conditions));
if (empty($data) || empty($data[$model->alias])) {
if (empty($data) || empty($data[$this->userModel])) {
return null; return null;
} }
} }
if (!empty($data)) { if (!empty($data)) {
if (!empty($data[$this->userModel][$this->fields['password']])) { if (!empty($data[$model->alias][$this->fields['password']])) {
unset($data[$this->userModel][$this->fields['password']]); unset($data[$model->alias][$this->fields['password']]);
} }
return $data[$this->userModel]; return $data[$model->alias];
} }
return null; return null;
} }
@ -888,9 +894,10 @@ class AuthComponent extends Object {
return $this->authenticate->hashPasswords($data); return $this->authenticate->hashPasswords($data);
} }
if (is_array($data) && isset($data[$this->userModel])) { $model =& $this->getModel();
if (isset($data[$this->userModel][$this->fields['username']]) && isset($data[$this->userModel][$this->fields['password']])) { if (is_array($data) && isset($data[$model->alias])) {
$data[$this->userModel][$this->fields['password']] = $this->password($data[$this->userModel][$this->fields['password']]); if (isset($data[$model->alias][$this->fields['username']]) && isset($data[$model->alias][$this->fields['password']])) {
$data[$model->alias][$this->fields['password']] = $this->password($data[$model->alias][$this->fields['password']]);
} }
} }
return $data; return $data;

View file

@ -90,7 +90,11 @@ class CakeSchema extends Object {
} }
if (empty($options['path'])) { if (empty($options['path'])) {
$this->path = CONFIGS . 'schema'; if (is_dir(CONFIGS . 'schema')) {
$this->path = CONFIGS . 'schema';
} else {
$this->path = CONFIGS . 'sql';
}
} }
$options = array_merge(get_object_vars($this), $options); $options = array_merge(get_object_vars($this), $options);
@ -239,8 +243,6 @@ class CakeSchema extends Object {
foreach ($Object->hasAndBelongsToMany as $Assoc => $assocData) { foreach ($Object->hasAndBelongsToMany as $Assoc => $assocData) {
if (isset($assocData['with'])) { if (isset($assocData['with'])) {
$class = $assocData['with']; $class = $assocData['with'];
} elseif ($assocData['_with']) {
$class = $assocData['_with'];
} }
if (is_object($Object->$class)) { if (is_object($Object->$class)) {
$table = $db->fullTableName($Object->$class, false); $table = $db->fullTableName($Object->$class, false);

View file

@ -224,6 +224,25 @@ class Helper extends Overloadable {
return $webPath; return $webPath;
} }
/**
* Adds a timestamp to a file based resource based on the value of `Asset.timestamp` in
* Configure. If Asset.timestamp is true and debug > 0, or Asset.timestamp == 'force'
* a timestamp will be added.
*
* @param string $path The file path to timestamp, the path must be inside WWW_ROOT
* @return string Path with a timestamp added, or not.
**/
function assetTimestamp($path) {
$timestampEnabled = (
(Configure::read('Asset.timestamp') === true && Configure::read() > 0) ||
Configure::read('Asset.timestamp') === 'force'
);
if (strpos($path, '?') === false && $timestampEnabled) {
$path .= '?' . @filemtime(WWW_ROOT . str_replace('/', DS, $path));
}
return $path;
}
/** /**
* Used to remove harmful tags from content * Used to remove harmful tags from content
* *

View file

@ -373,17 +373,7 @@ class HtmlHelper extends AppHelper {
$path .= '.css'; $path .= '.css';
} }
} }
$url = $this->webroot($this->assetTimestamp($path));
$path = $this->webroot($path);
$url = $path;
$timestampEnabled = (
(Configure::read('Asset.timestamp') === true && Configure::read() > 0) ||
Configure::read('Asset.timestamp') === 'force'
);
if (strpos($path, '?') === false && $timestampEnabled) {
$url .= '?' . @filemtime(WWW_ROOT . str_replace('/', DS, $path));
}
if (Configure::read('Asset.filter.css')) { if (Configure::read('Asset.filter.css')) {
$url = str_replace(CSS_URL, 'ccss/', $url); $url = str_replace(CSS_URL, 'ccss/', $url);
@ -452,21 +442,10 @@ class HtmlHelper extends AppHelper {
if ($url[0] !== '/') { if ($url[0] !== '/') {
$url = JS_URL . $url; $url = JS_URL . $url;
} }
$url = $this->webroot($url); if (strpos($url, '?') === false && strpos($url, '.js') === false) {
if (strpos($url, '?') === false) { $url .= '.js';
if (strpos($url, '.js') === false) {
$url .= '.js';
}
}
$timestampEnabled = (
(Configure::read('Asset.timestamp') === true && Configure::read('debug') > 0) ||
Configure::read('Asset.timestamp') === 'force'
);
if (strpos($url, '?') === false && $timestampEnabled) {
$url .= '?' . @filemtime(WWW_ROOT . str_replace('/', DS, $url));
} }
$url = $this->webroot($this->assetTimestamp($url));
if (Configure::read('Asset.filter.js')) { if (Configure::read('Asset.filter.js')) {
$url = str_replace(JS_URL, 'cjs/', $url); $url = str_replace(JS_URL, 'cjs/', $url);
@ -607,13 +586,11 @@ class HtmlHelper extends AppHelper {
function image($path, $options = array()) { function image($path, $options = array()) {
if (is_array($path)) { if (is_array($path)) {
$path = $this->url($path); $path = $this->url($path);
} elseif ($path[0] === '/') {
$path = $this->webroot($path);
} elseif (strpos($path, '://') === false) { } elseif (strpos($path, '://') === false) {
$path = $this->webroot(IMAGES_URL . $path); if ($path[0] !== '/') {
if ((Configure::read('Asset.timestamp') == true && Configure::read() > 0) || Configure::read('Asset.timestamp') === 'force') { $path = IMAGES_URL . $path;
$path .= '?' . @filemtime(str_replace('/', DS, WWW_ROOT . $path));
} }
$path = $this->webroot($this->assetTimestamp($path));
} }
if (!isset($options['alt'])) { if (!isset($options['alt'])) {

View file

@ -270,16 +270,7 @@ class JavascriptHelper extends AppHelper {
$url .= '.js'; $url .= '.js';
} }
} }
$url = $this->webroot($this->assetTimestamp($url));
$url = $this->webroot($url);
$timestampEnabled = (
(Configure::read('Asset.timestamp') === true && Configure::read() > 0) ||
Configure::read('Asset.timestamp') === 'force'
);
if (strpos($url, '?') === false && $timestampEnabled) {
$url .= '?' . @filemtime(WWW_ROOT . str_replace('/', DS, $url));
}
if (Configure::read('Asset.filter.js')) { if (Configure::read('Asset.filter.js')) {
$url = str_replace(JS_URL, 'cjs/', $url); $url = str_replace(JS_URL, 'cjs/', $url);

View file

@ -160,7 +160,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
function event($type, $callback, $options = array()) { function event($type, $callback, $options = array()) {
$defaults = array('wrap' => true, 'stop' => true); $defaults = array('wrap' => true, 'stop' => true);
$options = array_merge($defaults, $options); $options = array_merge($defaults, $options);
$function = 'function (event) {%s}'; $function = 'function (event) {%s}';
if ($options['wrap'] && $options['stop']) { if ($options['wrap'] && $options['stop']) {
$callback .= "\nreturn false;"; $callback .= "\nreturn false;";
@ -240,7 +240,13 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
} }
$options['url'] = $url; $options['url'] = $url;
if (isset($options['update'])) { if (isset($options['update'])) {
$options['success'] = 'function (msg, status) {$("' . $options['update'] . '").html(msg);}'; $wrapCallbacks = isset($options['wrapCallbacks']) ? $options['wrapCallbacks'] : true;
if ($wrapCallbacks) {
$success = '$("' . $options['update'] . '").html(data);';
} else {
$success = 'function (data, textStatus) {$("' . $options['update'] . '").html(data);}';
}
$options['success'] = $success;
unset($options['update']); unset($options['update']);
} }
$callbacks = array('success', 'error', 'beforeSend', 'complete'); $callbacks = array('success', 'error', 'beforeSend', 'complete');
@ -269,7 +275,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
/** /**
* Create a Draggable element * Create a Draggable element
* *
* Requires both Ui.Core and Ui.Draggable to be loaded. * Requires both Ui.Core and Ui.Draggable to be loaded.
* *
* @param array $options Array of options for the draggable element. * @param array $options Array of options for the draggable element.
@ -283,7 +289,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
/** /**
* Create a Droppable element * Create a Droppable element
* *
* Requires both Ui.Core and Ui.Droppable to be loaded. * Requires both Ui.Core and Ui.Droppable to be loaded.
* *
* @param array $options Array of options for the droppable element. * @param array $options Array of options for the droppable element.
@ -297,7 +303,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
/** /**
* Create a Slider element * Create a Slider element
* *
* Requires both Ui.Core and Ui.Slider to be loaded. * Requires both Ui.Core and Ui.Slider to be loaded.
* *
* @param array $options Array of options for the droppable element. * @param array $options Array of options for the droppable element.
@ -311,9 +317,9 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
} }
/** /**
* Serialize a form attached to $selector. If the current selection is not an input or * Serialize a form attached to $selector. If the current selection is not an input or
* form, errors will be created in the Javascript. * form, errors will be created in the Javascript.
* *
* @param array $options Options for the serialization * @param array $options Options for the serialization
* @return string completed form serialization script * @return string completed form serialization script
* @see JsHelper::serializeForm() for option list. * @see JsHelper::serializeForm() for option list.

View file

@ -115,7 +115,7 @@ class JsHelper extends AppHelper {
* @param string $method Method to be called * @param string $method Method to be called
* @param array $params Parameters for the method being called. * @param array $params Parameters for the method being called.
* @access public * @access public
* @return mixed * @return mixed Depends on the return of the dispatched method, or it could be an instance of the EngineHelper
**/ **/
function call__($method, $params) { function call__($method, $params) {
if (isset($this->{$this->__engineName}) && method_exists($this->{$this->__engineName}, $method)) { if (isset($this->{$this->__engineName}) && method_exists($this->{$this->__engineName}, $method)) {
@ -150,6 +150,20 @@ class JsHelper extends AppHelper {
trigger_error(sprintf(__('JsHelper:: Missing Method %s is undefined', true), $method), E_USER_WARNING); trigger_error(sprintf(__('JsHelper:: Missing Method %s is undefined', true), $method), E_USER_WARNING);
} }
/**
* Workaround for Object::Object() existing. Since Object::object exists, it does not
* fall into call__ and is not passed onto the engine helper. See JsBaseEngineHelper::object() for
* more information on this method.
*
* @param mixed $data Data to convert into JSON
* @param array $options Options to use for encoding JSON. See JsBaseEngineHelper::object() for more details.
* @return string encoded JSON
* @deprecated Remove when support for PHP4 and Object::object are removed.
**/
function object($data = array(), $options = array()) {
return $this->{$this->__engineName}->object($data, $options);
}
/** /**
* Writes all Javascript generated so far to a code block or * Writes all Javascript generated so far to a code block or
* caches them to a file and returns a linked script. * caches them to a file and returns a linked script.
@ -203,7 +217,7 @@ class JsHelper extends AppHelper {
/** /**
* Get all the cached scripts * Get all the cached scripts
* *
* @param boolean $clear Whether or not to clear the script caches * @param boolean $clear Whether or not to clear the script caches (default true)
* @return array Array of scripts added to the request. * @return array Array of scripts added to the request.
**/ **/
function getBuffer($clear = true) { function getBuffer($clear = true) {
@ -919,10 +933,10 @@ class JsBaseEngineHelper extends AppHelper {
} }
/** /**
* Prepare callbacks and wrap them with function ([args]) { } as defined in * Prepare callbacks and wrap them with function ([args]) { } as defined in
* _callbackArgs array. * _callbackArgs array.
* *
* @param string $method Name of the method you are preparing callbacks for. * @param string $method Name of the method you are preparing callbacks for.
* @param array $options Array of options being parsed * @param array $options Array of options being parsed
* @param string $callbacks Additional Keys that contain callbacks * @param string $callbacks Additional Keys that contain callbacks
* @access protected * @access protected

View file

@ -33,7 +33,7 @@ class PaginatorHelper extends AppHelper {
* *
* @var array * @var array
*/ */
var $helpers = array('Html', 'Ajax'); var $helpers = array('Html');
/** /**
* Holds the default model for paged recordsets * Holds the default model for paged recordsets
@ -42,6 +42,13 @@ class PaginatorHelper extends AppHelper {
*/ */
var $__defaultModel = null; var $__defaultModel = null;
/**
* The class used for 'Ajax' pagination links.
*
* @var string
**/
var $_ajaxHelperClass = 'Js';
/** /**
* Holds the default options for pagination links * Holds the default options for pagination links
* *
@ -66,6 +73,33 @@ class PaginatorHelper extends AppHelper {
*/ */
var $options = array(); var $options = array();
/**
* Constructor for the helper. Sets up the helper that is used for creating 'AJAX' links.
*
* Use `var $helpers = array('Paginator' => array('ajax' => 'CustomHelper'));` to set a custom Helper
* or choose a non JsHelper Helper. If you want to use a specific library with JsHelper declare JsHelper and its
* adapter before including PaginatorHelper in your helpers array.
*
* The chosen custom helper must implement a `link()` method.
*
* @return void
**/
function __construct($config = array()) {
$ajaxProvider = isset($config['ajax']) ? $config['ajax'] : 'Js';
$this->helpers[] = $ajaxProvider;
$this->_ajaxHelperClass = $ajaxProvider;
App::import('Helper', $ajaxProvider);
$classname = $ajaxProvider . 'Helper';
if (!method_exists($classname, 'link')) {
$message = sprintf(
__('%s does not implement a link() method, it is incompatible with PaginatorHelper', true),
$classname
);
trigger_error($message, E_USER_WARNING);
}
}
/** /**
* Gets the current paging parameters from the resultset for the given model * Gets the current paging parameters from the resultset for the given model
* *
@ -280,7 +314,7 @@ class PaginatorHelper extends AppHelper {
} }
$url = $this->url($url, true, $model); $url = $this->url($url, true, $model);
$obj = isset($options['update']) ? 'Ajax' : 'Html'; $obj = isset($options['update']) ? $this->_ajaxHelperClass : 'Html';
$url = array_merge(array('page' => $this->current($model)), $url); $url = array_merge(array('page' => $this->current($model)), $url);
$url = array_merge(Set::filter($url, true), array_intersect_key($url, array('plugin'=>true))); $url = array_merge(Set::filter($url, true), array_intersect_key($url, array('plugin'=>true)));
return $this->{$obj}->link($title, $url, $options); return $this->{$obj}->link($title, $url, $options);

View file

@ -148,7 +148,7 @@ class SchemaShellTest extends CakeTestCase {
$this->Shell->startup(); $this->Shell->startup();
$this->assertTrue(isset($this->Shell->Schema)); $this->assertTrue(isset($this->Shell->Schema));
$this->assertTrue(is_a($this->Shell->Schema, 'CakeSchema')); $this->assertTrue(is_a($this->Shell->Schema, 'CakeSchema'));
$this->assertEqual(strtolower($this->Shell->Schema->name), APP_DIR); $this->assertEqual(strtolower($this->Shell->Schema->name), strtolower(APP_DIR));
$this->assertEqual($this->Shell->Schema->file, 'schema.php'); $this->assertEqual($this->Shell->Schema->file, 'schema.php');
unset($this->Shell->Schema); unset($this->Shell->Schema);
@ -168,7 +168,7 @@ class SchemaShellTest extends CakeTestCase {
'path' => '/test/path' 'path' => '/test/path'
); );
$this->Shell->startup(); $this->Shell->startup();
$this->assertEqual(strtolower($this->Shell->Schema->name), APP_DIR); $this->assertEqual(strtolower($this->Shell->Schema->name), strtolower(APP_DIR));
$this->assertEqual($this->Shell->Schema->file, 'other_file.php'); $this->assertEqual($this->Shell->Schema->file, 'other_file.php');
$this->assertEqual($this->Shell->Schema->connection, 'test_suite'); $this->assertEqual($this->Shell->Schema->connection, 'test_suite');
$this->assertEqual($this->Shell->Schema->path, '/test/path'); $this->assertEqual($this->Shell->Schema->path, '/test/path');
@ -354,5 +354,33 @@ class SchemaShellTest extends CakeTestCase {
$this->_fixtures['core.article']->create($this->db); $this->_fixtures['core.article']->create($this->db);
} }
/**
* test that the plugin param creates the correct path in the schema object.
*
* @return void
**/
function testPluginParam() {
App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$this->Shell->params = array(
'plugin' => 'TestPlugin',
'connection' => 'test_suite'
);
$this->Shell->startup();
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'config' . DS . 'schema' . DS;
$this->assertEqual($this->Shell->Schema->path, $expected);
unset($this->Shell->Schema);
$this->Shell->params = array(
'plugin' => 'TestPlugin',
'connection' => 'test_suite',
'path' => '/some/path'
);
$this->Shell->startup();
$expected = '/some/path';
$this->assertEqual($this->Shell->Schema->path, $expected);
}
} }
?> ?>

View file

@ -303,16 +303,16 @@ class ControllerTaskTest extends CakeTestCase {
$this->assertTrue(strpos($result, "\$this->set('articles', \$this->paginate());") !== false); $this->assertTrue(strpos($result, "\$this->set('articles', \$this->paginate());") !== false);
$this->assertTrue(strpos($result, 'function view($id = null)') !== false); $this->assertTrue(strpos($result, 'function view($id = null)') !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(__('Invalid Article', true))") !== false); $this->assertTrue(strpos($result, "\$this->Session->setFlash(__('Invalid article', true))") !== false);
$this->assertTrue(strpos($result, "\$this->set('article', \$this->Article->read(null, \$id)") !== 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, 'function add()') !== false);
$this->assertTrue(strpos($result, 'if (!empty($this->data))') !== 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, 'if ($this->Article->save($this->data))') !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(__('The Article has been saved', true))") !== false); $this->assertTrue(strpos($result, "\$this->Session->setFlash(__('The article has been saved', true))") !== false);
$this->assertTrue(strpos($result, 'function edit($id = null)') !== false); $this->assertTrue(strpos($result, 'function edit($id = null)') !== false);
$this->assertTrue(strpos($result, "\$this->Session->setFlash(__('The Article could not be saved. Please, try again.', true));") !== false); $this->assertTrue(strpos($result, "\$this->Session->setFlash(__('The article could not be saved. Please, try again.', true));") !== false);
$this->assertTrue(strpos($result, 'function delete($id = null)') !== false); $this->assertTrue(strpos($result, 'function delete($id = null)') !== false);
$this->assertTrue(strpos($result, 'if ($this->Article->delete($id))') !== false); $this->assertTrue(strpos($result, 'if ($this->Article->delete($id))') !== false);
@ -346,13 +346,13 @@ class ControllerTaskTest extends CakeTestCase {
$this->assertTrue(strpos($result, "\$this->set('articles', \$this->paginate());") !== false); $this->assertTrue(strpos($result, "\$this->set('articles', \$this->paginate());") !== false);
$this->assertTrue(strpos($result, 'function view($id = null)') !== false); $this->assertTrue(strpos($result, 'function view($id = null)') !== false);
$this->assertTrue(strpos($result, "\$this->flash(__('Invalid Article', true), array('action' => 'index'))") !== false); $this->assertTrue(strpos($result, "\$this->flash(__('Invalid article', true), array('action' => 'index'))") !== false);
$this->assertTrue(strpos($result, "\$this->set('article', \$this->Article->read(null, \$id)") !== 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, 'function add()') !== false);
$this->assertTrue(strpos($result, 'if (!empty($this->data))') !== 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, 'if ($this->Article->save($this->data))') !== false);
$this->assertTrue(strpos($result, "\$this->flash(__('The Article has been saved.', true), array('action' => 'index'))") !== false); $this->assertTrue(strpos($result, "\$this->flash(__('The article has been saved.', true), array('action' => 'index'))") !== false);
$this->assertTrue(strpos($result, 'function edit($id = null)') !== false); $this->assertTrue(strpos($result, 'function edit($id = null)') !== false);
$this->assertTrue(strpos($result, "\$this->Article->Tag->find('list')") !== false); $this->assertTrue(strpos($result, "\$this->Article->Tag->find('list')") !== false);

View file

@ -33,13 +33,11 @@ if (!class_exists('ShellDispatcher')) {
ob_end_clean(); ob_end_clean();
} }
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'view.php'; require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'view.php';
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'controller.php'; require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'controller.php';
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'template.php'; require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'template.php';
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'project.php'; require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'project.php';
Mock::generatePartial( Mock::generatePartial(
'ShellDispatcher', 'TestViewTaskMockShellDispatcher', 'ShellDispatcher', 'TestViewTaskMockShellDispatcher',
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment') array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
@ -120,6 +118,8 @@ class ViewTaskTest extends CakeTestCase {
/** /**
* startTest method * startTest method
* *
* Ensure that the default theme is used
*
* @return void * @return void
* @access public * @access public
*/ */
@ -132,6 +132,7 @@ class ViewTaskTest extends CakeTestCase {
$this->Task->Controller =& new ViewTaskMockControllerTask(); $this->Task->Controller =& new ViewTaskMockControllerTask();
$this->Task->Project =& new ViewTaskMockProjectTask(); $this->Task->Project =& new ViewTaskMockProjectTask();
$this->Task->path = TMP; $this->Task->path = TMP;
$this->Task->Template->params['theme'] = 'default';
} }
/** /**
@ -259,11 +260,11 @@ class ViewTaskTest extends CakeTestCase {
$this->Task->expectAt(0, 'createFile', array( $this->Task->expectAt(0, 'createFile', array(
TMP . 'view_task_comments' . DS . 'view.ctp', TMP . 'view_task_comments' . DS . 'view.ctp',
new PatternExpectation('/ViewTaskComments/') new PatternExpectation('/View Task Comments/')
)); ));
$this->Task->expectAt(1, 'createFile', array( $this->Task->expectAt(1, 'createFile', array(
TMP . 'view_task_comments' . DS . 'edit.ctp', TMP . 'view_task_comments' . DS . 'edit.ctp',
new PatternExpectation('/Edit ViewTaskComment/') new PatternExpectation('/Edit View Task Comment/')
)); ));
$this->Task->expectAt(2, 'createFile', array( $this->Task->expectAt(2, 'createFile', array(
TMP . 'view_task_comments' . DS . 'index.ctp', TMP . 'view_task_comments' . DS . 'index.ctp',
@ -388,16 +389,34 @@ class ViewTaskTest extends CakeTestCase {
)); ));
$this->Task->expectAt(2, 'createFile', array( $this->Task->expectAt(2, 'createFile', array(
TMP . 'view_task_comments' . DS . 'add.ctp', TMP . 'view_task_comments' . DS . 'add.ctp',
new PatternExpectation('/Add ViewTaskComment/') new PatternExpectation('/Add View Task Comment/')
)); ));
$this->Task->expectAt(3, 'createFile', array( $this->Task->expectAt(3, 'createFile', array(
TMP . 'view_task_comments' . DS . 'edit.ctp', TMP . 'view_task_comments' . DS . 'edit.ctp',
new PatternExpectation('/Edit ViewTaskComment/') new PatternExpectation('/Edit View Task Comment/')
)); ));
$this->Task->execute(); $this->Task->execute();
} }
/**
* test `cake bake view posts index list`
*
* @return void
**/
function testExecuteWithAlternateTemplates() {
$this->Task->connection = 'test_suite';
$this->Task->args = array('ViewTaskComments', 'index', 'list');
$this->Task->params = array();
$this->Task->expectCallCount('createFile', 1);
$this->Task->expectAt(0, 'createFile', array(
TMP . 'view_task_comments' . DS . 'list.ctp',
new PatternExpectation('/ViewTaskComment/')
));
$this->Task->execute();
}
/** /**
* test execute into interactive() with admin methods. * test execute into interactive() with admin methods.
* *
@ -425,11 +444,11 @@ class ViewTaskTest extends CakeTestCase {
)); ));
$this->Task->expectAt(2, 'createFile', array( $this->Task->expectAt(2, 'createFile', array(
TMP . 'view_task_comments' . DS . 'admin_add.ctp', TMP . 'view_task_comments' . DS . 'admin_add.ctp',
new PatternExpectation('/Add ViewTaskComment/') new PatternExpectation('/Add View Task Comment/')
)); ));
$this->Task->expectAt(3, 'createFile', array( $this->Task->expectAt(3, 'createFile', array(
TMP . 'view_task_comments' . DS . 'admin_edit.ctp', TMP . 'view_task_comments' . DS . 'admin_edit.ctp',
new PatternExpectation('/Edit ViewTaskComment/') new PatternExpectation('/Edit View Task Comment/')
)); ));
$this->Task->execute(); $this->Task->execute();

View file

@ -66,7 +66,7 @@ class CakeLogTest extends CakeTestCase {
$result = file(LOGS . 'debug.log'); $result = file(LOGS . 'debug.log');
$this->assertEqual(count($result), 1); $this->assertEqual(count($result), 1);
$this->assertPattern( $this->assertPattern(
'/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} Debug: Notice \(8\): Undefined variable: out in \[.+ line \d{2}\]$/', '/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} Notice: Notice \(8\): Undefined variable: out in \[.+ line \d{2}\]$/',
$result[0] $result[0]
); );
@unlink(LOGS . 'debug.log'); @unlink(LOGS . 'debug.log');

View file

@ -1,34 +1,31 @@
<?php <?php
/* SVN FILE: $Id$ */
/** /**
* AutComponentTest file * AuthComponentTest file
* *
* Long description for file * Long description for file
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite> * CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) * Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* *
* Licensed under The Open Group Test Suite License * Licensed under The Open Group Test Suite License
* Redistributions of files must retain the above copyright notice. * Redistributions of files must retain the above copyright notice.
* *
* @filesource * @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) * @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake * @package cake
* @subpackage cake.cake.tests.cases.libs.controller.components * @subpackage cake.cake.tests.cases.libs.controller.components
* @since CakePHP(tm) v 1.2.0.5347 * @since CakePHP(tm) v 1.2.0.5347
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/ */
App::import(array('controller' . DS . 'components' . DS .'auth', 'controller' . DS . 'components' . DS .'acl')); App::import('Component', array('Auth', 'Acl'));
App::import(array('controller' . DS . 'components' . DS . 'acl', 'model' . DS . 'db_acl')); App::import('Model', 'DbAcl');
App::import('Core', 'Xml'); App::import('Core', 'Xml');
Mock::generate('AclComponent', 'AuthTestMockAclComponent');
/** /**
* TestAuthComponent class * TestAuthComponent class
* *
@ -272,6 +269,7 @@ class AuthTestController extends Controller {
* @return void * @return void
*/ */
function beforeFilter() { function beforeFilter() {
$this->Auth->userModel = 'AuthUser';
} }
/** /**
@ -495,11 +493,13 @@ class AuthTest extends CakeTestCase {
$this->Controller =& new AuthTestController(); $this->Controller =& new AuthTestController();
$this->Controller->Component->init($this->Controller); $this->Controller->Component->init($this->Controller);
$this->Controller->Component->initialize($this->Controller);
$this->Controller->beforeFilter();
ClassRegistry::addObject('view', new View($this->Controller)); ClassRegistry::addObject('view', new View($this->Controller));
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
$this->Controller->Session->del('Message.auth'); $this->Controller->Session->delete('Message.auth');
Router::reload(); Router::reload();
@ -517,8 +517,8 @@ class AuthTest extends CakeTestCase {
$_ENV = $this->_env; $_ENV = $this->_env;
Configure::write('Acl', $this->_acl); Configure::write('Acl', $this->_acl);
Configure::write('Security.salt', $this->_securitySalt); Configure::write('Security.salt', $this->_securitySalt);
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
$this->Controller->Session->del('Message.auth'); $this->Controller->Session->delete('Message.auth');
ClassRegistry::flush(); ClassRegistry::flush();
unset($this->Controller, $this->AuthUser); unset($this->Controller, $this->AuthUser);
} }
@ -586,7 +586,7 @@ class AuthTest extends CakeTestCase {
'id' => 1, 'username' => 'mariano', 'created' => '2007-03-17 01:16:23', 'updated' => date('Y-m-d H:i:s') 'id' => 1, 'username' => 'mariano', 'created' => '2007-03-17 01:16:23', 'updated' => date('Y-m-d H:i:s')
)); ));
$this->assertEqual($user, $expected); $this->assertEqual($user, $expected);
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
$this->Controller->data['AuthUser']['username'] = 'blah'; $this->Controller->data['AuthUser']['username'] = 'blah';
$this->Controller->data['AuthUser']['password'] = ''; $this->Controller->data['AuthUser']['password'] = '';
@ -595,7 +595,7 @@ class AuthTest extends CakeTestCase {
$user = $this->Controller->Auth->user(); $user = $this->Controller->Auth->user();
$this->assertFalse($user); $this->assertFalse($user);
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
$this->Controller->data['AuthUser']['username'] = 'now() or 1=1 --'; $this->Controller->data['AuthUser']['username'] = 'now() or 1=1 --';
$this->Controller->data['AuthUser']['password'] = ''; $this->Controller->data['AuthUser']['password'] = '';
@ -604,7 +604,7 @@ class AuthTest extends CakeTestCase {
$user = $this->Controller->Auth->user(); $user = $this->Controller->Auth->user();
$this->assertFalse($user); $this->assertFalse($user);
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
$this->Controller->data['AuthUser']['username'] = 'now() or 1=1 # something'; $this->Controller->data['AuthUser']['username'] = 'now() or 1=1 # something';
$this->Controller->data['AuthUser']['password'] = ''; $this->Controller->data['AuthUser']['password'] = '';
@ -613,7 +613,7 @@ class AuthTest extends CakeTestCase {
$user = $this->Controller->Auth->user(); $user = $this->Controller->Auth->user();
$this->assertFalse($user); $this->assertFalse($user);
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
$this->Controller->Auth->userModel = 'UuidUser'; $this->Controller->Auth->userModel = 'UuidUser';
$this->Controller->Auth->login('47c36f9c-bc00-4d17-9626-4e183ca6822b'); $this->Controller->Auth->login('47c36f9c-bc00-4d17-9626-4e183ca6822b');
@ -623,7 +623,7 @@ class AuthTest extends CakeTestCase {
'id' => '47c36f9c-bc00-4d17-9626-4e183ca6822b', 'title' => 'Unique record 1', 'count' => 2, 'created' => '2008-03-13 01:16:23', 'updated' => '2008-03-13 01:18:31' 'id' => '47c36f9c-bc00-4d17-9626-4e183ca6822b', 'title' => 'Unique record 1', 'count' => 2, 'created' => '2008-03-13 01:16:23', 'updated' => '2008-03-13 01:18:31'
)); ));
$this->assertEqual($user, $expected); $this->assertEqual($user, $expected);
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
} }
/** /**
@ -642,7 +642,7 @@ class AuthTest extends CakeTestCase {
$result = $this->Controller->Auth->startup($this->Controller); $result = $this->Controller->Auth->startup($this->Controller);
$this->assertTrue($result); $this->assertTrue($result);
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
$result = $this->Controller->Auth->startup($this->Controller); $result = $this->Controller->Auth->startup($this->Controller);
$this->assertFalse($result); $this->assertFalse($result);
$this->assertTrue($this->Controller->Session->check('Message.auth')); $this->assertTrue($this->Controller->Session->check('Message.auth'));
@ -673,7 +673,7 @@ class AuthTest extends CakeTestCase {
$this->assertTrue($this->Controller->Session->check('Message.auth')); $this->assertTrue($this->Controller->Session->check('Message.auth'));
$this->assertFalse($result); $this->assertFalse($result);
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
} }
/** /**
@ -695,7 +695,7 @@ class AuthTest extends CakeTestCase {
$result = $this->Controller->Auth->startup($this->Controller); $result = $this->Controller->Auth->startup($this->Controller);
$this->assertTrue($result); $this->assertTrue($result);
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
$this->Controller->Auth->startup($this->Controller); $this->Controller->Auth->startup($this->Controller);
$this->assertTrue($this->Controller->Session->check('Message.auth')); $this->assertTrue($this->Controller->Session->check('Message.auth'));
$result = $this->Controller->Auth->isAuthorized(); $result = $this->Controller->Auth->isAuthorized();
@ -737,7 +737,7 @@ class AuthTest extends CakeTestCase {
$result = $this->Controller->Acl->Aro->save(); $result = $this->Controller->Acl->Aro->save();
$this->assertTrue($result); $this->assertTrue($result);
$this->Controller->Acl->Aco->create(array('alias'=>'Root')); $this->Controller->Acl->Aco->create(array('alias' => 'Root'));
$result = $this->Controller->Acl->Aco->save(); $result = $this->Controller->Acl->Aco->save();
$this->assertTrue($result); $this->assertTrue($result);
@ -759,11 +759,40 @@ class AuthTest extends CakeTestCase {
$this->Controller->Auth->startup($this->Controller); $this->Controller->Auth->startup($this->Controller);
$this->assertTrue($this->Controller->Auth->isAuthorized()); $this->assertTrue($this->Controller->Auth->isAuthorized());
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
$this->Controller->Auth->startup($this->Controller); $this->Controller->Auth->startup($this->Controller);
$this->assertTrue($this->Controller->Session->check('Message.auth')); $this->assertTrue($this->Controller->Session->check('Message.auth'));
} }
/**
* test authorize = 'actions' setting.
*
* @return void
**/
function testAuthorizeActions() {
$this->AuthUser =& new AuthUser();
$user = $this->AuthUser->find();
$this->Controller->Session->write('Auth', $user);
$this->Controller->params['controller'] = 'auth_test';
$this->Controller->params['action'] = 'add';
$this->Controller->Acl =& new AuthTestMockAclComponent();
$this->Controller->Acl->setReturnValue('check', true);
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->userModel = 'AuthUser';
$this->Controller->Auth->authorize = 'actions';
$this->Controller->Auth->actionPath = 'Root/';
$this->Controller->Acl->expectAt(0, 'check', array(
$user, 'Root/AuthTest/add'
));
$this->Controller->Auth->startup($this->Controller);
$this->assertTrue($this->Controller->Auth->isAuthorized());
}
/** /**
* Tests that deny always takes precedence over allow * Tests that deny always takes precedence over allow
* *
@ -774,7 +803,7 @@ class AuthTest extends CakeTestCase {
$this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->allow('*'); $this->Controller->Auth->allow('*');
$this->Controller->Auth->deny('add'); $this->Controller->Auth->deny('add', 'camelcase');
$this->Controller->params['action'] = 'delete'; $this->Controller->params['action'] = 'delete';
$this->assertTrue($this->Controller->Auth->startup($this->Controller)); $this->assertTrue($this->Controller->Auth->startup($this->Controller));
@ -784,6 +813,61 @@ class AuthTest extends CakeTestCase {
$this->Controller->params['action'] = 'Add'; $this->Controller->params['action'] = 'Add';
$this->assertFalse($this->Controller->Auth->startup($this->Controller)); $this->assertFalse($this->Controller->Auth->startup($this->Controller));
$this->Controller->params['action'] = 'camelCase';
$this->assertFalse($this->Controller->Auth->startup($this->Controller));
$this->Controller->Auth->allow('*');
$this->Controller->Auth->deny(array('add', 'camelcase'));
$this->Controller->params['action'] = 'camelCase';
$this->assertFalse($this->Controller->Auth->startup($this->Controller));
}
/**
* test the action() method
*
* @return void
**/
function testActionMethod() {
$this->Controller->params['controller'] = 'auth_test';
$this->Controller->params['action'] = 'add';
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->actionPath = 'ROOT/';
$result = $this->Controller->Auth->action();
$this->assertEqual($result, 'ROOT/AuthTest/add');
$result = $this->Controller->Auth->action(':controller');
$this->assertEqual($result, 'ROOT/AuthTest');
$result = $this->Controller->Auth->action(':controller');
$this->assertEqual($result, 'ROOT/AuthTest');
$this->Controller->params['plugin'] = 'test_plugin';
$this->Controller->params['controller'] = 'auth_test';
$this->Controller->params['action'] = 'add';
$this->Controller->Auth->initialize($this->Controller);
$result = $this->Controller->Auth->action();
$this->assertEqual($result, 'ROOT/TestPlugin/AuthTest/add');
}
/**
* test that deny() converts camel case inputs to lowercase.
*
* @return void
**/
function testDenyWithCamelCaseMethods() {
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->allow('*');
$this->Controller->Auth->deny('add', 'camelCase');
$url = '/auth_test/camelCase';
$this->Controller->params = Router::parse($url);
$this->Controller->params['url']['url'] = Router::normalize($url);
$this->assertFalse($this->Controller->Auth->startup($this->Controller));
} }
/** /**
@ -815,6 +899,17 @@ class AuthTest extends CakeTestCase {
$this->Controller->Auth->allowedActions = array('delete', 'add'); $this->Controller->Auth->allowedActions = array('delete', 'add');
$result = $this->Controller->Auth->startup($this->Controller); $result = $this->Controller->Auth->startup($this->Controller);
$this->assertFalse($result, 'startup() should return false, as action is not allowed. %s'); $this->assertFalse($result, 'startup() should return false, as action is not allowed. %s');
}
function testAllowedActionsSetWithAllowMethod() {
$url = '/auth_test/action_name';
$this->Controller->params = Router::parse($url);
$this->Controller->params['url']['url'] = Router::normalize($url);
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->allow('action_name', 'anotherAction');
$this->assertEqual($this->Controller->Auth->allowedActions, array('action_name', 'anotheraction'));
} }
/** /**
@ -848,7 +943,7 @@ class AuthTest extends CakeTestCase {
$expected = Router::normalize($this->Controller->Auth->loginRedirect); $expected = Router::normalize($this->Controller->Auth->loginRedirect);
$this->assertEqual($expected, $this->Controller->Auth->redirect()); $this->assertEqual($expected, $this->Controller->Auth->redirect());
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
$this->Controller->params['url']['url'] = 'admin/'; $this->Controller->params['url']['url'] = 'admin/';
$this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->initialize($this->Controller);
@ -859,7 +954,7 @@ class AuthTest extends CakeTestCase {
$this->assertTrue($this->Controller->Session->check('Message.auth')); $this->assertTrue($this->Controller->Session->check('Message.auth'));
$this->assertEqual($expected, $this->Controller->Auth->redirect()); $this->assertEqual($expected, $this->Controller->Auth->redirect());
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
//empty referer no session //empty referer no session
$_SERVER['HTTP_REFERER'] = false; $_SERVER['HTTP_REFERER'] = false;
@ -887,7 +982,7 @@ class AuthTest extends CakeTestCase {
$this->assertEqual($expected, $this->Controller->testUrl); $this->assertEqual($expected, $this->Controller->testUrl);
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
$_SERVER['HTTP_REFERER'] = Router::url('/admin/', true); $_SERVER['HTTP_REFERER'] = Router::url('/admin/', true);
$this->Controller->Session->write('Auth', array( $this->Controller->Session->write('Auth', array(
@ -904,7 +999,7 @@ class AuthTest extends CakeTestCase {
//Ticket #4750 //Ticket #4750
//named params //named params
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
$url = '/posts/index/year:2008/month:feb'; $url = '/posts/index/year:2008/month:feb';
$this->Controller->params = Router::parse($url); $this->Controller->params = Router::parse($url);
$this->Controller->params['url']['url'] = Router::normalize($url); $this->Controller->params['url']['url'] = Router::normalize($url);
@ -916,7 +1011,7 @@ class AuthTest extends CakeTestCase {
$this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect'));
//passed args //passed args
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
$url = '/posts/view/1'; $url = '/posts/view/1';
$this->Controller->params = Router::parse($url); $this->Controller->params = Router::parse($url);
$this->Controller->params['url']['url'] = Router::normalize($url); $this->Controller->params['url']['url'] = Router::normalize($url);
@ -934,7 +1029,7 @@ class AuthTest extends CakeTestCase {
'print' => 'true', 'print' => 'true',
'refer' => 'menu' 'refer' => 'menu'
); );
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
$url = '/posts/index/29?print=true&refer=menu'; $url = '/posts/index/29?print=true&refer=menu';
$this->Controller->params = Dispatcher::parseParams($url); $this->Controller->params = Dispatcher::parseParams($url);
$this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->initialize($this->Controller);
@ -950,7 +1045,7 @@ class AuthTest extends CakeTestCase {
'refer' => 'menu', 'refer' => 'menu',
'ext' => 'html' 'ext' => 'html'
); );
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
$url = '/posts/index/29?print=true&refer=menu'; $url = '/posts/index/29?print=true&refer=menu';
$this->Controller->params = Dispatcher::parseParams($url); $this->Controller->params = Dispatcher::parseParams($url);
$this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->initialize($this->Controller);
@ -963,7 +1058,7 @@ class AuthTest extends CakeTestCase {
//external authed action //external authed action
$_SERVER['HTTP_REFERER'] = 'http://webmail.example.com/view/message'; $_SERVER['HTTP_REFERER'] = 'http://webmail.example.com/view/message';
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
$url = '/posts/edit/1'; $url = '/posts/edit/1';
$this->Controller->params = Router::parse($url); $this->Controller->params = Router::parse($url);
$this->Controller->params['url']['url'] = Router::normalize($url); $this->Controller->params['url']['url'] = Router::normalize($url);
@ -976,7 +1071,7 @@ class AuthTest extends CakeTestCase {
//external direct login link //external direct login link
$_SERVER['HTTP_REFERER'] = 'http://webmail.example.com/view/message'; $_SERVER['HTTP_REFERER'] = 'http://webmail.example.com/view/message';
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
$url = '/AuthTest/login'; $url = '/AuthTest/login';
$this->Controller->params = Router::parse($url); $this->Controller->params = Router::parse($url);
$this->Controller->params['url']['url'] = Router::normalize($url); $this->Controller->params['url']['url'] = Router::normalize($url);
@ -988,7 +1083,7 @@ class AuthTest extends CakeTestCase {
$this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect'));
$_SERVER['HTTP_REFERER'] = $backup; $_SERVER['HTTP_REFERER'] = $backup;
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
} }
/** /**
@ -998,7 +1093,7 @@ class AuthTest extends CakeTestCase {
* @return void * @return void
**/ **/
function testNoRedirectOn404() { function testNoRedirectOn404() {
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
$this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->initialize($this->Controller);
$this->Controller->params = Router::parse('auth_test/something_totally_wrong'); $this->Controller->params = Router::parse('auth_test/something_totally_wrong');
$result = $this->Controller->Auth->startup($this->Controller); $result = $this->Controller->Auth->startup($this->Controller);
@ -1033,7 +1128,7 @@ class AuthTest extends CakeTestCase {
$user = $this->Controller->Auth->user(); $user = $this->Controller->Auth->user();
$this->assertTrue($this->Controller->Session->check('Message.auth')); $this->assertTrue($this->Controller->Session->check('Message.auth'));
$this->assertEqual($user, false); $this->assertEqual($user, false);
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
} }
/** /**
@ -1058,7 +1153,7 @@ class AuthTest extends CakeTestCase {
$this->Controller->Auth->startup($this->Controller); $this->Controller->Auth->startup($this->Controller);
$this->assertTrue(is_array($this->Controller->Auth->user())); $this->assertTrue(is_array($this->Controller->Auth->user()));
$this->Controller->Session->del($this->Controller->Auth->sessionKey); $this->Controller->Session->delete($this->Controller->Auth->sessionKey);
$this->Controller->data['AuthUser']['username'] = 'nate'; $this->Controller->data['AuthUser']['username'] = 'nate';
$this->Controller->data['AuthUser']['password'] = 'cake1'; $this->Controller->data['AuthUser']['password'] = 'cake1';
@ -1070,7 +1165,7 @@ class AuthTest extends CakeTestCase {
$this->Controller->Auth->startup($this->Controller); $this->Controller->Auth->startup($this->Controller);
$this->assertTrue(is_null($this->Controller->Auth->user())); $this->assertTrue(is_null($this->Controller->Auth->user()));
$this->Controller->Session->del($this->Controller->Auth->sessionKey); $this->Controller->Session->delete($this->Controller->Auth->sessionKey);
$this->Controller->data['AuthUser']['username'] = '> n'; $this->Controller->data['AuthUser']['username'] = '> n';
$this->Controller->data['AuthUser']['password'] = 'cake'; $this->Controller->data['AuthUser']['password'] = 'cake';
@ -1167,7 +1262,7 @@ class AuthTest extends CakeTestCase {
$user = $this->Controller->Auth->user(); $user = $this->Controller->Auth->user();
$this->assertTrue(!!$user); $this->assertTrue(!!$user);
$this->Controller->Session->del('Auth'); $this->Controller->Session->delete('Auth');
Router::reload(); Router::reload();
Router::connect('/', array('controller' => 'people', 'action' => 'login')); Router::connect('/', array('controller' => 'people', 'action' => 'login'));
$url = '/'; $url = '/';
@ -1260,6 +1355,53 @@ class AuthTest extends CakeTestCase {
Configure::write('Routing.admin', $admin); Configure::write('Routing.admin', $admin);
} }
/**
* testPluginModel method
*
* @access public
* @return void
*/
function testPluginModel() {
// Adding plugins
Cache::delete('object_map', '_cake_core_');
App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS)
), true);
App::objects('plugin', null, false);
$PluginModel =& ClassRegistry::init('TestPlugin.TestPluginAuthUser');
$user['id'] = 1;
$user['username'] = 'gwoo';
$user['password'] = Security::hash(Configure::read('Security.salt') . 'cake');
$PluginModel->save($user, false);
$authUser = $PluginModel->find();
$this->Controller->data['TestPluginAuthUser']['username'] = $authUser['TestPluginAuthUser']['username'];
$this->Controller->data['TestPluginAuthUser']['password'] = 'cake';
$this->Controller->params = Router::parse('auth_test/login');
$this->Controller->params['url']['url'] = 'auth_test/login';
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->loginAction = 'auth_test/login';
$this->Controller->Auth->userModel = 'TestPlugin.TestPluginAuthUser';
$this->Controller->Auth->startup($this->Controller);
$user = $this->Controller->Auth->user();
$expected = array('TestPluginAuthUser' => array(
'id' => 1, 'username' => 'gwoo', 'created' => '2007-03-17 01:16:23', 'updated' => date('Y-m-d H:i:s')
));
$this->assertEqual($user, $expected);
// Reverting changes
Cache::delete('object_map', '_cake_core_');
App::build();
App::objects('plugin', null, false);
}
/** /**
* testAjaxLogin method * testAjaxLogin method
* *

View file

@ -1088,11 +1088,13 @@ class RouterTest extends CakeTestCase {
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
Configure::write('Routing.admin', 'admin'); Configure::write('Routing.admin', 'admin');
$paths = Configure::read('pluginPaths'); $paths = App::path('plugins');
Configure::write('pluginPaths', array( App::build(array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS 'plugins' => array(
)); TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
Configure::write('__objects.plugin', array('test_plugin')); )
), true);
App::objects('plugin', null, false);
Router::reload(); Router::reload();
Router::setRequestInfo(array( Router::setRequestInfo(array(
@ -1107,7 +1109,7 @@ class RouterTest extends CakeTestCase {
$expected = '/admin/test_plugin'; $expected = '/admin/test_plugin';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
Configure::write('pluginPaths', $paths); App::build(array('plugins' => $paths));
} }
/** /**

View file

@ -411,6 +411,41 @@ class HelperTest extends CakeTestCase {
$this->assertEqual($result, "/posts/index/page:1?one=value&amp;two=value&amp;three=purple"); $this->assertEqual($result, "/posts/index/page:1?one=value&amp;two=value&amp;three=purple");
} }
/**
* test assetTimestamp application
*
* @return void
**/
function testAssetTimestamp() {
$_timestamp = Configure::read('Asset.timestamp');
$_debug = Configure::read('debug');
Configure::write('Asset.timestamp', false);
$result = $this->Helper->assetTimestamp(CSS_URL . 'cake.generic.css');
$this->assertEqual($result, CSS_URL . 'cake.generic.css');
Configure::write('Asset.timestamp', true);
Configure::write('debug', 0);
$result = $this->Helper->assetTimestamp(CSS_URL . 'cake.generic.css');
$this->assertEqual($result, CSS_URL . 'cake.generic.css');
Configure::write('Asset.timestamp', true);
Configure::write('debug', 2);
$result = $this->Helper->assetTimestamp(CSS_URL . 'cake.generic.css');
$this->assertPattern('/' . preg_quote(CSS_URL . 'cake.generic.css?', '/') . '[0-9]+/', $result);
Configure::write('Asset.timestamp', 'force');
Configure::write('debug', 0);
$result = $this->Helper->assetTimestamp(CSS_URL . 'cake.generic.css');
$this->assertPattern('/' . preg_quote(CSS_URL . 'cake.generic.css?', '/') . '[0-9]+/', $result);
$result = $this->Helper->assetTimestamp(CSS_URL . 'cake.generic.css?someparam');
$this->assertEqual($result, CSS_URL . 'cake.generic.css?someparam');
Configure::write('debug', $_debug);
Configure::write('Asset.timestamp', $_timestamp);
}
/** /**
* testFieldsWithSameName method * testFieldsWithSameName method
* *

View file

@ -308,6 +308,15 @@ class HtmlHelperTest extends CakeTestCase {
$result = $this->Html->image('cake.icon.gif'); $result = $this->Html->image('cake.icon.gif');
$this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.gif\?\d+/', 'alt' => ''))); $this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.gif\?\d+/', 'alt' => '')));
$webroot = $this->Html->webroot;
$this->Html->webroot = '/testing/longer/';
$result = $this->Html->image('cake.icon.gif');
$expected = array(
'img' => array('src' => 'preg:/\/testing\/longer\/img\/cake\.icon\.gif\?[0-9]+/', 'alt' => '')
);
$this->assertTags($result, $expected);
$this->Html->webroot = $webroot;
} }
/** /**
@ -332,6 +341,16 @@ class HtmlHelperTest extends CakeTestCase {
'src' => 'preg:/themed\/default\/img\/cake\.power\.gif\?\d+/', 'src' => 'preg:/themed\/default\/img\/cake\.power\.gif\?\d+/',
'alt' => '' 'alt' => ''
))); )));
$webroot = $this->Html->webroot;
$this->Html->webroot = '/testing/';
$result = $this->Html->image('cake.power.gif');
$this->assertTags($result, array(
'img' => array(
'src' => 'preg:/\/testing\/themed\/default\/img\/cake\.power\.gif\?\d+/',
'alt' => ''
)));
$this->Html->webroot = $webroot;
} }
/** /**
@ -420,14 +439,14 @@ class HtmlHelperTest extends CakeTestCase {
$webroot = $this->Html->webroot; $webroot = $this->Html->webroot;
$this->Html->webroot = '/testing/'; $this->Html->webroot = '/testing/';
$result = $this->Html->css('cake.generic'); $result = $this->Html->css('cake.generic');
$expected['link']['href'] = 'preg:/\/testing\/css\/cake\.generic\.css\?/'; $expected['link']['href'] = 'preg:/\/testing\/css\/cake\.generic\.css\?[0-9]+/';
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
$this->Html->webroot = $webroot; $this->Html->webroot = $webroot;
$webroot = $this->Html->webroot; $webroot = $this->Html->webroot;
$this->Html->webroot = '/testing/longer/'; $this->Html->webroot = '/testing/longer/';
$result = $this->Html->css('cake.generic'); $result = $this->Html->css('cake.generic');
$expected['link']['href'] = 'preg:/\/testing\/longer\/css\/cake\.generic\.css\?/'; $expected['link']['href'] = 'preg:/\/testing\/longer\/css\/cake\.generic\.css\?[0-9]+/';
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
$this->Html->webroot = $webroot; $this->Html->webroot = $webroot;
} }

View file

@ -278,11 +278,11 @@ class JavascriptTest extends CakeTestCase {
$this->Javascript->webroot = '/testing/'; $this->Javascript->webroot = '/testing/';
$result = $this->Javascript->link('__cake_js_test'); $result = $this->Javascript->link('__cake_js_test');
$this->assertPattern('/^<script[^<>]+src="\/testing\/js\/__cake_js_test\.js\?"[^<>]*>/', $result); $this->assertPattern('/^<script[^<>]+src="\/testing\/js\/__cake_js_test\.js\?\d+"[^<>]*>/', $result);
$this->Javascript->webroot = '/testing/longer/'; $this->Javascript->webroot = '/testing/longer/';
$result = $this->Javascript->link('__cake_js_test'); $result = $this->Javascript->link('__cake_js_test');
$this->assertPattern('/^<script[^<>]+src="\/testing\/longer\/js\/__cake_js_test\.js\?"[^<>]*>/', $result); $this->assertPattern('/^<script[^<>]+src="\/testing\/longer\/js\/__cake_js_test\.js\?\d+"[^<>]*>/', $result);
$this->Javascript->webroot = $webroot; $this->Javascript->webroot = $webroot;
Configure::write('debug', $debug); Configure::write('debug', $debug);

View file

@ -160,6 +160,12 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
$expected = '$.ajax({url:"\\/posts\\/view\\/1"});'; $expected = '$.ajax({url:"\\/posts\\/view\\/1"});';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->Jquery->request(array('controller' => 'posts', 'action' => 'view', 1), array(
'update' => '#content'
));
$expected = '$.ajax({success:function (data, textStatus) {$("#content").html(data);}, url:"\/posts\/view\/1"});';
$this->assertEqual($result, $expected);
$result = $this->Jquery->request('/people/edit/1', array( $result = $this->Jquery->request('/people/edit/1', array(
'method' => 'post', 'method' => 'post',
'before' => 'doBefore', 'before' => 'doBefore',
@ -179,7 +185,7 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
'method' => 'post', 'method' => 'post',
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = '$.ajax({success:function (msg, status) {$("#updated").html(msg);}, type:"post", url:"\\/people\\/edit\\/1"});'; $expected = '$.ajax({success:function (data, textStatus) {$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->Jquery->request('/people/edit/1', array( $result = $this->Jquery->request('/people/edit/1', array(
@ -190,7 +196,7 @@ class JqueryEngineHelperTestCase extends CakeTestCase {
'data' => '$("#someId").serialize()', 'data' => '$("#someId").serialize()',
'wrapCallbacks' => false 'wrapCallbacks' => false
)); ));
$expected = '$.ajax({data:$("#someId").serialize(), success:function (msg, status) {$("#updated").html(msg);}, type:"post", url:"\\/people\\/edit\\/1"});'; $expected = '$.ajax({data:$("#someId").serialize(), success:function (data, textStatus) {$("#updated").html(data);}, type:"post", url:"\\/people\\/edit\\/1"});';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $this->Jquery->request('/people/edit/1', array( $result = $this->Jquery->request('/people/edit/1', array(

View file

@ -419,6 +419,17 @@ CODE;
); );
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
} }
/**
* Test that Object::Object() is not breaking json output in JsHelper
*
* @return void
**/
function testObjectPassThrough() {
$result = $this->Js->object(array('one' => 'first', 'two' => 'second'));
$expected = '{"one":"first","two":"second"}';
$this->assertEqual($result, $expected);
}
} }

View file

@ -23,7 +23,9 @@
* @lastmodified $Date$ * @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/ */
App::import('Helper', array('Html', 'Paginator', 'Form', 'Ajax', 'Javascript')); App::import('Helper', array('Html', 'Paginator', 'Form', 'Ajax', 'Javascript', 'Js'));
Mock::generate('JsHelper', 'PaginatorMockJsHelper');
/** /**
* PaginatorHelperTest class * PaginatorHelperTest class
@ -40,7 +42,7 @@ class PaginatorHelperTest extends CakeTestCase {
* @return void * @return void
*/ */
function setUp() { function setUp() {
$this->Paginator = new PaginatorHelper(); $this->Paginator = new PaginatorHelper(array('ajax' => 'Ajax'));
$this->Paginator->params['paging'] = array( $this->Paginator->params['paging'] = array(
'Article' => array( 'Article' => array(
'current' => 9, 'current' => 9,
@ -1682,5 +1684,31 @@ class PaginatorHelperTest extends CakeTestCase {
); );
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
} }
/**
* test that mock classes injected into paginatorHelper are called when using link()
*
* @return void
**/
function testMockAjaxProviderClassInjection() {
$Paginator =& new PaginatorHelper(array('ajax' => 'PaginatorMockJs'));
$Paginator->params['paging'] = array(
'Article' => array(
'current' => 9,
'count' => 62,
'prevPage' => false,
'nextPage' => true,
'pageCount' => 7,
'defaults' => array(),
'options' => array()
)
);
$Paginator->PaginatorMockJs =& new PaginatorMockJsHelper();
$Paginator->PaginatorMockJs->expectOnce('link');
$result = $Paginator->link('Page 2', array('page' => 2), array('update' => '#content'));
$this->expectError();
$Paginator =& new PaginatorHelper(array('ajax' => 'Form'));
}
} }
?> ?>

View file

@ -0,0 +1,52 @@
<?php
/* SVN FILE: $Id$ */
/**
* Test Plugin Auth User Model
*
*
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework (http://www.cakephp.org)
* Copyright 2006-2008, Cake Software Foundation, Inc.
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.cake.tests.test_app.plugins.test_plugin
* @since CakePHP v 1.2.0.4487
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
class TestPluginAuthUser extends TestPluginAppModel {
/**
* Name property
*
* @var string
*/
var $name = 'TestPluginAuthUser';
/**
* useTable property
*
* @var string
*/
var $useTable = 'auth_users';
/**
* useDbConfig property
*
* @var string 'test_suite'
* @access public
*/
var $useDbConfig = 'test_suite';
}