Merge branch '2.0' of github.com:cakephp/cakephp into 2.0

This commit is contained in:
Jose Lorenzo Rodriguez 2011-10-28 23:46:13 -04:30
commit 66cf86c154
72 changed files with 388 additions and 361 deletions

View file

@ -498,7 +498,7 @@ class SchemaShell extends Shell {
))->addSubcommand('dump', array( ))->addSubcommand('dump', array(
'help' => __d('cake_console', 'Dump database SQL based on a schema file to stdout.'), 'help' => __d('cake_console', 'Dump database SQL based on a schema file to stdout.'),
'parser' => array( 'parser' => array(
'options' => compact('plugin', 'path', 'file', 'name', 'connection'), 'options' => compact('plugin', 'path', 'file', 'name', 'connection', 'write'),
'arguments' => compact('name') 'arguments' => compact('name')
) )
))->addSubcommand('create', array( ))->addSubcommand('create', array(

View file

@ -145,7 +145,7 @@ class TestTask extends BakeTask {
$this->Template->set('fixtures', $this->_fixtures); $this->Template->set('fixtures', $this->_fixtures);
$this->Template->set('plugin', $plugin); $this->Template->set('plugin', $plugin);
$this->Template->set(compact( $this->Template->set(compact(
'className', 'methods', 'type', 'fullClassName', 'mock', 'className', 'methods', 'type', 'fullClassName', 'mock',
'construction', 'realType' 'construction', 'realType'
)); ));
$out = $this->Template->generate('classes', 'test'); $out = $this->Template->generate('classes', 'test');

View file

@ -24,7 +24,7 @@ App::uses('<?php echo $fullClassName; ?>', '<?php echo $realType; ?>');
<?php if ($mock and strtolower($type) == 'controller'): ?> <?php if ($mock and strtolower($type) == 'controller'): ?>
/** /**
* Test<?php echo $fullClassName; ?> * Test<?php echo $fullClassName; ?>
* *
*/ */
class Test<?php echo $fullClassName; ?> extends <?php echo $fullClassName; ?> { class Test<?php echo $fullClassName; ?> extends <?php echo $fullClassName; ?> {

View file

@ -66,7 +66,7 @@
<div class="paging"> <div class="paging">
<?php <?php
echo "<?php\n"; echo "<?php\n";
echo "\t\techo \$this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));\n"; echo "\t\techo \$this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));\n";
echo "\t\techo \$this->Paginator->numbers(array('separator' => ''));\n"; echo "\t\techo \$this->Paginator->numbers(array('separator' => ''));\n";
echo "\t\techo \$this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));\n"; echo "\t\techo \$this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));\n";

View file

@ -2,7 +2,7 @@
/** /**
* This file is loaded automatically by the app/webroot/index.php file after core.php * This file is loaded automatically by the app/webroot/index.php file after core.php
* *
* This file should load/create any application wide configuration settings, such as * This file should load/create any application wide configuration settings, such as
* Caching, Logging, loading additional configuration files. * Caching, Logging, loading additional configuration files.
* *
* You should also use this file to include any files that provide global functions/constants * You should also use this file to include any files that provide global functions/constants

View file

@ -32,7 +32,7 @@
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display')); Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/** /**
* Load all plugin routes. See the CakePlugin documentation on * Load all plugin routes. See the CakePlugin documentation on
* how to customize the loading of plugin routes. * how to customize the loading of plugin routes.
*/ */
CakePlugin::routes(); CakePlugin::routes();

View file

@ -131,7 +131,7 @@ abstract class BaseAuthorize {
* }}} * }}}
* *
* You can use the custom CRUD operations to create additional generic permissions * You can use the custom CRUD operations to create additional generic permissions
* that behave like CRUD operations. Doing this will require additional columns on the * that behave like CRUD operations. Doing this will require additional columns on the
* permissions lookup. When using with DbAcl, you'll have to add additional _admin type columns * permissions lookup. When using with DbAcl, you'll have to add additional _admin type columns
* to the `aros_acos` table. * to the `aros_acos` table.
* *

View file

