Merge branch 'master' into 2.5

This commit is contained in:
mark_story 2013-09-27 22:26:33 -04:00
commit 5e9b22271a
34 changed files with 121 additions and 66 deletions

View file

@ -17,7 +17,7 @@ Some Handy Links
[The Bakery](http://bakery.cakephp.org) - Tips, tutorials and articles
[API](http://api.cakephp.org) - A reference to Cake's classes
[API](http://api.cakephp.org) - A reference to CakePHP's classes
[CakePHP TV](http://tv.cakephp.org) - Screen casts from events and video tutorials

View file

@ -2,7 +2,7 @@
/**
* This is core configuration file.
*
* Use it to configure core behaviour of Cake.
* Use it to configure core behaviour of CakePHP.
*
* PHP 5
*

View file

@ -2,7 +2,7 @@
/**
* This is email configuration file.
*
* Use it to configure email transports of Cake.
* Use it to configure email transports of CakePHP.
*
* PHP 5
*

View file

@ -1,6 +1,6 @@
<?php
/**
* Application model for Cake.
* Application model for CakePHP.
*
* This file is application-wide model file. You can put all
* application-wide model-related methods here.

View file

@ -23,7 +23,7 @@
*/
/**
* Get Cake's root directory
* Get CakePHP's root directory
*/
define('APP_DIR', 'app');
define('DS', DIRECTORY_SEPARATOR);

View file

@ -201,6 +201,7 @@ class Shell extends Object {
*/
public function initialize() {
$this->_loadModels();
$this->loadTasks();
}
/**

View file

@ -114,7 +114,7 @@ class ShellDispatcher {
}
/**
* Initializes the environment and loads the Cake core.
* Initializes the environment and loads the CakePHP core.
*
* @return boolean Success.
*/
@ -206,7 +206,6 @@ class ShellDispatcher {
if ($Shell instanceof Shell) {
$Shell->initialize();
$Shell->loadTasks();
return $Shell->runCommand($command, $this->args);
}
$methods = array_diff(get_class_methods($Shell), get_class_methods('Shell'));

View file

@ -304,7 +304,10 @@ class AuthComponent extends Component {
return $this->_unauthenticated($controller);
}
if (empty($this->authorize) || $this->isAuthorized($this->user())) {
if ($this->_isLoginAction($controller) ||
empty($this->authorize) ||
$this->isAuthorized($this->user())
) {
return true;
}
@ -347,6 +350,11 @@ class AuthComponent extends Component {
}
if ($this->_isLoginAction($controller)) {
if (empty($controller->request->data)) {
if (!$this->Session->check('Auth.redirect') && env('HTTP_REFERER')) {
$this->Session->write('Auth.redirect', $controller->referer(null, true));
}
}
return true;
}
@ -367,9 +375,7 @@ class AuthComponent extends Component {
}
/**
* Normalizes $loginAction and checks if current request url is same as login
* action. If current url is same as login action, referrer url is saved in session
* which is later accessible using redirectUrl().
* Normalizes $loginAction and checks if current request url is same as login action.
*
* @param Controller $controller A reference to the controller object.
* @return boolean True if current action is login action else false.
@ -382,15 +388,7 @@ class AuthComponent extends Component {
$url = Router::normalize($url);
$loginAction = Router::normalize($this->loginAction);
if ($loginAction == $url) {
if (empty($controller->request->data)) {
if (!$this->Session->check('Auth.redirect') && env('HTTP_REFERER')) {
$this->Session->write('Auth.redirect', $controller->referer(null, true));
}
}
return true;
}
return false;
return $loginAction === $url;
}
/**

View file

@ -207,7 +207,7 @@ class Controller extends Object implements CakeEventListener {
public $View;
/**
* File extension for view templates. Defaults to Cake's conventional ".ctp".
* File extension for view templates. Defaults to CakePHP's conventional ".ctp".
*
* @var string
*/

View file

@ -1,8 +1,8 @@
<?php
/**
* Session class for Cake.
* Session class for CakePHP.
*
* Cake abstracts the handling of sessions.
* CakePHP abstracts the handling of sessions.
* There are several convenient methods to access session information.
* This class is the implementation of those methods.
* They are mostly used by the Session Component.
@ -27,9 +27,9 @@ App::uses('Hash', 'Utility');
App::uses('Security', 'Utility');
/**
* Session class for Cake.
* Session class for CakePHP.
*
* Cake abstracts the handling of sessions. There are several convenient methods to access session information.
* CakePHP abstracts the handling of sessions. There are several convenient methods to access session information.
* This class is the implementation of those methods. They are mostly used by the Session Component.
*
* @package Cake.Model.Datasource
@ -444,7 +444,7 @@ class CakeSession {
}
/**
* Helper method to initialize a session, based on Cake core settings.
* Helper method to initialize a session, based on CakePHP core settings.
*
* Sessions can be configured with a few shortcut names as well as have any number of ini settings declared.
*

View file

@ -325,6 +325,13 @@ class CakeEmail {
*/
protected $_emailPattern = null;
/**
* The classname used for email configuration.
*
* @var string
*/
protected $_configClass = 'EmailConfig';
/**
* Constructor
*
@ -1179,10 +1186,10 @@ class CakeEmail {
*/
protected function _applyConfig($config) {
if (is_string($config)) {
if (!class_exists('EmailConfig') && !config('email')) {
if (!class_exists($this->_configClass) && !config('email')) {
throw new ConfigureException(__d('cake_dev', '%s not found.', APP . 'Config' . DS . 'email.php'));
}
$configs = new EmailConfig();
$configs = new $this->_configClass();
if (!isset($configs->{$config})) {
throw new ConfigureException(__d('cake_dev', 'Unknown email configuration "%s".', $config));
}

View file

@ -3,7 +3,7 @@
* Dispatcher takes the URL information, parses it for parameters and
* tells the involved controllers what to do.
*
* This is the heart of Cake's operation.
* This is the heart of CakePHP's operation.
*
* PHP 5
*

View file

@ -441,7 +441,6 @@ class ShellDispatcherTest extends CakeTestCase {
$Mock = $this->getMock('Shell', array(), array(), 'MockWithMainShell');
$Mock->expects($this->once())->method('initialize');
$Mock->expects($this->once())->method('loadTasks');
$Mock->expects($this->once())->method('runCommand')
->with(null, array())
->will($this->returnValue(true));
@ -467,7 +466,6 @@ class ShellDispatcherTest extends CakeTestCase {
$this->mockObjects[] = $Shell;
$Shell->expects($this->once())->method('initialize');
$Shell->expects($this->once())->method('loadTasks');
$Shell->expects($this->once())->method('runCommand')
->with('initdb', array('initdb'))
->will($this->returnValue(true));
@ -491,7 +489,6 @@ class ShellDispatcherTest extends CakeTestCase {
$Shell = $this->getMock('Object', $methods, array(), 'MockWithMainNotAShell');
$Shell->expects($this->never())->method('initialize');
$Shell->expects($this->never())->method('loadTasks');
$Shell->expects($this->once())->method('startup');
$Shell->expects($this->once())->method('main')->will($this->returnValue(true));
$Dispatcher->TestShell = $Shell;
@ -524,7 +521,6 @@ class ShellDispatcherTest extends CakeTestCase {
$Shell = $this->getMock('Object', $methods, array(&$Dispatcher), 'MockWithoutMainNotAShell');
$Shell->expects($this->never())->method('initialize');
$Shell->expects($this->never())->method('loadTasks');
$Shell->expects($this->once())->method('startup');
$Shell->expects($this->once())->method('main')->will($this->returnValue(true));
$Dispatcher->TestShell = $Shell;

View file

@ -195,6 +195,7 @@ class ShellTest extends CakeTestCase {
), App::RESET);
CakePlugin::load('TestPlugin');
$this->Shell->tasks = array('DbConfig' => array('one', 'two'));
$this->Shell->uses = array('TestPlugin.TestPluginPost');
$this->Shell->initialize();
@ -208,6 +209,7 @@ class ShellTest extends CakeTestCase {
$this->assertTrue(isset($this->Shell->Comment));
$this->assertInstanceOf('Comment', $this->Shell->Comment);
$this->assertEquals('Comment', $this->Shell->modelClass);
$this->assertInstanceOf('DbConfigTask', $this->Shell->DbConfig);
App::build();
}

View file

@ -876,6 +876,28 @@ class AuthComponentTest extends CakeTestCase {
$this->Auth->Session->delete('Auth');
}
/**
* testNoLoginRedirectForAuthenticatedUser method
*
* @return void
*/
public function testNoLoginRedirectForAuthenticatedUser() {
$this->Controller->request['controller'] = 'auth_test';
$this->Controller->request['action'] = 'login';
$this->Controller->here = '/auth_test/login';
$this->Auth->request->url = 'auth_test/login';
$this->Auth->Session->write('Auth.User.id', '1');
$this->Auth->authenticate = array('Form');
$this->getMock('BaseAuthorize', array('authorize'), array(), 'NoLoginRedirectMockAuthorize', false);
$this->Auth->authorize = array('NoLoginRedirectMockAuthorize');
$this->Auth->loginAction = array('controller' => 'auth_test', 'action' => 'login');
$return = $this->Auth->startup($this->Controller);
$this->assertTrue($return);
$this->assertNull($this->Controller->testUrl);
}
/**
* Default to loginRedirect, if set, on authError.
*

View file

@ -3477,7 +3477,7 @@ class ContainableBehaviorTest extends CakeTestCase {
'joinTable' => 'articles_tags',
'foreignKey' => 'article_id',
'associationForeignKey' => 'tag_id',
// LENGHT function mysql-only, using LIKE does almost the same
// LENGTH function mysql-only, using LIKE does almost the same
'conditions' => "ShortTag.tag LIKE '???'"
)
)

View file

@ -703,7 +703,7 @@ class CakeSchemaTest extends CakeTestCase {
);
$result = $this->Schema->generateTable('fields', $posts);
$this->assertRegExp('/public \$fields/', $result);
$this->assertPattern('/\'type\' \=\> \'fulltext\'/', $result);
$this->assertRegExp('/\'type\' \=\> \'fulltext\'/', $result);
}
/**

View file

@ -951,6 +951,9 @@ class DboSourceTest extends CakeTestCase {
* @return void
*/
public function testFieldsCacheKeyWithSchemanameChange() {
if ($this->db instanceof Postgres || $this->db instanceof Sqlserver) {
$this->markTestSkipped('Cannot run this test with SqlServer or Postgres');
}
Cache::delete('method_cache', '_cake_core_');
DboSource::$methodCache = array();
$Article = ClassRegistry::init('Article');

View file

@ -147,7 +147,7 @@ class ModelCrossSchemaHabtmTest extends BaseModelTest {
));
$results = $Player->saveAll($player, array('validate' => 'first'));
$this->assertNotEqual(false, $results);
$this->assertNotSame(false, $results);
$count = $Player->find('count');
$this->assertEquals(5, $count);

View file

@ -26,6 +26,15 @@ App::uses('CakeEmail', 'Network/Email');
*/
class TestCakeEmail extends CakeEmail {
/**
* Config classname.
*
* Use a the testing config class in this file.
*
* @var string
*/
protected $_configClass = 'TestEmailConfig';
/**
* Config
*
@ -79,7 +88,7 @@ class TestCakeEmail extends CakeEmail {
* EmailConfig class
*
*/
class EmailConfig {
class TestEmailConfig {
/**
* test config
@ -841,7 +850,7 @@ class CakeEmailTest extends CakeTestCase {
* @return void
*/
public function testConfigString() {
$configs = new EmailConfig();
$configs = new TestEmailConfig();
$this->CakeEmail->config('test');
$result = $this->CakeEmail->to();
@ -1767,8 +1776,8 @@ class CakeEmailTest extends CakeTestCase {
* @return void
*/
public function testConstructWithConfigString() {
$configs = new EmailConfig();
$this->CakeEmail = new CakeEmail('test');
$configs = new TestEmailConfig();
$this->CakeEmail = new TestCakeEmail('test');
$result = $this->CakeEmail->to();
$this->assertEquals($configs->test['to'], $result);

View file

@ -6754,7 +6754,7 @@ class FormHelperTest extends CakeTestCase {
$result = $matches[1];
$expected = range(date('Y') + 20, 1930);
$this->assertEquals($result, $expected);
$this->assertEquals($expected, $result);
$this->Form->request->data['Project']['release'] = '2050-10-10';
$result = $this->Form->year('Project.release');
@ -6762,7 +6762,7 @@ class FormHelperTest extends CakeTestCase {
$result = $matches[1];
$expected = range(2050, date('Y') - 20);
$this->assertEquals($result, $expected);
$this->assertEquals($expected, $result);
$this->Form->request->data['Project']['release'] = '1881-10-10';
$result = $this->Form->year('Project.release', 1890, 1900);
@ -6770,7 +6770,7 @@ class FormHelperTest extends CakeTestCase {
$result = $matches[1];
$expected = range(1900, 1881);
$this->assertEquals($result, $expected);
$this->assertEquals($expected, $result);
}
/**
@ -9312,7 +9312,7 @@ class FormHelperTest extends CakeTestCase {
'div' => false,
'label' => false,
);
$this->assertEqual($result, $expected);
$this->assertEquals($expected, $result);
}
}

View file

@ -1844,13 +1844,13 @@ class HtmlHelperTest extends CakeTestCase {
$this->assertTags($result, array('div' => array('class' => 'class-name'), '&lt;text&gt;', '/div'));
$result = $this->Html->tag(false, '<em>stuff</em>');
$this->assertEquals($result, '<em>stuff</em>');
$this->assertEquals('<em>stuff</em>', $result);
$result = $this->Html->tag(null, '<em>stuff</em>');
$this->assertEquals($result, '<em>stuff</em>');
$this->assertEquals('<em>stuff</em>', $result);
$result = $this->Html->tag('', '<em>stuff</em>');
$this->assertEquals($result, '<em>stuff</em>');
$this->assertEquals('<em>stuff</em>', $result);
}
/**

View file

@ -2233,7 +2233,7 @@ class PaginatorHelperTest extends CakeTestCase {
*/
public function testParam() {
$result = $this->Paginator->param('count');
$this->assertIdentical(62, $result);
$this->assertSame(62, $result);
$result = $this->Paginator->param('imaginary');
$this->assertNull($result);

View file

@ -241,6 +241,14 @@ class TextHelperTest extends CakeTestCase {
'Text with a url http://www.not--work.com and more',
'Text with a url <a href="http://www.not--work.com">http://www.not--work.com</a> and more',
),
array(
'Text with a partial www.küchenschöhn-not-working.de URL',
'Text with a partial <a href="http://www.küchenschöhn-not-working.de">www.küchenschöhn-not-working.de</a> URL'
),
array(
'Text with a partial http://www.küchenschöhn-not-working.de URL',
'Text with a partial <a href="http://www.küchenschöhn-not-working.de">http://www.küchenschöhn-not-working.de</a> URL'
)
);
}
@ -351,6 +359,16 @@ class TextHelperTest extends CakeTestCase {
$expected = 'Text with <a href="mailto:email@example.com" \s*class="link">email@example.com</a> address';
$result = $this->Text->autoLinkEmails($text, array('class' => 'link'));
$this->assertRegExp('#^' . $expected . '$#', $result);
$text = 'Text with düsentrieb@küchenschöhn-not-working.de address';
$expected = 'Text with <a href="mailto:düsentrieb@küchenschöhn-not-working.de">düsentrieb@küchenschöhn-not-working.de</a> address';
$result = $this->Text->autoLinkEmails($text);
$this->assertRegExp('#^' . $expected . '$#', $result);
$text = 'Text with me@subdomain.küchenschöhn.de address';
$expected = 'Text with <a href="mailto:me@subdomain.küchenschöhn.de">me@subdomain.küchenschöhn.de</a> address';
$result = $this->Text->autoLinkEmails($text);
$this->assertRegExp('#^' . $expected . '$#', $result);
}
/**
@ -383,7 +401,7 @@ TEXT;
TEXT;
$result = $this->Text->autoParagraph($text);
$this->assertEquals($expected, $result);
$this->assertTextEquals($expected, $result);
$result = $this->Text->autoParagraph($text);
$text = 'This is a <BR id="test"/><br class="test"> test text';
$expected = <<<TEXT
@ -392,7 +410,7 @@ TEXT;
TEXT;
$result = $this->Text->autoParagraph($text);
$this->assertEquals($expected, $result);
$this->assertTextEquals($expected, $result);
$text = <<<TEXT
This is a test text.
This is a line return.
@ -403,7 +421,7 @@ This is a line return.</p>
TEXT;
$result = $this->Text->autoParagraph($text);
$this->assertEquals($expected, $result);
$this->assertTextEquals($expected, $result);
$text = <<<TEXT
This is a test text.
@ -415,7 +433,7 @@ TEXT;
TEXT;
$result = $this->Text->autoParagraph($text);
$this->assertEquals($expected, $result);
$this->assertTextEquals($expected, $result);
}
}

View file

@ -1388,7 +1388,7 @@ class ViewTest extends CakeTestCase {
public function testBlockSetDecimal() {
$this->View->assign('testWithDecimal', 1.23456789);
$result = $this->View->fetch('testWithDecimal');
$this->assertEqual('1.23456789', $result);
$this->assertEquals('1.23456789', $result);
}
/**

View file

@ -1,6 +1,6 @@
<?php
/**
* This class helpes in indirectly testing the functionaliteies of CakeTestCase::assertTags
* This class helpes in indirectly testing the functionalities of CakeTestCase::assertTags
*
* @package Cake.Test.Fixture
*/

View file

@ -42,7 +42,7 @@ class CakeTestLoader extends PHPUnit_Runner_StandardTestSuiteLoader {
}
/**
* Convert path fragments used by Cake's test runner to absolute paths that can be fed to PHPUnit.
* Convert path fragments used by CakePHP's test runner to absolute paths that can be fed to PHPUnit.
*
* @param string $filePath
* @param string $params

View file

@ -22,14 +22,14 @@ require_once 'PHPUnit/TextUI/TestRunner.php';
App::uses('CakeFixtureManager', 'TestSuite/Fixture');
/**
* A custom test runner for Cake's use of PHPUnit.
* A custom test runner for CakePHP's use of PHPUnit.
*
* @package Cake.TestSuite
*/
class CakeTestRunner extends PHPUnit_TextUI_TestRunner {
/**
* Lets us pass in some options needed for cake's webrunner.
* Lets us pass in some options needed for CakePHP's webrunner.
*
* @param mixed $loader
* @param array $params list of options to be used for this run

View file

@ -32,7 +32,7 @@ class CakeTestFixture {
public $name = null;
/**
* Cake's DBO driver (e.g: DboMysql).
* CakePHP's DBO driver (e.g: DboMysql).
*
* @var object
*/

View file

@ -18,7 +18,7 @@
* Pluralize and singularize English words.
*
* Inflector pluralizes and singularizes English nouns.
* Used by Cake's naming conventions throughout the framework.
* Used by CakePHP's naming conventions throughout the framework.
*
* @package Cake.Utility
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html

View file

@ -23,7 +23,7 @@
App::uses('HttpSocket', 'Network/Http');
/**
* XML handling for Cake.
* XML handling for CakePHP.
*
* The methods in these classes enable the datasources that use XML to work.
*

View file

@ -105,7 +105,7 @@ class TextHelper extends AppHelper {
$this->_placeholders = array();
$options += array('escape' => true);
$pattern = '#(?<!href="|src="|">)((?:https?|ftp|nntp)://[a-z0-9.\-:]+(?:[/?][^\s<]*)?)#i';
$pattern = '#(?<!href="|src="|">)((?:https?|ftp|nntp)://[\p{L}0-9.\-:]+(?:[/?][^\s<]*)?)#ui';
$text = preg_replace_callback(
$pattern,
array(&$this, '_insertPlaceHolder'),
@ -186,9 +186,9 @@ class TextHelper extends AppHelper {
$options += array('escape' => true);
$this->_placeholders = array();
$atom = '[a-z0-9!#$%&\'*+\/=?^_`{|}~-]';
$atom = '[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]';
$text = preg_replace_callback(
'/(' . $atom . '+(?:\.' . $atom . '+)*@[a-z0-9-]+(?:\.[a-z0-9-]+)+)/i',
'/(' . $atom . '+(?:\.' . $atom . '+)*@[\p{L}0-9-]+(?:\.[\p{L}0-9-]+)+)/ui',
array(&$this, '_insertPlaceholder'),
$text
);

View file

@ -136,7 +136,7 @@ class View extends Object {
public $layoutPath = null;
/**
* Turns on or off Cake's conventional mode of applying layout files. On by default.
* Turns on or off CakePHP's conventional mode of applying layout files. On by default.
* Setting to off means that layouts will not be automatically applied to rendered views.
*
* @var boolean
@ -144,7 +144,7 @@ class View extends Object {
public $autoLayout = true;
/**
* File extension. Defaults to Cake's template ".ctp".
* File extension. Defaults to CakePHP's template ".ctp".
*
* @var string
*/

View file

@ -1,6 +1,6 @@
<?php
/**
* Basic Cake functionality.
* Basic CakePHP functionality.
*
* Handles loading of core files needed on every request
*