@ -519,7 +519,7 @@ class AuthComponent extends Component {
* Logs a user out, and returns the login action to redirect to. * Logs a user out, and returns the login action to redirect to.
* Triggers the logout() method of all the authenticate objects, so they can perform * Triggers the logout() method of all the authenticate objects, so they can perform
* custom logout logic. AuthComponent will remove the session data, so * custom logout logic. AuthComponent will remove the session data, so
* there is no need to do that in an authentication object. Logging out * there is no need to do that in an authentication object. Logging out
* will also renew the session id. This helps mitigate issues with session replays. * will also renew the session id. This helps mitigate issues with session replays.
* *
* @return string AuthComponent::$logoutRedirect * @return string AuthComponent::$logoutRedirect

View file

@ -98,7 +98,7 @@ class RequestHandlerComponent extends Component {
/** /**
* Checks to see if a file extension has been parsed by the Router, or if the * Checks to see if a file extension has been parsed by the Router, or if the
* HTTP_ACCEPT_TYPE has matches only one content type with the supported extensions. * HTTP_ACCEPT_TYPE has matches only one content type with the supported extensions.
* If there is only one matching type between the supported content types & extensions, * If there is only one matching type between the supported content types & extensions,
* and the requested mime-types, RequestHandler::$ext is set to that value. * and the requested mime-types, RequestHandler::$ext is set to that value.
* *
* @param Controller $controller A reference to the controller * @param Controller $controller A reference to the controller

View file

@ -433,7 +433,7 @@ class Router {
Router::connect($url, Router::connect($url,
array( array(
'plugin' => $plugin, 'plugin' => $plugin,
'controller' => $urlName, 'controller' => $urlName,
'action' => $params['action'], 'action' => $params['action'],
'[method]' => $params['method'] '[method]' => $params['method']
), ),

View file

@ -157,7 +157,7 @@ class ApcEngineTest extends CakeTestCase {
$result = Cache::read('test_decrement', 'apc'); $result = Cache::read('test_decrement', 'apc');
$this->assertEqual(2, $result); $this->assertEqual(2, $result);
} }
/** /**

View file

@ -352,7 +352,7 @@ class FileEngineTest extends CakeTestCase {
/** /**
* Testing the mask setting in FileEngine * Testing the mask setting in FileEngine
* *
* @return void * @return void
*/ */
public function testMaskSetting() { public function testMaskSetting() {

View file

@ -24,13 +24,13 @@ class TestMemcacheEngine extends MemcacheEngine {
/** /**
* public accessor to _parseServerString * public accessor to _parseServerString
* *
* @param string $server * @param string $server
* @return array * @return array
*/ */
public function parseServerString($server) { public function parseServerString($server) {
return $this->_parseServerString($server); return $this->_parseServerString($server);
} }
public function setMemcache($memcache) { public function setMemcache($memcache) {
$this->_Memcache = $memcache; $this->_Memcache = $memcache;
} }

View file

@ -145,7 +145,7 @@ class WincacheEngineTest extends CakeTestCase {
$result = Cache::read('test_decrement', 'wincache'); $result = Cache::read('test_decrement', 'wincache');
$this->assertEqual(2, $result); $this->assertEqual(2, $result);
} }
/** /**

View file

@ -81,7 +81,7 @@ class AclShellTest extends CakeTestCase {
$this->Task->expects($this->at(4))->method('out') $this->Task->expects($this->at(4))->method('out')
->with($this->stringContains('[3] Gandalf')); ->with($this->stringContains('[3] Gandalf'));
$this->Task->expects($this->at(6))->method('out') $this->Task->expects($this->at(6))->method('out')
->with($this->stringContains('[5] MyModel.2')); ->with($this->stringContains('[5] MyModel.2'));
@ -217,7 +217,7 @@ class AclShellTest extends CakeTestCase {
$this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create'); $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create');
$this->Task->expects($this->at(0))->method('out') $this->Task->expects($this->at(0))->method('out')
->with($this->stringContains('Permission denied'), true); ->with($this->stringContains('Permission denied'), true);
$this->Task->deny(); $this->Task->deny();
$node = $this->Task->Acl->Aro->node(array('model' => 'AuthUser', 'foreign_key' => 2)); $node = $this->Task->Acl->Aro->node(array('model' => 'AuthUser', 'foreign_key' => 2));
@ -264,7 +264,7 @@ class AclShellTest extends CakeTestCase {
->with($this->matchesRegularExpression('/Permission .*granted/'), true); ->with($this->matchesRegularExpression('/Permission .*granted/'), true);
$this->Task->expects($this->at(1))->method('out') $this->Task->expects($this->at(1))->method('out')
->with($this->matchesRegularExpression('/Permission .*inherited/'), true); ->with($this->matchesRegularExpression('/Permission .*inherited/'), true);
$this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create'); $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create');
$this->Task->grant(); $this->Task->grant();
@ -302,7 +302,7 @@ class AclShellTest extends CakeTestCase {
public function testInitDb() { public function testInitDb() {
$this->Task->expects($this->once())->method('dispatchShell') $this->Task->expects($this->once())->method('dispatchShell')
->with('schema create DbAcl'); ->with('schema create DbAcl');
$this->Task->initdb(); $this->Task->initdb();
} }
} }

View file

@ -84,10 +84,10 @@ class BakeShellTest extends CakeTestCase {
$this->Shell->DbConfig = $this->getMock('DbConfigTask', array(), array(&$this->Dispatcher)); $this->Shell->DbConfig = $this->getMock('DbConfigTask', array(), array(&$this->Dispatcher));
$this->Shell->DbConfig->expects($this->once())->method('getConfig')->will($this->returnValue('test')); $this->Shell->DbConfig->expects($this->once())->method('getConfig')->will($this->returnValue('test'));
$this->Shell->Model->expects($this->never())->method('getName'); $this->Shell->Model->expects($this->never())->method('getName');
$this->Shell->Model->expects($this->once())->method('bake')->will($this->returnValue(true)); $this->Shell->Model->expects($this->once())->method('bake')->will($this->returnValue(true));
$this->Shell->Controller->expects($this->once())->method('bake')->will($this->returnValue(true)); $this->Shell->Controller->expects($this->once())->method('bake')->will($this->returnValue(true));
$this->Shell->View->expects($this->once())->method('execute'); $this->Shell->View->expects($this->once())->method('execute');

View file

@ -146,7 +146,7 @@ class CommandListShellTest extends CakeTestCase {
$output = $this->Shell->stdout->output; $output = $this->Shell->stdout->output;
$find = '<shell name="sample" call_as="sample" provider="app" help="sample -h"/>'; $find = '<shell name="sample" call_as="sample" provider="app" help="sample -h"/>';
$this->assertContains($find, $output); $this->assertContains($find, $output);
$find = '<shell name="bake" call_as="bake" provider="CORE" help="bake -h"/>'; $find = '<shell name="bake" call_as="bake" provider="CORE" help="bake -h"/>';

View file

@ -184,7 +184,7 @@ class ShellTest extends CakeTestCase {
$this->assertTrue(isset($this->Shell->Comment)); $this->assertTrue(isset($this->Shell->Comment));
$this->assertInstanceOf('Comment', $this->Shell->Comment); $this->assertInstanceOf('Comment', $this->Shell->Comment);
$this->assertEqual($this->Shell->modelClass, 'Comment'); $this->assertEqual($this->Shell->modelClass, 'Comment');
App::build(); App::build();
} }
@ -832,7 +832,7 @@ TEXT;
/** /**
* Testing camel cased naming of tasks * Testing camel cased naming of tasks
* *
* @return void * @return void
*/ */
public function testShellNaming() { public function testShellNaming() {

View file

@ -40,7 +40,7 @@ class DbConfigTaskTest extends CakeTestCase {
$out = $this->getMock('ConsoleOutput', array(), array(), '', false); $out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Task = $this->getMock('DbConfigTask', $this->Task = $this->getMock('DbConfigTask',
array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest', '_verify'), array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest', '_verify'),
array($out, $out, $in) array($out, $out, $in)
); );

View file

@ -188,7 +188,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->connection = 'test'; $this->Task->connection = 'test';
$this->Task->path = '/my/path/'; $this->Task->path = '/my/path/';
$result = $this->Task->bake('Article', false, array( $result = $this->Task->bake('Article', false, array(
'fromTable' => true, 'fromTable' => true,
'schema' => 'Article', 'schema' => 'Article',
'records' => false 'records' => false
)); ));
@ -209,7 +209,7 @@ class FixtureTaskTest extends CakeTestCase {
$this->Task->expects($this->at(0))->method('createFile') $this->Task->expects($this->at(0))->method('createFile')
->with($filename, $this->stringContains('class ArticleFixture')); ->with($filename, $this->stringContains('class ArticleFixture'));
$this->Task->execute(); $this->Task->execute();
} }

View file

@ -45,12 +45,12 @@ class PluginTaskTest extends CakeTestCase {
$this->out = $this->getMock('ConsoleOutput', array(), array(), '', false); $this->out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$this->in = $this->getMock('ConsoleInput', array(), array(), '', false); $this->in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Task = $this->getMock('PluginTask', $this->Task = $this->getMock('PluginTask',
array('in', 'err', 'createFile', '_stop', 'clear'), array('in', 'err', 'createFile', '_stop', 'clear'),
array($this->out, $this->out, $this->in) array($this->out, $this->out, $this->in)
); );
$this->Task->path = TMP . 'tests' . DS; $this->Task->path = TMP . 'tests' . DS;
$this->_paths = $paths = App::path('plugins'); $this->_paths = $paths = App::path('plugins');
foreach ($paths as $i => $p) { foreach ($paths as $i => $p) {
if (!is_dir($p)) { if (!is_dir($p)) {
@ -84,7 +84,7 @@ class PluginTaskTest extends CakeTestCase {
$path = $this->Task->path . 'BakeTestPlugin'; $path = $this->Task->path . 'BakeTestPlugin';
$this->assertTrue(is_dir($path), 'No plugin dir %s'); $this->assertTrue(is_dir($path), 'No plugin dir %s');
$directories = array( $directories = array(
'Config' . DS . 'Schema', 'Config' . DS . 'Schema',
'Model' . DS . 'Behavior', 'Model' . DS . 'Behavior',
@ -155,7 +155,7 @@ class PluginTaskTest extends CakeTestCase {
$file = $path . DS . 'Model' . DS . 'BakeTestPluginAppModel.php'; $file = $path . DS . 'Model' . DS . 'BakeTestPluginAppModel.php';
$this->Task->expects($this->at(3))->method('createFile') $this->Task->expects($this->at(3))->method('createFile')
->with($file, new PHPUnit_Framework_Constraint_IsAnything()); ->with($file, new PHPUnit_Framework_Constraint_IsAnything());
$this->Task->args = array('BakeTestPlugin'); $this->Task->args = array('BakeTestPlugin');
$this->Task->execute(); $this->Task->execute();
@ -174,7 +174,7 @@ class PluginTaskTest extends CakeTestCase {
$last = count($paths); $last = count($paths);
$paths[] = '/fake/path'; $paths[] = '/fake/path';
$this->Task = $this->getMock('PluginTask', $this->Task = $this->getMock('PluginTask',
array('in', 'out', 'err', 'createFile', '_stop'), array('in', 'out', 'err', 'createFile', '_stop'),
array($this->out, $this->out, $this->in) array($this->out, $this->out, $this->in)
); );
@ -183,7 +183,7 @@ class PluginTaskTest extends CakeTestCase {
// Make sure the added path is filtered out. // Make sure the added path is filtered out.
$this->Task->expects($this->exactly($last)) $this->Task->expects($this->exactly($last))
->method('out'); ->method('out');
$this->Task->expects($this->once()) $this->Task->expects($this->once())
->method('in') ->method('in')
->will($this->returnValue($last)); ->will($this->returnValue($last));

View file

@ -130,7 +130,7 @@ class ProjectTaskTest extends CakeTestCase {
} }
/** /**
* test bake with CakePHP on the include path. The constants should remain commented out. * test bake with CakePHP on the include path. The constants should remain commented out.
* *
* @return void * @return void
*/ */

View file

@ -613,7 +613,7 @@ class ViewTaskTest extends CakeTestCase {
TMP . 'ViewTaskComments' . DS . 'index.ctp', TMP . 'ViewTaskComments' . DS . 'index.ctp',
$this->stringContains('ViewTaskComment') $this->stringContains('ViewTaskComment')
); );
$this->Task->expects($this->at(4))->method('createFile') $this->Task->expects($this->at(4))->method('createFile')
->with( ->with(
TMP . 'ViewTaskComments' . DS . 'view.ctp', TMP . 'ViewTaskComments' . DS . 'view.ctp',
@ -631,7 +631,7 @@ class ViewTaskTest extends CakeTestCase {
TMP . 'ViewTaskComments' . DS . 'edit.ctp', TMP . 'ViewTaskComments' . DS . 'edit.ctp',
$this->stringContains('Edit View Task Comment') $this->stringContains('Edit View Task Comment')
); );
$this->Task->expects($this->exactly(4))->method('createFile'); $this->Task->expects($this->exactly(4))->method('createFile');
$this->Task->execute(); $this->Task->execute();
} }
@ -678,7 +678,7 @@ class ViewTaskTest extends CakeTestCase {
TMP . 'ViewTaskComments' . DS . 'admin_index.ctp', TMP . 'ViewTaskComments' . DS . 'admin_index.ctp',
$this->stringContains('ViewTaskComment') $this->stringContains('ViewTaskComment')
); );
$this->Task->expects($this->at(4))->method('createFile') $this->Task->expects($this->at(4))->method('createFile')
->with( ->with(
TMP . 'ViewTaskComments' . DS . 'admin_view.ctp', TMP . 'ViewTaskComments' . DS . 'admin_view.ctp',
@ -696,7 +696,7 @@ class ViewTaskTest extends CakeTestCase {
TMP . 'ViewTaskComments' . DS . 'admin_edit.ctp', TMP . 'ViewTaskComments' . DS . 'admin_edit.ctp',
$this->stringContains('Edit View Task Comment') $this->stringContains('Edit View Task Comment')
); );
$this->Task->expects($this->exactly(4))->method('createFile'); $this->Task->expects($this->exactly(4))->method('createFile');
$this->Task->execute(); $this->Task->execute();
} }

View file

@ -87,7 +87,7 @@ class ConsoleErrorHandlerTest extends CakeTestCase {
ConsoleErrorHandler::$stderr->expects($this->once())->method('write') ConsoleErrorHandler::$stderr->expects($this->once())->method('write')
->with($this->stringContains('Too many parameters.')); ->with($this->stringContains('Too many parameters.'));
$this->Error->expects($this->once()) $this->Error->expects($this->once())
->method('_stop') ->method('_stop')
->with(1); ->with(1);
@ -102,7 +102,7 @@ class ConsoleErrorHandlerTest extends CakeTestCase {
*/ */
public function testError404Exception() { public function testError404Exception() {
$exception = new NotFoundException('dont use me in cli.'); $exception = new NotFoundException('dont use me in cli.');
ConsoleErrorHandler::$stderr->expects($this->once())->method('write') ConsoleErrorHandler::$stderr->expects($this->once())->method('write')
->with($this->stringContains('dont use me in cli.')); ->with($this->stringContains('dont use me in cli.'));

View file

@ -48,7 +48,7 @@ class ConsoleOptionParserTest extends CakeTestCase {
$this->assertEquals($parser, $result, 'Setting epilog is not chainable'); $this->assertEquals($parser, $result, 'Setting epilog is not chainable');
$this->assertEquals('A test', $parser->epilog(), 'getting value is wrong.'); $this->assertEquals('A test', $parser->epilog(), 'getting value is wrong.');
$result = $parser->epilog(array('A test', 'something')); $result = $parser->epilog(array('A test', 'something'));
$this->assertEquals("A test\nsomething", $parser->epilog(), 'getting value is wrong.'); $this->assertEquals("A test\nsomething", $parser->epilog(), 'getting value is wrong.');
} }
@ -116,7 +116,7 @@ class ConsoleOptionParserTest extends CakeTestCase {
)); ));
$result = $parser->parse(array('--test')); $result = $parser->parse(array('--test'));
$this->assertEquals(array('test' => 'default value', 'help' => false), $result[0], 'Default value did not parse out'); $this->assertEquals(array('test' => 'default value', 'help' => false), $result[0], 'Default value did not parse out');
$parser = new ConsoleOptionParser('test', false); $parser = new ConsoleOptionParser('test', false);
$parser->addOption('test', array( $parser->addOption('test', array(
'default' => 'default value', 'default' => 'default value',
@ -165,7 +165,7 @@ class ConsoleOptionParserTest extends CakeTestCase {
$result = $parser->parse(array('--test', 'value')); $result = $parser->parse(array('--test', 'value'));
$expected = array(array('test' => true, 'help' => false), array('value')); $expected = array(array('test' => true, 'help' => false), array('value'));
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$result = $parser->parse(array('value')); $result = $parser->parse(array('value'));
$expected = array(array('test' => false, 'help' => false), array('value')); $expected = array(array('test' => false, 'help' => false), array('value'));
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
@ -249,7 +249,7 @@ class ConsoleOptionParserTest extends CakeTestCase {
$result = $parser->parse(array('--fail', 'other')); $result = $parser->parse(array('--fail', 'other'));
} }
/** /**
* test parsing short options that do not exist. * test parsing short options that do not exist.
* *
@ -271,7 +271,7 @@ class ConsoleOptionParserTest extends CakeTestCase {
public function testOptionWithChoices() { public function testOptionWithChoices() {
$parser = new ConsoleOptionParser('test', false); $parser = new ConsoleOptionParser('test', false);
$parser->addOption('name', array('choices' => array('mark', 'jose'))); $parser->addOption('name', array('choices' => array('mark', 'jose')));
$result = $parser->parse(array('--name', 'mark')); $result = $parser->parse(array('--name', 'mark'));
$expected = array('name' => 'mark', 'help' => false); $expected = array('name' => 'mark', 'help' => false);
$this->assertEquals($expected, $result[0], 'Got the correct value.'); $this->assertEquals($expected, $result[0], 'Got the correct value.');
@ -519,7 +519,7 @@ TEXT;
$args = $parser->arguments(); $args = $parser->arguments();
$this->assertEquals(2, count($args)); $this->assertEquals(2, count($args));
$commands = $parser->subcommands(); $commands = $parser->subcommands();
$this->assertEquals(1, count($commands)); $this->assertEquals(1, count($commands));
} }
@ -567,7 +567,7 @@ TEXT;
) )
) )
)); ));
$result = $parser->parse(array('--secondary', '--fourth', '4', 'c'), 'sub'); $result = $parser->parse(array('--secondary', '--fourth', '4', 'c'), 'sub');
$expected = array(array( $expected = array(array(
'secondary' => true, 'secondary' => true,

View file

@ -3,7 +3,7 @@
* ActionsAuthorizeTest file * ActionsAuthorizeTest file
* *
* PHP 5 * PHP 5
* *
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org) * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* *
@ -77,7 +77,7 @@ class ActionsAuthorizeTest extends CakeTestCase {
->method('check') ->method('check')
->with($user, '/controllers/Posts/index') ->with($user, '/controllers/Posts/index')
->will($this->returnValue(false)); ->will($this->returnValue(false));
$this->assertFalse($this->auth->authorize($user['User'], $request)); $this->assertFalse($this->auth->authorize($user['User'], $request));
} }
@ -106,7 +106,7 @@ class ActionsAuthorizeTest extends CakeTestCase {
->method('check') ->method('check')
->with($user, '/controllers/Posts/index') ->with($user, '/controllers/Posts/index')
->will($this->returnValue(true)); ->will($this->returnValue(true));
$this->assertTrue($this->auth->authorize($user['User'], $request)); $this->assertTrue($this->auth->authorize($user['User'], $request));
} }

View file

@ -3,7 +3,7 @@
* BasicAuthenticateTest file * BasicAuthenticateTest file
* *
* PHP 5 * PHP 5
* *
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org) * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* *

View file

@ -3,7 +3,7 @@
* ControllerAuthorizeTest file * ControllerAuthorizeTest file
* *
* PHP 5 * PHP 5
* *
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org) * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* *
@ -36,12 +36,12 @@ class ControllerAuthorizeTest extends CakeTestCase {
$this->components->expects($this->any()) $this->components->expects($this->any())
->method('getController') ->method('getController')
->will($this->returnValue($this->controller)); ->will($this->returnValue($this->controller));
$this->auth = new ControllerAuthorize($this->components); $this->auth = new ControllerAuthorize($this->components);
} }
/** /**
* *
* @expectedException CakeException * @expectedException CakeException
*/ */
public function testControllerTypeError() { public function testControllerTypeError() {
@ -74,7 +74,7 @@ class ControllerAuthorizeTest extends CakeTestCase {
public function testAuthorizeSuccess() { public function testAuthorizeSuccess() {
$user = array('User' => array('username' => 'mark')); $user = array('User' => array('username' => 'mark'));
$request = new CakeRequest('/posts/index', false); $request = new CakeRequest('/posts/index', false);
$this->controller->expects($this->once()) $this->controller->expects($this->once())
->method('isAuthorized') ->method('isAuthorized')
->with($user) ->with($user)

View file

@ -3,7 +3,7 @@
* CrudAuthorizeTest file * CrudAuthorizeTest file
* *
* PHP 5 * PHP 5
* *
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org) * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* *
@ -179,7 +179,7 @@ class CrudAuthorizeTest extends CakeTestCase {
public function testAutoPrefixMapActions() { public function testAutoPrefixMapActions() {
Configure::write('Routing.prefixes', array('admin', 'manager')); Configure::write('Routing.prefixes', array('admin', 'manager'));
Router::reload(); Router::reload();
$auth = new CrudAuthorize($this->Components); $auth = new CrudAuthorize($this->Components);
$this->assertTrue(isset($auth->settings['actionMap']['admin_index'])); $this->assertTrue(isset($auth->settings['actionMap']['admin_index']));
} }

View file

@ -3,7 +3,7 @@
* DigestAuthenticateTest file * DigestAuthenticateTest file
* *
* PHP 5 * PHP 5
* *
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org) * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* *

View file

@ -3,7 +3,7 @@
* FormAuthenticateTest file * FormAuthenticateTest file
* *
* PHP 5 * PHP 5
* *
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org) * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* *

View file

@ -76,7 +76,7 @@ class CookieComponentTest extends CakeTestCase {
$this->Cookie = $this->getMock('CookieComponent', array('_setcookie'), array($Collection)); $this->Cookie = $this->getMock('CookieComponent', array('_setcookie'), array($Collection));
$this->Controller = new CookieComponentTestController(); $this->Controller = new CookieComponentTestController();
$this->Cookie->initialize($this->Controller); $this->Cookie->initialize($this->Controller);
$this->Cookie->name = 'CakeTestCookie'; $this->Cookie->name = 'CakeTestCookie';
$this->Cookie->time = 10; $this->Cookie->time = 10;
$this->Cookie->path = '/'; $this->Cookie->path = '/';

View file

@ -453,7 +453,7 @@ class PaginatorComponentTest extends CakeTestCase {
$Controller->params['url'] = array(); $Controller->params['url'] = array();
$Controller->constructClasses(); $Controller->constructClasses();
$Controller->Paginator->settings = array( $Controller->Paginator->settings = array(
'order' => 'PaginatorControllerPost.id DESC', 'order' => 'PaginatorControllerPost.id DESC',
'maxLimit' => 10, 'maxLimit' => 10,
'paramType' => 'named' 'paramType' => 'named'
); );
@ -502,7 +502,7 @@ class PaginatorComponentTest extends CakeTestCase {
} }
/** /**
* test that option merging prefers specific models * test that option merging prefers specific models
* *
* @return void * @return void
*/ */
@ -671,7 +671,7 @@ class PaginatorComponentTest extends CakeTestCase {
->method('hasField') ->method('hasField')
->with('something') ->with('something')
->will($this->returnValue(false)); ->will($this->returnValue(false));
$model->expects($this->at(1)) $model->expects($this->at(1))
->method('hasField') ->method('hasField')
->with('something', true) ->with('something', true)

View file

@ -135,7 +135,7 @@ class SecurityComponentTest extends CakeTestCase {
*/ */
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$request = new CakeRequest('posts/index', false); $request = new CakeRequest('posts/index', false);
$request->addParams(array('controller' => 'posts', 'action' => 'index')); $request->addParams(array('controller' => 'posts', 'action' => 'index'));
$this->Controller = new SecurityTestController($request); $this->Controller = new SecurityTestController($request);
@ -492,7 +492,7 @@ class SecurityComponentTest extends CakeTestCase {
} }
/** /**
* Test that objects can't be passed into the serialized string. This was a vector for RFI and LFI * Test that objects can't be passed into the serialized string. This was a vector for RFI and LFI
* attacks. Thanks to Felix Wilhelm * attacks. Thanks to Felix Wilhelm
* *
* @return void * @return void
@ -641,7 +641,7 @@ class SecurityComponentTest extends CakeTestCase {
$fields = '19464422eafe977ee729c59222af07f983010c5f%3A'; $fields = '19464422eafe977ee729c59222af07f983010c5f%3A';
$this->Controller->request->data = array( $this->Controller->request->data = array(
'User.password' => 'bar', 'User.name' => 'foo', 'User.is_valid' => '1', 'User.password' => 'bar', 'User.name' => 'foo', 'User.is_valid' => '1',
'Tag' => array('Tag' => array(1)), 'Tag' => array('Tag' => array(1)),
'_Token' => compact('key', 'fields', 'unlocked'), '_Token' => compact('key', 'fields', 'unlocked'),
); );
$result = $this->Controller->Security->validatePost($this->Controller); $result = $this->Controller->Security->validatePost($this->Controller);
@ -1056,7 +1056,7 @@ class SecurityComponentTest extends CakeTestCase {
} }
/** /**
* test that csrf checks are skipped for request action. * test that csrf checks are skipped for request action.
* *
* @return void * @return void
*/ */
@ -1073,7 +1073,7 @@ class SecurityComponentTest extends CakeTestCase {
} }
/** /**
* test setting * test setting
* *
* @return void * @return void
*/ */
@ -1117,9 +1117,9 @@ class SecurityComponentTest extends CakeTestCase {
$this->Security->validatePost = false; $this->Security->validatePost = false;
$this->Security->csrfCheck = true; $this->Security->csrfCheck = true;
$this->Security->csrfExpires = '+10 minutes'; $this->Security->csrfExpires = '+10 minutes';
$this->Security->Session->write('_Token.csrfTokens', array('nonce1' => strtotime('+10 minutes'))); $this->Security->Session->write('_Token.csrfTokens', array('nonce1' => strtotime('+10 minutes')));
$this->Controller->request = $this->getMock('CakeRequest', array('is')); $this->Controller->request = $this->getMock('CakeRequest', array('is'));
$this->Controller->request->expects($this->once())->method('is') $this->Controller->request->expects($this->once())->method('is')
->with('post') ->with('post')
@ -1148,7 +1148,7 @@ class SecurityComponentTest extends CakeTestCase {
$this->Security->validatePost = false; $this->Security->validatePost = false;
$this->Security->csrfCheck = true; $this->Security->csrfCheck = true;
$this->Security->csrfExpires = '+10 minutes'; $this->Security->csrfExpires = '+10 minutes';
$this->Security->Session->write('_Token.csrfTokens', array( $this->Security->Session->write('_Token.csrfTokens', array(
'valid' => strtotime('+30 minutes'), 'valid' => strtotime('+30 minutes'),
'poof' => strtotime('-11 minutes'), 'poof' => strtotime('-11 minutes'),
@ -1158,7 +1158,7 @@ class SecurityComponentTest extends CakeTestCase {
$tokens = $this->Security->Session->read('_Token.csrfTokens'); $tokens = $this->Security->Session->read('_Token.csrfTokens');
$this->assertEquals(2, count($tokens), 'Too many tokens left behind'); $this->assertEquals(2, count($tokens), 'Too many tokens left behind');
$this->assertNotEmpty('valid', $tokens, 'Valid token was removed.'); $this->assertNotEmpty('valid', $tokens, 'Valid token was removed.');
} }
/** /**
@ -1170,9 +1170,9 @@ class SecurityComponentTest extends CakeTestCase {
$this->Security->validatePost = false; $this->Security->validatePost = false;
$this->Security->csrfCheck = true; $this->Security->csrfCheck = true;
$this->Security->csrfExpires = '+10 minutes'; $this->Security->csrfExpires = '+10 minutes';
$this->Security->Session->write('_Token.csrfTokens', array('nonce1' => strtotime('+10 minutes'))); $this->Security->Session->write('_Token.csrfTokens', array('nonce1' => strtotime('+10 minutes')));
$this->Controller->request = $this->getMock('CakeRequest', array('is')); $this->Controller->request = $this->getMock('CakeRequest', array('is'));
$this->Controller->request->expects($this->once())->method('is') $this->Controller->request->expects($this->once())->method('is')
->with('post') ->with('post')

View file

@ -274,21 +274,21 @@ class TestController extends ControllerTestAppController {
public function returner() { public function returner() {
return 'I am from the controller.'; return 'I am from the controller.';
} }
protected function protected_m() { protected function protected_m() {
} }
private function private_m() { private function private_m() {
} }
public function _hidden() { public function _hidden() {
} }
public function admin_add() { public function admin_add() {
} }
} }
@ -1319,5 +1319,5 @@ class ControllerTest extends CakeTestCase {
$this->assertEquals('I am from the controller.', $result); $this->assertEquals('I am from the controller.', $result);
} }
} }

View file

@ -238,7 +238,7 @@ class ContainableBehaviorTest extends CakeTestCase {
/** /**
* testBeforeFindWithNonExistingBinding method * testBeforeFindWithNonExistingBinding method
* *
* @expectedException PHPUnit_Framework_Error_Warning * @expectedException PHPUnit_Framework_Error_Warning
* @return void * @return void
*/ */
@ -3304,15 +3304,15 @@ class ContainableBehaviorTest extends CakeTestCase {
$this->assertEqual($expected, array_keys($result)); $this->assertEqual($expected, array_keys($result));
$this->assertTrue(empty($this->Article->hasMany['ArticlesTag'])); $this->assertTrue(empty($this->Article->hasMany['ArticlesTag']));
$this->JoinA =& ClassRegistry::init('JoinA'); $this->JoinA =& ClassRegistry::init('JoinA');
$this->JoinB =& ClassRegistry::init('JoinB'); $this->JoinB =& ClassRegistry::init('JoinB');
$this->JoinC =& ClassRegistry::init('JoinC'); $this->JoinC =& ClassRegistry::init('JoinC');
$this->JoinA->Behaviors->attach('Containable'); $this->JoinA->Behaviors->attach('Containable');
$this->JoinB->Behaviors->attach('Containable'); $this->JoinB->Behaviors->attach('Containable');
$this->JoinC->Behaviors->attach('Containable'); $this->JoinC->Behaviors->attach('Containable');
$this->JoinA->JoinB->find('all', array('contain' => array('JoinA'))); $this->JoinA->JoinB->find('all', array('contain' => array('JoinA')));
$this->JoinA->bindModel(array('hasOne' => array('JoinAsJoinC' => array('joinTable' => 'as_cs'))), false); $this->JoinA->bindModel(array('hasOne' => array('JoinAsJoinC' => array('joinTable' => 'as_cs'))), false);
$result = $this->JoinA->hasOne; $result = $this->JoinA->hasOne;

View file

@ -566,7 +566,7 @@ class CakeSchemaTest extends CakeTestCase {
)); ));
$this->assertFalse(isset($read['tables']['missing']['posts_tags']), 'Join table marked as missing'); $this->assertFalse(isset($read['tables']['missing']['posts_tags']), 'Join table marked as missing');
} }
/** /**
* testSchemaReadWithAppModel method * testSchemaReadWithAppModel method
* *
@ -575,7 +575,7 @@ class CakeSchemaTest extends CakeTestCase {
*/ */
public function testSchemaReadWithAppModel() { public function testSchemaReadWithAppModel() {
$connections = ConnectionManager::enumConnectionObjects(); $connections = ConnectionManager::enumConnectionObjects();
ConnectionManager::drop('default'); ConnectionManager::drop('default');
ConnectionManager::create('default', $connections['test']); ConnectionManager::create('default', $connections['test']);
try { try {
$read = $this->Schema->read(array( $read = $this->Schema->read(array(

View file

@ -92,7 +92,7 @@ class SqlserverTestDb extends Sqlserver {
public function clearFieldMappings() { public function clearFieldMappings() {
$this->_fieldMappings = array(); $this->_fieldMappings = array();
} }
/** /**
* describe method * describe method
* *
@ -568,11 +568,11 @@ class SqlserverTest extends CakeTestCase {
*/ */
public function testGetPrimaryKey() { public function testGetPrimaryKey() {
$schema = $this->model->schema(); $schema = $this->model->schema();
$this->db->describe = $schema; $this->db->describe = $schema;
$result = $this->db->getPrimaryKey($this->model); $result = $this->db->getPrimaryKey($this->model);
$this->assertEqual($result, 'id'); $this->assertEqual($result, 'id');
unset($schema['id']['key']); unset($schema['id']['key']);
$this->db->describe = $schema; $this->db->describe = $schema;
$result = $this->db->getPrimaryKey($this->model); $result = $this->db->getPrimaryKey($this->model);
@ -586,7 +586,7 @@ class SqlserverTest extends CakeTestCase {
*/ */
public function testInsertMulti() { public function testInsertMulti() {
$this->db->describe = $this->model->schema(); $this->db->describe = $this->model->schema();
$fields = array('id', 'name', 'login'); $fields = array('id', 'name', 'login');
$values = array( $values = array(
array(1, 'Larry', 'PhpNut'), array(1, 'Larry', 'PhpNut'),

View file

@ -612,7 +612,7 @@ class DboSourceTest extends CakeTestCase {
$result = Set::extract($log['log'], '/query'); $result = Set::extract($log['log'], '/query');
$expected = array('Query 1', 'Query 2'); $expected = array('Query 1', 'Query 2');
$this->assertEqual($expected, $result); $this->assertEqual($expected, $result);
$oldDebug = Configure::read('debug'); $oldDebug = Configure::read('debug');
Configure::write('debug', 2); Configure::write('debug', 2);
ob_start(); ob_start();

View file

@ -146,7 +146,7 @@ class DatabaseSessionTest extends CakeTestCase {
$result = $this->storage->read('foo'); $result = $this->storage->read('foo');
$expected = 'Some value'; $expected = 'Some value';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$result = $this->storage->read('made up value'); $result = $this->storage->read('made up value');
$this->assertFalse($result); $this->assertFalse($result);
} }
@ -158,7 +158,7 @@ class DatabaseSessionTest extends CakeTestCase {
*/ */
public function testDestroy() { public function testDestroy() {
$this->storage->write('foo', 'Some value'); $this->storage->write('foo', 'Some value');
$this->assertTrue($this->storage->destroy('foo'), 'Destroy failed'); $this->assertTrue($this->storage->destroy('foo'), 'Destroy failed');
$this->assertFalse($this->storage->read('foo'), 'Value still present.'); $this->assertFalse($this->storage->read('foo'), 'Value still present.');
} }

View file

@ -3457,7 +3457,7 @@ class ModelWriteTest extends BaseModelTest {
) )
) )
); );
$this->assertTrue($result[0]['Post']['updated'] >= $newTs); $this->assertTrue($result[0]['Post']['updated'] >= $newTs);
$this->assertTrue($result[1]['Post']['updated'] >= $newTs); $this->assertTrue($result[1]['Post']['updated'] >= $newTs);
$this->assertTrue($result[3]['Post']['updated'] >= $newTs); $this->assertTrue($result[3]['Post']['updated'] >= $newTs);
@ -4372,7 +4372,7 @@ class ModelWriteTest extends BaseModelTest {
$mock = $this->getMock( $mock = $this->getMock(
'DboSource', 'DboSource',
array('connect', 'rollback', 'describe', 'create', 'begin'), array('connect', 'rollback', 'describe', 'create', 'begin'),
array(), array(),
'MockAssociatedTransactionDboSource', 'MockAssociatedTransactionDboSource',
false false
@ -4754,7 +4754,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $TestModel->find('all', array( $result = $TestModel->find('all', array(
'fields' => array('id', 'author_id', 'title', 'body', 'published'), 'fields' => array('id', 'author_id', 'title', 'body', 'published'),
'recursive' => -1, 'recursive' => -1,
'order' => 'Post.id ASC' 'order' => 'Post.id ASC'
)); ));
$errors = array(1 => array('title' => array('This field cannot be left blank'))); $errors = array(1 => array('title' => array('This field cannot be left blank')));
@ -4810,7 +4810,7 @@ class ModelWriteTest extends BaseModelTest {
$result = $TestModel->find('all', array( $result = $TestModel->find('all', array(
'fields' => array('id', 'author_id', 'title', 'body', 'published'), 'fields' => array('id', 'author_id', 'title', 'body', 'published'),
'recursive' => -1, 'recursive' => -1,
'order' => 'Post.id ASC' 'order' => 'Post.id ASC'
)); ));
$this->assertEqual($expected, $result); $this->assertEqual($expected, $result);

View file

@ -85,7 +85,7 @@ class CakeRequestTest extends CakeTestCase {
); );
$request = new CakeRequest('some/path'); $request = new CakeRequest('some/path');
$this->assertEqual($request->query, $_GET); $this->assertEqual($request->query, $_GET);
$_GET = array( $_GET = array(
'one' => 'param', 'one' => 'param',
'two' => 'banana', 'two' => 'banana',
@ -106,7 +106,7 @@ class CakeRequestTest extends CakeTestCase {
$expected = array('one' => 'something', 'two' => 'else'); $expected = array('one' => 'something', 'two' => 'else');
$this->assertEqual($request->query, $expected); $this->assertEqual($request->query, $expected);
$this->assertEquals('some/path?one=something&two=else', $request->url); $this->assertEquals('some/path?one=something&two=else', $request->url);
} }
/** /**
@ -553,7 +553,7 @@ class CakeRequestTest extends CakeTestCase {
public function testHost() { public function testHost() {
$_SERVER['HTTP_HOST'] = 'localhost'; $_SERVER['HTTP_HOST'] = 'localhost';
$request = new CakeRequest('some/path'); $request = new CakeRequest('some/path');
$this->assertEquals('localhost', $request->host()); $this->assertEquals('localhost', $request->host());
} }
@ -617,7 +617,7 @@ class CakeRequestTest extends CakeTestCase {
$_SERVER['HTTP_USER_AGENT'] = 'Android 2.0'; $_SERVER['HTTP_USER_AGENT'] = 'Android 2.0';
$this->assertTrue($request->is('mobile')); $this->assertTrue($request->is('mobile'));
$this->assertTrue($request->isMobile()); $this->assertTrue($request->isMobile());
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 5.1; rv:2.0b6pre) Gecko/20100902 Firefox/4.0b6pre Fennec/2.0b1pre'; $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 5.1; rv:2.0b6pre) Gecko/20100902 Firefox/4.0b6pre Fennec/2.0b1pre';
$this->assertTrue($request->is('mobile')); $this->assertTrue($request->is('mobile'));
$this->assertTrue($request->isMobile()); $this->assertTrue($request->isMobile());
@ -782,7 +782,7 @@ class CakeRequestTest extends CakeTestCase {
public function testAccepts() { public function testAccepts() {
$_SERVER['HTTP_ACCEPT'] = 'text/xml,application/xml;q=0.9,application/xhtml+xml,text/html,text/plain,image/png'; $_SERVER['HTTP_ACCEPT'] = 'text/xml,application/xml;q=0.9,application/xhtml+xml,text/html,text/plain,image/png';
$request = new CakeRequest('/', false); $request = new CakeRequest('/', false);
$result = $request->accepts(); $result = $request->accepts();
$expected = array( $expected = array(
'text/xml', 'application/xhtml+xml', 'text/html', 'text/plain', 'image/png', 'application/xml' 'text/xml', 'application/xhtml+xml', 'text/html', 'text/plain', 'image/png', 'application/xml'
@ -1047,7 +1047,7 @@ class CakeRequestTest extends CakeTestCase {
'IIS - No rewrite base path', 'IIS - No rewrite base path',
array( array(
'App' => array( 'App' => array(
'base' => false, 'base' => false,
'baseUrl' => '/index.php', 'baseUrl' => '/index.php',
'dir' => 'app', 'dir' => 'app',
'webroot' => 'webroot' 'webroot' => 'webroot'
@ -1076,7 +1076,7 @@ class CakeRequestTest extends CakeTestCase {
'IIS - No rewrite with path, no PHP_SELF', 'IIS - No rewrite with path, no PHP_SELF',
array( array(
'App' => array( 'App' => array(
'base' => false, 'base' => false,
'baseUrl' => '/index.php?', 'baseUrl' => '/index.php?',
'dir' => 'app', 'dir' => 'app',
'webroot' => 'webroot' 'webroot' => 'webroot'
@ -1101,21 +1101,21 @@ class CakeRequestTest extends CakeTestCase {
'IIS - No rewrite sub dir 2', 'IIS - No rewrite sub dir 2',
array( array(
'App' => array( 'App' => array(
'base' => false, 'base' => false,
'baseUrl' => '/site/index.php', 'baseUrl' => '/site/index.php',
'dir' => 'app', 'dir' => 'app',
'webroot' => 'webroot', 'webroot' => 'webroot',
), ),
'SERVER' => array( 'SERVER' => array(
'SCRIPT_NAME' => '/site/index.php', 'SCRIPT_NAME' => '/site/index.php',
'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot',
'QUERY_STRING' => '', 'QUERY_STRING' => '',
'REQUEST_URI' => '/site/index.php', 'REQUEST_URI' => '/site/index.php',
'URL' => '/site/index.php', 'URL' => '/site/index.php',
'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\site\\index.php', 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\site\\index.php',
'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot',
'PHP_SELF' => '/site/index.php', 'PHP_SELF' => '/site/index.php',
'argv' => array(), 'argv' => array(),
'argc' => 0 'argc' => 0
), ),
), ),
@ -1129,22 +1129,22 @@ class CakeRequestTest extends CakeTestCase {
'IIS - No rewrite sub dir 2 with path', 'IIS - No rewrite sub dir 2 with path',
array( array(
'App' => array( 'App' => array(
'base' => false, 'base' => false,
'baseUrl' => '/site/index.php', 'baseUrl' => '/site/index.php',
'dir' => 'app', 'dir' => 'app',
'webroot' => 'webroot' 'webroot' => 'webroot'
), ),
'GET' => array('/posts/add' => ''), 'GET' => array('/posts/add' => ''),
'SERVER' => array( 'SERVER' => array(
'SCRIPT_NAME' => '/site/index.php', 'SCRIPT_NAME' => '/site/index.php',
'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot',
'QUERY_STRING' => '/posts/add', 'QUERY_STRING' => '/posts/add',
'REQUEST_URI' => '/site/index.php/posts/add', 'REQUEST_URI' => '/site/index.php/posts/add',
'URL' => '/site/index.php/posts/add', 'URL' => '/site/index.php/posts/add',
'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\site\\index.php', 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\site\\index.php',
'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot',
'PHP_SELF' => '/site/index.php/posts/add', 'PHP_SELF' => '/site/index.php/posts/add',
'argv' => array('/posts/add'), 'argv' => array('/posts/add'),
'argc' => 1 'argc' => 1
), ),
), ),
@ -1158,16 +1158,16 @@ class CakeRequestTest extends CakeTestCase {
'Apache - No rewrite, document root set to webroot, requesting path', 'Apache - No rewrite, document root set to webroot, requesting path',
array( array(
'App' => array( 'App' => array(
'base' => false, 'base' => false,
'baseUrl' => '/index.php', 'baseUrl' => '/index.php',
'dir' => 'app', 'dir' => 'app',
'webroot' => 'webroot' 'webroot' => 'webroot'
), ),
'SERVER' => array( 'SERVER' => array(
'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot',
'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php',
'QUERY_STRING' => '', 'QUERY_STRING' => '',
'REQUEST_URI' => '/index.php/posts/index', 'REQUEST_URI' => '/index.php/posts/index',
'SCRIPT_NAME' => '/index.php', 'SCRIPT_NAME' => '/index.php',
'PATH_INFO' => '/posts/index', 'PATH_INFO' => '/posts/index',
'PHP_SELF' => '/index.php/posts/index', 'PHP_SELF' => '/index.php/posts/index',
@ -1183,19 +1183,19 @@ class CakeRequestTest extends CakeTestCase {
'Apache - No rewrite, document root set to webroot, requesting root', 'Apache - No rewrite, document root set to webroot, requesting root',
array( array(
'App' => array( 'App' => array(
'base' => false, 'base' => false,
'baseUrl' => '/index.php', 'baseUrl' => '/index.php',
'dir' => 'app', 'dir' => 'app',
'webroot' => 'webroot' 'webroot' => 'webroot'
), ),
'SERVER' => array( 'SERVER' => array(
'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot',
'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php',
'QUERY_STRING' => '', 'QUERY_STRING' => '',
'REQUEST_URI' => '/index.php', 'REQUEST_URI' => '/index.php',
'SCRIPT_NAME' => '/index.php', 'SCRIPT_NAME' => '/index.php',
'PATH_INFO' => '', 'PATH_INFO' => '',
'PHP_SELF' => '/index.php', 'PHP_SELF' => '/index.php',
), ),
), ),
array( array(
@ -1208,16 +1208,16 @@ class CakeRequestTest extends CakeTestCase {
'Apache - No rewrite, document root set above top level cake dir, requesting path', 'Apache - No rewrite, document root set above top level cake dir, requesting path',
array( array(
'App' => array( 'App' => array(
'base' => false, 'base' => false,
'baseUrl' => '/site/index.php', 'baseUrl' => '/site/index.php',
'dir' => 'app', 'dir' => 'app',
'webroot' => 'webroot' 'webroot' => 'webroot'
), ),
'SERVER' => array( 'SERVER' => array(
'SERVER_NAME' => 'localhost', 'SERVER_NAME' => 'localhost',
'DOCUMENT_ROOT' => '/Library/WebServer/Documents', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents',
'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php',
'REQUEST_URI' => '/site/index.php/posts/index', 'REQUEST_URI' => '/site/index.php/posts/index',
'SCRIPT_NAME' => '/site/index.php', 'SCRIPT_NAME' => '/site/index.php',
'PATH_INFO' => '/posts/index', 'PATH_INFO' => '/posts/index',
'PHP_SELF' => '/site/index.php/posts/index', 'PHP_SELF' => '/site/index.php/posts/index',
@ -1233,15 +1233,15 @@ class CakeRequestTest extends CakeTestCase {
'Apache - No rewrite, document root set above top level cake dir, request root, no PATH_INFO', 'Apache - No rewrite, document root set above top level cake dir, request root, no PATH_INFO',
array( array(
'App' => array( 'App' => array(
'base' => false, 'base' => false,
'baseUrl' => '/site/index.php', 'baseUrl' => '/site/index.php',
'dir' => 'app', 'dir' => 'app',
'webroot' => 'webroot' 'webroot' => 'webroot'
), ),
'SERVER' => array( 'SERVER' => array(
'SERVER_NAME' => 'localhost', 'SERVER_NAME' => 'localhost',
'DOCUMENT_ROOT' => '/Library/WebServer/Documents', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents',
'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php',
'REQUEST_URI' => '/site/index.php/', 'REQUEST_URI' => '/site/index.php/',
'SCRIPT_NAME' => '/site/index.php', 'SCRIPT_NAME' => '/site/index.php',
'PHP_SELF' => '/site/index.php/', 'PHP_SELF' => '/site/index.php/',
@ -1257,17 +1257,17 @@ class CakeRequestTest extends CakeTestCase {
'Apache - No rewrite, document root set above top level cake dir, request path, with GET', 'Apache - No rewrite, document root set above top level cake dir, request path, with GET',
array( array(
'App' => array( 'App' => array(
'base' => false, 'base' => false,
'baseUrl' => '/site/index.php', 'baseUrl' => '/site/index.php',
'dir' => 'app', 'dir' => 'app',
'webroot' => 'webroot' 'webroot' => 'webroot'
), ),
'GET' => array('a' => 'b', 'c' => 'd'), 'GET' => array('a' => 'b', 'c' => 'd'),
'SERVER' => array( 'SERVER' => array(
'SERVER_NAME' => 'localhost', 'SERVER_NAME' => 'localhost',
'DOCUMENT_ROOT' => '/Library/WebServer/Documents', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents',
'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php',
'REQUEST_URI' => '/site/index.php/posts/index?a=b&c=d', 'REQUEST_URI' => '/site/index.php/posts/index?a=b&c=d',
'SCRIPT_NAME' => '/site/index.php', 'SCRIPT_NAME' => '/site/index.php',
'PATH_INFO' => '/posts/index', 'PATH_INFO' => '/posts/index',
'PHP_SELF' => '/site/index.php/posts/index', 'PHP_SELF' => '/site/index.php/posts/index',
@ -1291,9 +1291,9 @@ class CakeRequestTest extends CakeTestCase {
'webroot' => 'webroot' 'webroot' => 'webroot'
), ),
'SERVER' => array( 'SERVER' => array(
'SERVER_NAME' => 'localhost', 'SERVER_NAME' => 'localhost',
'DOCUMENT_ROOT' => '/Library/WebServer/Documents', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents',
'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php',
'REQUEST_URI' => '/site/', 'REQUEST_URI' => '/site/',
'SCRIPT_NAME' => '/site/app/webroot/index.php', 'SCRIPT_NAME' => '/site/app/webroot/index.php',
'PHP_SELF' => '/site/app/webroot/index.php', 'PHP_SELF' => '/site/app/webroot/index.php',
@ -1315,9 +1315,9 @@ class CakeRequestTest extends CakeTestCase {
'webroot' => 'webroot' 'webroot' => 'webroot'
), ),
'SERVER' => array( 'SERVER' => array(
'SERVER_NAME' => 'localhost', 'SERVER_NAME' => 'localhost',
'DOCUMENT_ROOT' => '/Library/WebServer/Documents', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents',
'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php',
'SCRIPT_NAME' => '/site/app/webroot/index.php', 'SCRIPT_NAME' => '/site/app/webroot/index.php',
'PHP_SELF' => '/site/app/webroot/index.php', 'PHP_SELF' => '/site/app/webroot/index.php',
'PATH_INFO' => null, 'PATH_INFO' => null,
@ -1340,9 +1340,9 @@ class CakeRequestTest extends CakeTestCase {
'webroot' => 'webroot' 'webroot' => 'webroot'
), ),
'SERVER' => array( 'SERVER' => array(
'SERVER_NAME' => 'localhost', 'SERVER_NAME' => 'localhost',
'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot',
'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php',
'SCRIPT_NAME' => '/index.php', 'SCRIPT_NAME' => '/index.php',
'PHP_SELF' => '/index.php', 'PHP_SELF' => '/index.php',
'PATH_INFO' => null, 'PATH_INFO' => null,
@ -1366,9 +1366,9 @@ class CakeRequestTest extends CakeTestCase {
), ),
'GET' => array('/posts/add' => ''), 'GET' => array('/posts/add' => ''),
'SERVER' => array( 'SERVER' => array(
'SERVER_NAME' => 'localhost', 'SERVER_NAME' => 'localhost',
'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot',
'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php',
'SCRIPT_NAME' => '/index.php', 'SCRIPT_NAME' => '/index.php',
'QUERY_STRING' => '/posts/add&', 'QUERY_STRING' => '/posts/add&',
'PHP_SELF' => '/index.php', 'PHP_SELF' => '/index.php',
@ -1438,7 +1438,7 @@ class CakeRequestTest extends CakeTestCase {
$request = new CakeRequest('posts/index'); $request = new CakeRequest('posts/index');
$result = $request->data('Model.new_value', 'new value'); $result = $request->data('Model.new_value', 'new value');
$this->assertSame($result, $request, 'Return was not $this'); $this->assertSame($result, $request, 'Return was not $this');
$this->assertEquals($request->data['Model']['new_value'], 'new value'); $this->assertEquals($request->data['Model']['new_value'], 'new value');
$request->data('Post.title', 'New post')->data('Comment.1.author', 'Mark'); $request->data('Post.title', 'New post')->data('Comment.1.author', 'Mark');
@ -1456,13 +1456,13 @@ class CakeRequestTest extends CakeTestCase {
$request->data('Post.null', null); $request->data('Post.null', null);
$this->assertNull($request->data['Post']['null']); $this->assertNull($request->data['Post']['null']);
$request->data('Post.false', false); $request->data('Post.false', false);
$this->assertFalse($request->data['Post']['false']); $this->assertFalse($request->data['Post']['false']);
$request->data('Post.zero', 0); $request->data('Post.zero', 0);
$this->assertSame(0, $request->data['Post']['zero']); $this->assertSame(0, $request->data['Post']['zero']);
$request->data('Post.empty', ''); $request->data('Post.empty', '');
$this->assertSame('', $request->data['Post']['empty']); $this->assertSame('', $request->data['Post']['empty']);
} }
@ -1480,7 +1480,7 @@ class CakeRequestTest extends CakeTestCase {
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'es_mx;en_ca'; $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'es_mx;en_ca';
$result = CakeRequest::acceptLanguage(); $result = CakeRequest::acceptLanguage();
$this->assertEquals(array('es-mx', 'en-ca'), $result, 'Languages do not match'); $this->assertEquals(array('es-mx', 'en-ca'), $result, 'Languages do not match');
$result = CakeRequest::acceptLanguage('en-ca'); $result = CakeRequest::acceptLanguage('en-ca');
$this->assertTrue($result); $this->assertTrue($result);
@ -1489,7 +1489,7 @@ class CakeRequestTest extends CakeTestCase {
} }
/** /**
* test the here() method * test the here() method
* *
* @return void * @return void
*/ */
@ -1521,7 +1521,7 @@ class CakeRequestTest extends CakeTestCase {
$request = $this->getMock('CakeRequest', array('_readInput')); $request = $this->getMock('CakeRequest', array('_readInput'));
$request->expects($this->once())->method('_readInput') $request->expects($this->once())->method('_readInput')
->will($this->returnValue('I came from stdin')); ->will($this->returnValue('I came from stdin'));
$result = $request->input(); $result = $request->input();
$this->assertEquals('I came from stdin', $result); $this->assertEquals('I came from stdin', $result);
} }
@ -1540,7 +1540,7 @@ class CakeRequestTest extends CakeTestCase {
$this->assertEquals(array('name' => 'value'), (array)$result); $this->assertEquals(array('name' => 'value'), (array)$result);
} }
/** /**
* Test input() decoding with additional arguments. * Test input() decoding with additional arguments.
* *
* @return void * @return void
@ -1560,7 +1560,7 @@ XML;
$result = $request->input('Xml::build', array('return' => 'domdocument')); $result = $request->input('Xml::build', array('return' => 'domdocument'));
$this->assertInstanceOf('DOMDocument', $result); $this->assertInstanceOf('DOMDocument', $result);
$this->assertEquals( $this->assertEquals(
'Test', 'Test',
$result->getElementsByTagName('title')->item(0)->childNodes->item(0)->wholeText $result->getElementsByTagName('title')->item(0)->childNodes->item(0)->wholeText
); );
} }

View file

@ -146,7 +146,7 @@ class RouterTest extends CakeTestCase {
'named' => array(), 'named' => array(),
'plugin' => 'test_plugin', 'plugin' => 'test_plugin',
'controller' => 'test_plugin', 'controller' => 'test_plugin',
'action' => 'index', 'action' => 'index',
'[method]' => 'GET' '[method]' => 'GET'
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
@ -186,7 +186,7 @@ class RouterTest extends CakeTestCase {
'named' => array(), 'named' => array(),
'plugin' => 'test_plugin', 'plugin' => 'test_plugin',
'controller' => 'test_plugin', 'controller' => 'test_plugin',
'action' => 'index', 'action' => 'index',
'[method]' => 'GET' '[method]' => 'GET'
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);

View file

@ -419,9 +419,9 @@ class CakeTestFixtureTest extends CakeTestCase {
/** /**
* Helper function to be used as callback and store the parameters of an insertMulti call * Helper function to be used as callback and store the parameters of an insertMulti call
* *
* @param string $table * @param string $table
* @param string $fields * @param string $fields
* @param string $values * @param string $values
* @return boolean true * @return boolean true
*/ */
function _insertCallback($table, $fields, $values) { function _insertCallback($table, $fields, $values) {

View file

@ -257,7 +257,7 @@ class ObjectCollectionTest extends CakeTestCase {
$this->Objects->TriggerMockSecond->expects($this->once()) $this->Objects->TriggerMockSecond->expects($this->once())
->method('callback') ->method('callback')
->will($this->returnValue(array('three', 'four'))); ->will($this->returnValue(array('three', 'four')));
$result = $this->Objects->trigger('callback', array(), array('collectReturn' => true)); $result = $this->Objects->trigger('callback', array(), array('collectReturn' => true));
$expected = array( $expected = array(
array('one', 'two'), array('one', 'two'),
@ -402,7 +402,7 @@ class ObjectCollectionTest extends CakeTestCase {
'Apple' => array('class' => 'Banana.Apple', 'settings' => array('foo' => 'bar')), 'Apple' => array('class' => 'Banana.Apple', 'settings' => array('foo' => 'bar')),
); );
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
// This is the result after Controller::_mergeVars // This is the result after Controller::_mergeVars
$components = array( $components = array(
'Html' => null, 'Html' => null,

View file

@ -134,7 +134,7 @@ class SecurityTest extends CakeTestCase {
$key = 'my_key'; $key = 'my_key';
$result = Security::cipher($txt, $key); $result = Security::cipher($txt, $key);
$this->assertEqual(Security::cipher($result, $key), $txt); $this->assertEqual(Security::cipher($result, $key), $txt);
$txt = 123456; $txt = 123456;
$key = 'my_key'; $key = 'my_key';
$result = Security::cipher($txt, $key); $result = Security::cipher($txt, $key);

View file

@ -104,6 +104,7 @@ class Contact extends CakeTestModel {
'non_existing' => array(), 'non_existing' => array(),
'idontexist' => array(), 'idontexist' => array(),
'imrequired' => array('rule' => array('between', 5, 30), 'allowEmpty' => false), 'imrequired' => array('rule' => array('between', 5, 30), 'allowEmpty' => false),
'string_required' => 'notEmpty',
'imalsorequired' => array('rule' => 'alphaNumeric', 'allowEmpty' => false), 'imalsorequired' => array('rule' => 'alphaNumeric', 'allowEmpty' => false),
'imrequiredtoo' => array('rule' => 'notEmpty'), 'imrequiredtoo' => array('rule' => 'notEmpty'),
'required_one' => array('required' => array('rule' => array('notEmpty'))), 'required_one' => array('required' => array('rule' => array('notEmpty'))),
@ -845,7 +846,7 @@ class FormHelperTest extends CakeTestCase {
); );
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
} }
/** /**
* Tests correct generation of number fields for integer fields * Tests correct generation of number fields for integer fields
* *
@ -1610,7 +1611,7 @@ class FormHelperTest extends CakeTestCase {
'/div' '/div'
); );
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
$result = $this->Form->error( $result = $this->Form->error(
'ValidateUser.email', 'Invalid email', array('wrap' => false) 'ValidateUser.email', 'Invalid email', array('wrap' => false)
); );
@ -6584,6 +6585,141 @@ class FormHelperTest extends CakeTestCase {
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
} }
/**
* Test that required fields are created for various types of validation.
*
* @return void
*/
function testFormInputRequiredDetection() {
$this->Form->create('Contact');
$result = $this->Form->input('Contact.non_existing');
$expected = array(
'div' => array('class' => 'input text required'),
'label' => array('for' => 'ContactNonExisting'),
'Non Existing',
'/label',
'input' => array(
'type' => 'text', 'name' => 'data[Contact][non_existing]',
'id' => 'ContactNonExisting'
),
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('Contact.imrequired');
$expected = array(
'div' => array('class' => 'input text required'),
'label' => array('for' => 'ContactImrequired'),
'Imrequired',
'/label',
'input' => array(
'type' => 'text', 'name' => 'data[Contact][imrequired]',
'id' => 'ContactImrequired'
),
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('Contact.imalsorequired');
$expected = array(
'div' => array('class' => 'input text required'),
'label' => array('for' => 'ContactImalsorequired'),
'Imalsorequired',
'/label',
'input' => array(
'type' => 'text', 'name' => 'data[Contact][imalsorequired]',
'id' => 'ContactImalsorequired'
),
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('Contact.imrequiredtoo');
$expected = array(
'div' => array('class' => 'input text required'),
'label' => array('for' => 'ContactImrequiredtoo'),
'Imrequiredtoo',
'/label',
'input' => array(
'type' => 'text', 'name' => 'data[Contact][imrequiredtoo]',
'id' => 'ContactImrequiredtoo'
),
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('Contact.required_one');
$expected = array(
'div' => array('class' => 'input text required'),
'label' => array('for' => 'ContactRequiredOne'),
'Required One',
'/label',
'input' => array(
'type' => 'text', 'name' => 'data[Contact][required_one]',
'id' => 'ContactRequiredOne'
),
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('Contact.string_required');
$expected = array(
'div' => array('class' => 'input text required'),
'label' => array('for' => 'ContactStringRequired'),
'String Required',
'/label',
'input' => array(
'type' => 'text', 'name' => 'data[Contact][string_required]',
'id' => 'ContactStringRequired'
),
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('Contact.imnotrequired');
$expected = array(
'div' => array('class' => 'input text'),
'label' => array('for' => 'ContactImnotrequired'),
'Imnotrequired',
'/label',
'input' => array(
'type' => 'text', 'name' => 'data[Contact][imnotrequired]',
'id' => 'ContactImnotrequired'
),
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('Contact.imalsonotrequired');
$expected = array(
'div' => array('class' => 'input text'),
'label' => array('for' => 'ContactImalsonotrequired'),
'Imalsonotrequired',
'/label',
'input' => array(
'type' => 'text', 'name' => 'data[Contact][imalsonotrequired]',
'id' => 'ContactImalsonotrequired'
),
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('Contact.imnotrequiredeither');
$expected = array(
'div' => array('class' => 'input text'),
'label' => array('for' => 'ContactImnotrequiredeither'),
'Imnotrequiredeither',
'/label',
'input' => array(
'type' => 'text', 'name' => 'data[Contact][imnotrequiredeither]',
'id' => 'ContactImnotrequiredeither'
),
'/div'
);
$this->assertTags($result, $expected);
}
/** /**
* testFormMagicInput method * testFormMagicInput method
* *
@ -6671,117 +6807,6 @@ class FormHelperTest extends CakeTestCase {
); );
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
$result = $this->Form->input('Contact.non_existing');
$expected = array(
'div' => array('class' => 'input text required'),
'label' => array('for' => 'ContactNonExisting'),
'Non Existing',
'/label',
'input' => array(
'type' => 'text', 'name' => 'data[Contact][non_existing]',
'id' => 'ContactNonExisting'
),
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('Contact.imrequired');
$expected = array(
'div' => array('class' => 'input text required'),
'label' => array('for' => 'ContactImrequired'),
'Imrequired',
'/label',
'input' => array(
'type' => 'text', 'name' => 'data[Contact][imrequired]',
'id' => 'ContactImrequired'
),
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('Contact.imalsorequired');
$expected = array(
'div' => array('class' => 'input text required'),
'label' => array('for' => 'ContactImalsorequired'),
'Imalsorequired',
'/label',
'input' => array(
'type' => 'text', 'name' => 'data[Contact][imalsorequired]',
'id' => 'ContactImalsorequired'
),
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('Contact.imrequiredtoo');
$expected = array(
'div' => array('class' => 'input text required'),
'label' => array('for' => 'ContactImrequiredtoo'),
'Imrequiredtoo',
'/label',
'input' => array(
'type' => 'text', 'name' => 'data[Contact][imrequiredtoo]',
'id' => 'ContactImrequiredtoo'
),
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('Contact.required_one');
$expected = array(
'div' => array('class' => 'input text required'),
'label' => array('for' => 'ContactRequiredOne'),
'Required One',
'/label',
'input' => array(
'type' => 'text', 'name' => 'data[Contact][required_one]',
'id' => 'ContactRequiredOne'
),
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('Contact.imnotrequired');
$expected = array(
'div' => array('class' => 'input text'),
'label' => array('for' => 'ContactImnotrequired'),
'Imnotrequired',
'/label',
'input' => array(
'type' => 'text', 'name' => 'data[Contact][imnotrequired]',
'id' => 'ContactImnotrequired'
),
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('Contact.imalsonotrequired');
$expected = array(
'div' => array('class' => 'input text'),
'label' => array('for' => 'ContactImalsonotrequired'),
'Imalsonotrequired',
'/label',
'input' => array(
'type' => 'text', 'name' => 'data[Contact][imalsonotrequired]',
'id' => 'ContactImalsonotrequired'
),
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('Contact.imnotrequiredeither');
$expected = array(
'div' => array('class' => 'input text'),
'label' => array('for' => 'ContactImnotrequiredeither'),
'Imnotrequiredeither',
'/label',
'input' => array(
'type' => 'text', 'name' => 'data[Contact][imnotrequiredeither]',
'id' => 'ContactImnotrequiredeither'
),
'/div'
);
$this->assertTags($result, $expected);
extract($this->dateRegex); extract($this->dateRegex);
$now = strtotime('now'); $now = strtotime('now');
@ -7479,7 +7504,7 @@ class FormHelperTest extends CakeTestCase {
'input' => array('type' => 'text', 'name' => 'data[User][query]', 'id' => 'UserQuery', 'value' => 'test') 'input' => array('type' => 'text', 'name' => 'data[User][query]', 'id' => 'UserQuery', 'value' => 'test')
); );
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
$result = $this->Form->input('User.website', array('type' => 'url', 'value' => 'http://domain.tld', 'div' => false, 'label' => false)); $result = $this->Form->input('User.website', array('type' => 'url', 'value' => 'http://domain.tld', 'div' => false, 'label' => false));
$expected = array( $expected = array(
'input' => array('type' => 'url', 'name' => 'data[User][website]', 'id' => 'UserWebsite', 'value' => 'http://domain.tld') 'input' => array('type' => 'url', 'name' => 'data[User][website]', 'id' => 'UserWebsite', 'value' => 'http://domain.tld')

View file

@ -798,7 +798,7 @@ class HtmlHelperTest extends CakeTestCase {
*/ */
public function testBreadcrumb() { public function testBreadcrumb() {
$this->assertNull($this->Html->getCrumbs()); $this->assertNull($this->Html->getCrumbs());
$this->Html->addCrumb('First', '#first'); $this->Html->addCrumb('First', '#first');
$this->Html->addCrumb('Second', '#second'); $this->Html->addCrumb('Second', '#second');
$this->Html->addCrumb('Third', '#third'); $this->Html->addCrumb('Third', '#third');

View file

@ -576,7 +576,7 @@ class RssHelperTest extends CakeTestCase {
$File = new File($tmpFile, true, '0777'); $File = new File($tmpFile, true, '0777');
$this->assertTrue($File->write('123'), 'Could not write to ' . $tmpFile); $this->assertTrue($File->write('123'), 'Could not write to ' . $tmpFile);
clearstatcache(true, $tmpFile); clearstatcache(true, $tmpFile);
$item = array( $item = array(
'title' => array( 'title' => array(
'value' => 'My Title', 'value' => 'My Title',

View file

@ -403,8 +403,8 @@ class TimeHelperTest extends CakeTestCase {
$yourTimezone = new DateTimeZone($timezone); $yourTimezone = new DateTimeZone($timezone);
$yourTime = new DateTime('now', $yourTimezone); $yourTime = new DateTime('now', $yourTimezone);
$userOffset = $yourTimezone->getOffset($yourTime) / HOUR; $userOffset = $yourTimezone->getOffset($yourTime) / HOUR;
$this->assertEqual($yourTime->format('r'), $this->Time->toRss(time(), $userOffset)); $this->assertEqual($yourTime->format('r'), $this->Time->toRss(time(), $userOffset));
} }
} }
} }

View file

@ -11,7 +11,7 @@ class FixturizedTestCase extends CakeTestCase {
/** /**
* Fixtures to use in this thes * Fixtures to use in this thes
* @var array * @var array
*/ */
public $fixtures = array('core.category'); public $fixtures = array('core.category');

View file

@ -18,7 +18,7 @@
*/ */
class TestAppCacheEngine extends CacheEngine { class TestAppCacheEngine extends CacheEngine {
public function write($key, $value, $duration) { public function write($key, $value, $duration) {
if ($key == 'fail') { if ($key == 'fail') {
return false; return false;
} }

View file

@ -22,6 +22,6 @@ App::uses('CakeLogInterface', 'Log');
class TestAppLog implements CakeLogInterface { class TestAppLog implements CakeLogInterface {
public function write($type, $message) { public function write($type, $message) {
} }
} }

View file

@ -23,7 +23,7 @@ mon "<U0031><U6708>";"<U0032><U6708>";/
"<U0039><U6708>";"<U0031><U0030><U6708>";/ "<U0039><U6708>";"<U0031><U0030><U6708>";/
"<U0031><U0031><U6708>";"<U0031><U0032><U6708>" "<U0031><U0031><U6708>";"<U0031><U0032><U6708>"
% Appropriate date and time representation (%c) % Appropriate date and time representation (%c)
% %
d_t_fmt "<U0025><U0059><U5E74><U0025><U006D><U6708><U0025><U0064><U65E5><U0020><U0025><U0048><U6642><U0025><U004D><U5206><U0025><U0053><U79D2>" d_t_fmt "<U0025><U0059><U5E74><U0025><U006D><U6708><U0025><U0064><U65E5><U0020><U0025><U0048><U6642><U0025><U004D><U5206><U0025><U0053><U79D2>"
% %
% Appropriate date representation (%x) % Appropriate date representation (%x)
@ -31,18 +31,18 @@ d_t_fmt "<U0025><U0059><U5E74><U0025><U006D><U6708><U0025><U0064><U65E5><U0020><
d_fmt "<U0025><U0059><U5E74><U0025><U006D><U6708><U0025><U0064><U65E5>" d_fmt "<U0025><U0059><U5E74><U0025><U006D><U6708><U0025><U0064><U65E5>"
% %
% Appropriate time representation (%X) % Appropriate time representation (%X)
% %
t_fmt "<U0025><U0048><U6642><U0025><U004D><U5206><U0025><U0053><U79D2>" t_fmt "<U0025><U0048><U6642><U0025><U004D><U5206><U0025><U0053><U79D2>"
% %
% Appropriate AM/PM time representation (%r) % Appropriate AM/PM time representation (%r)
% %
t_fmt_ampm "<U0025><U0070><U0025><U0049><U6642><U0025><U004D><U5206><U0025><U0053><U79D2>" t_fmt_ampm "<U0025><U0070><U0025><U0049><U6642><U0025><U004D><U5206><U0025><U0053><U79D2>"
% %
% Strings for AM/PM % Strings for AM/PM
% %
am_pm "<U5348><U524D>";"<U5348><U5F8C>" am_pm "<U5348><U524D>";"<U5348><U5F8C>"
% %
% Appropriate date representation (date(1)) % Appropriate date representation (date(1))
date_fmt "<U0025><U0059><U5E74><U0020><U0025><U0062><U0020><U0025>/ date_fmt "<U0025><U0059><U5E74><U0020><U0025><U0062><U0020><U0025>/
<U0065><U65E5><U0020><U0025><U0041><U0020><U0025><U0048><U003A><U0025>/ <U0065><U65E5><U0020><U0025><U0041><U0020><U0025><U0048><U003A><U0025>/
<U004D><U003A><U0025><U0053><U0020><U0025><U005A>" <U004D><U003A><U0025><U0053><U0020><U0025><U005A>"

View file

@ -10,22 +10,22 @@ class TestAppLibSession implements CakeSessionHandlerInterface {
} }
public function close() { public function close() {
} }
public function read($id) { public function read($id) {
} }
public function write($id, $data) { public function write($id, $data) {
} }
public function destroy($id) { public function destroy($id) {
} }
public function gc($expires = null) { public function gc($expires = null) {
} }
} }

View file

@ -17,5 +17,5 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
class OtherTaskTask extends Shell { class OtherTaskTask extends Shell {
} }

View file

@ -18,7 +18,7 @@
*/ */
class TestPluginController extends TestPluginAppController { class TestPluginController extends TestPluginAppController {
public $uses = array(); public $uses = array();
public function index() { public function index() {
$this->autoRender = false; $this->autoRender = false;
} }

View file

@ -29,5 +29,5 @@ class TestPluginCacheEngine extends CacheEngine {
public function delete($key) { } public function delete($key) { }
public function clear($check) { } public function clear($check) { }
} }

View file

@ -19,6 +19,6 @@
class TestPluginLog implements CakeLogInterface { class TestPluginLog implements CakeLogInterface {
public function write($type, $message) { public function write($type, $message) {
} }
} }

View file

@ -9,22 +9,22 @@ class TestPluginSession implements CakeSessionHandlerInterface {
} }
public function close() { public function close() {
} }
public function read($id) { public function read($id) {
} }
public function write($id, $data) { public function write($id, $data) {
} }
public function destroy($id) { public function destroy($id) {
} }
public function gc($expires = null) { public function gc($expires = null) {
} }
} }

View file

@ -1,5 +1,5 @@
<?php <?php
class TestPluginAppHelper extends AppHelper { class TestPluginAppHelper extends AppHelper {
} }

View file

@ -1,4 +1,4 @@
<?php <?php
echo $html; echo $html;
echo $this->Html->link('Test link', '#'); echo $this->Html->link('Test link', '#');
?> ?>

View file

@ -494,9 +494,9 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
/** /**
* Compatibility wrapper for assertIsA * Compatibility wrapper for assertIsA
* *
* @param string $object * @param string $object
* @param string $type * @param string $type
* @param string $message * @param string $message
* @return void * @return void
*/ */
protected static function assertIsA($object, $type, $message = '') { protected static function assertIsA($object, $type, $message = '') {

View file

@ -38,8 +38,8 @@ class CakeTestRunner extends PHPUnit_TextUI_TestRunner {
/** /**
* Actually run a suite of tests. Cake initializes fixtures here using the chosen fixture manager * Actually run a suite of tests. Cake initializes fixtures here using the chosen fixture manager
* *
* @param PHPUnit_Framework_Test $suite * @param PHPUnit_Framework_Test $suite
* @param array $arguments * @param array $arguments
* @return void * @return void
*/ */
public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array()) { public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array()) {

View file

@ -64,7 +64,7 @@ class ControllerTestDispatcher extends Dispatcher {
/** /**
* Loads routes and resets if the test case dictates it should * Loads routes and resets if the test case dictates it should
* *
* @return void * @return void
*/ */
protected function _loadRoutes() { protected function _loadRoutes() {
@ -190,7 +190,7 @@ abstract class ControllerTestCase extends CakeTestCase {
* - `vars` Get the set view variables. * - `vars` Get the set view variables.
* - `view` Get the rendered view, without a layout. * - `view` Get the rendered view, without a layout.
* - `contents` Get the rendered view including the layout. * - `contents` Get the rendered view including the layout.
* - `result` Get the return value of the controller action. Useful * - `result` Get the return value of the controller action. Useful
* for testing requestAction methods. * for testing requestAction methods.
* *
* @param string $url The url to test * @param string $url The url to test
@ -260,7 +260,7 @@ abstract class ControllerTestCase extends CakeTestCase {
* Generates a mocked controller and mocks any classes passed to `$mocks`. By * Generates a mocked controller and mocks any classes passed to `$mocks`. By
* default, `_stop()` is stubbed as is sending the response headers, so to not * default, `_stop()` is stubbed as is sending the response headers, so to not
* interfere with testing. * interfere with testing.
* *
* ### Mocks: * ### Mocks:
* *
* - `methods` Methods to mock on the controller. `_stop()` is mocked by default * - `methods` Methods to mock on the controller. `_stop()` is mocked by default
@ -289,10 +289,10 @@ abstract class ControllerTestCase extends CakeTestCase {
)); ));
} }
ClassRegistry::flush(); ClassRegistry::flush();
$mocks = array_merge_recursive(array( $mocks = array_merge_recursive(array(
'methods' => array('_stop'), 'methods' => array('_stop'),
'models' => array(), 'models' => array(),
'components' => array() 'components' => array()
), (array)$mocks); ), (array)$mocks);

View file

@ -188,7 +188,7 @@ class CakeTestFixture {
} }
$this->Schema->build(array($this->table => $this->fields)); $this->Schema->build(array($this->table => $this->fields));
try { try {
$db->execute($db->dropSchema($this->Schema), array('log' => false)); $db->execute($db->dropSchema($this->Schema), array('log' => false));
} catch (Exception $e) { } catch (Exception $e) {
return false; return false;

View file

@ -61,7 +61,7 @@ class CakeTextReporter extends CakeBaseReporter {
$context = $context[2]; $context = $context[2];
printf( printf(
"FAIL on line %s\n%s in\n%s %s()\n\n", "FAIL on line %s\n%s in\n%s %s()\n\n",
$context['line'], $message->toString(), $context['file'], $realContext['function'] $context['line'], $message->toString(), $context['file'], $realContext['function']
); );
} }
@ -80,7 +80,7 @@ class CakeTextReporter extends CakeBaseReporter {
echo "FAILURES!!!\n"; echo "FAILURES!!!\n";
} }
echo "Test cases run: " . $result->count() . echo "Test cases run: " . $result->count() .
"/" . ($result->count() - $result->skippedCount()) . "/" . ($result->count() - $result->skippedCount()) .
', Passes: ' . $this->numAssertions . ', Passes: ' . $this->numAssertions .
', Failures: ' . $result->failureCount() . ', Failures: ' . $result->failureCount() .

View file

@ -547,8 +547,8 @@ class Debugger {
* *
* `Debugger::addFormat('custom', $data);` * `Debugger::addFormat('custom', $data);`
* *
* Where $data is an array of strings that use String::insert() variable * Where $data is an array of strings that use String::insert() variable
* replacement. The template vars should be in a `{:id}` style. * replacement. The template vars should be in a `{:id}` style.
* An error formatter can have the following keys: * An error formatter can have the following keys:
* *
* - 'error' - Used for the container for the error message. Gets the following template * - 'error' - Used for the container for the error message. Gets the following template
@ -557,11 +557,11 @@ class Debugger {
* the contents of the other template keys. * the contents of the other template keys.
* - 'trace' - The container for a stack trace. Gets the following template * - 'trace' - The container for a stack trace. Gets the following template
* variables: `trace` * variables: `trace`
* - 'context' - The container element for the context variables. * - 'context' - The container element for the context variables.
* Gets the following templates: `id`, `context` * Gets the following templates: `id`, `context`
* - 'links' - An array of HTML links that are used for creating links to other resources. * - 'links' - An array of HTML links that are used for creating links to other resources.
* Typically this is used to create javascript links to open other sections. * Typically this is used to create javascript links to open other sections.
* Link keys, are: `code`, `context`, `help`. See the js output format for an * Link keys, are: `code`, `context`, `help`. See the js output format for an
* example. * example.
* - 'traceLine' - Used for creating lines in the stacktrace. Gets the following * - 'traceLine' - Used for creating lines in the stacktrace. Gets the following
* template variables: `reference`, `path`, `line` * template variables: `reference`, `path`, `line`
@ -599,14 +599,14 @@ class Debugger {
} }
/** /**
* Switches output format, updates format strings. * Switches output format, updates format strings.
* Can be used to switch the active output format: * Can be used to switch the active output format:
* *
* @param string $format Format to use, including 'js' for JavaScript-enhanced HTML, 'html' for * @param string $format Format to use, including 'js' for JavaScript-enhanced HTML, 'html' for
* straight HTML output, or 'txt' for unformatted text. * straight HTML output, or 'txt' for unformatted text.
* @param array $strings Template strings to be used for the output format. * @param array $strings Template strings to be used for the output format.
* @return string * @return string
* @deprecated Use Debugger::outputAs() and Debugger::addFormat(). Will be removed * @deprecated Use Debugger::outputAs() and Debugger::addFormat(). Will be removed
* in 3.0 * in 3.0
*/ */
public function output($format = null, $strings = array()) { public function output($format = null, $strings = array()) {

View file

@ -1,6 +1,6 @@
<?php <?php
/** /**
* SQL Dump element. Dumps out SQL log information * SQL Dump element. Dumps out SQL log information
* *
* PHP 5 * PHP 5
* *
@ -53,7 +53,7 @@ if ($noLogs || isset($_forced_from_dbo_)):
endforeach; endforeach;
?> ?>
</tbody></table> </tbody></table>
<?php <?php
endforeach; endforeach;
else: else:
echo '<p>Encountered unexpected $logs cannot generate SQL log</p>'; echo '<p>Encountered unexpected $logs cannot generate SQL log</p>';

View file

@ -239,14 +239,16 @@ class FormHelper extends AppHelper {
} }
/** /**
* Returns if a field is required to be filled based on validation properties from the validating object * Returns if a field is required to be filled based on validation properties from the validating object.
* *
* @param array $validateProperties * @param array $validateProperties
* @return boolean true if field is required to be filled, false otherwise * @return boolean true if field is required to be filled, false otherwise
*/ */
protected function _isRequiredField($validateProperties) { protected function _isRequiredField($validateProperties) {
$required = false; $required = false;
if (is_array($validateProperties)) { if (is_string($validateProperties)) {
return true;
} elseif (is_array($validateProperties)) {
$dims = Set::countDim($validateProperties); $dims = Set::countDim($validateProperties);
if ($dims == 1 || ($dims == 2 && isset($validateProperties['rule']))) { if ($dims == 1 || ($dims == 2 && isset($validateProperties['rule']))) {
@ -271,7 +273,7 @@ class FormHelper extends AppHelper {
* Returns false if given form field described by the current entity has no errors. * Returns false if given form field described by the current entity has no errors.
* Otherwise it returns the validation message * Otherwise it returns the validation message
* *
* @return mixed Either false when there or no errors, or the error * @return mixed Either false when there or no errors, or the error
* string. The error string could be ''. * string. The error string could be ''.
*/ */
public function tagIsInvalid() { public function tagIsInvalid() {

View file

@ -36,7 +36,7 @@ endif;
2) <a target="_blank" href="http://book.cakephp.org/2.0/en/development/configuration.html#cakephp-core-configuration" style="color:#fff;">I don't / can't use URL rewriting</a> 2) <a target="_blank" href="http://book.cakephp.org/2.0/en/development/configuration.html#cakephp-core-configuration" style="color:#fff;">I don't / can't use URL rewriting</a>
</p> </p>
<p> <p>
<?php <?php
if (version_compare(PHP_VERSION, '5.2.6', '>=')): if (version_compare(PHP_VERSION, '5.2.6', '>=')):
echo '<span class="notice success">'; echo '<span class="notice success">';
echo __d('cake_dev', 'Your version of PHP is 5.2.6 or higher.'); echo __d('cake_dev', 'Your version of PHP is 5.2.6 or higher.');

View file

@ -49,8 +49,8 @@ foreach (${$pluralVar} as ${$singularVar}):
echo $this->Html->link(__d('cake', 'View'), array('action' => 'view', ${$singularVar}[$modelClass][$primaryKey])); echo $this->Html->link(__d('cake', 'View'), array('action' => 'view', ${$singularVar}[$modelClass][$primaryKey]));
echo $this->Html->link(__d('cake', 'Edit'), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])); echo $this->Html->link(__d('cake', 'Edit'), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey]));
echo $this->Form->postLink( echo $this->Form->postLink(
__d('cake', 'Delete'), __d('cake', 'Delete'),
array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]),
null, null,
__d('cake', 'Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey] __d('cake', 'Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey]
); );