Permalink
Browse files

Merge branch 'master' into 2.3

Conflicts:
	app/Config/Schema/i18n.php
	lib/Cake/I18n/Multibyte.php
	lib/Cake/Test/Case/Log/CakeLogTest.php
	lib/Cake/Test/Case/Routing/DispatcherTest.php
  • Loading branch information...
2 parents 6378aab + 644d47c commit e0aab77dabb39cfda36598b768d1a58acf4b53a6 @markstory markstory committed Nov 11, 2012
View
@@ -10,6 +10,16 @@ env:
- DB=pgsql
- DB=sqlite
+matrix:
+ allow_failures:
+ - php: 5.4
+ env:
+ - PHPCS=1
+ include:
+ - php: 5.4
+ env:
+ - PHPCS=1
+
before_script:
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test;'; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE cakephp_test2;'; fi"
@@ -23,6 +33,9 @@ before_script:
server.listen(80, 'localhost');
console.log('TCP server listening on port 80 at localhost.');" > app/tmp/socket.js
- sudo node ./app/tmp/socket.js &
+ - pear channel-discover pear.cakephp.org
+ - pear install --alldeps cakephp/CakePHP_CodeSniffer
+ - phpenv rehash
- set +H
- echo "<?php
class DATABASE_CONFIG {
@@ -105,7 +118,7 @@ before_script:
}" > app/Config/database.php
script:
- - ./lib/Cake/Console/cake test core AllTests --stderr
+ - sh -c "if [ '$PHPCS' != '1' ]; then ./lib/Cake/Console/cake test core AllTests --stderr; else phpcs --extensions=php --standard=CakePHP ./lib/Cake; fi"
notifications:
email: false
@@ -21,7 +21,9 @@
*
* cake schema run create i18n
*/
+// @codingStandardsIgnoreStart
class I18nSchema extends CakeSchema {
+// @codingStandardsIgnoreEnd
public $name = 'i18n';
@@ -114,7 +114,7 @@ public function getOptionParser() {
))->addOption('stop-on-failure', array(
'help' => __d('cake_console', 'Stop execution upon first failure.'),
'boolean' => true
- ))->addOption('stop-on-skipped ', array(
+ ))->addOption('stop-on-skipped', array(
'help' => __d('cake_console', 'Stop execution upon first skipped test.'),
'boolean' => true
))->addOption('stop-on-incomplete', array(
@@ -132,7 +132,7 @@ public function getOptionParser() {
))->addOption('no-globals-backup', array(
'help' => __d('cake_console', 'Do not backup and restore $GLOBALS for each test.'),
'boolean' => true
- ))->addOption('static-backup ', array(
+ ))->addOption('static-backup', array(
'help' => __d('cake_console', 'Backup and restore static attributes for each test.'),
'boolean' => true
))->addOption('syntax-check', array(
@@ -21,14 +21,17 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
+// @codingStandardsIgnoreStart
+
/*
*
* Using the Schema command line utility
* cake schema run create i18n
- *
*/
class i18nSchema extends CakeSchema {
+// @codingStandardsIgnoreEnd
+
public $name = 'i18n';
public function before($event = array()) {
@@ -93,7 +93,7 @@ protected function _findUser($conditions, $password = null) {
}
$result = ClassRegistry::init($userModel)->find('first', array(
'conditions' => $conditions,
- 'recursive' => (int)$this->settings['recursive'],
+ 'recursive' => $this->settings['recursive'],
'contain' => $this->settings['contain'],
));
if (empty($result) || empty($result[$model])) {
@@ -170,7 +170,7 @@ protected function _findUser($username, $password = null) {
}
$result = ClassRegistry::init($userModel)->find('first', array(
'conditions' => $conditions,
- 'recursive' => (int)$this->settings['recursive']
+ 'recursive' => $this->settings['recursive']
));
if (empty($result) || empty($result[$model])) {
return false;
@@ -753,8 +753,8 @@ public static function mimeEncode($string, $charset = null, $newline = "\r\n") {
if ($charset == 'UTF-8') {
$parts = array();
$maxchars = floor(($length * 3) / 4);
- $strlen = strlen($string);
- while ($strlen > $maxchars) {
+ $stringLength = strlen($string);
+ while ($stringLength > $maxchars) {
$i = (int)$maxchars;
$test = ord($string[$i]);
while ($test >= 128 && $test <= 191) {
@@ -763,7 +763,7 @@ public static function mimeEncode($string, $charset = null, $newline = "\r\n") {
}
$parts[] = base64_encode(substr($string, 0, $i));
$string = substr($string, $i);
- $strlen = strlen($string);
+ $stringLength = strlen($string);
}
$parts[] = base64_encode($string);
$string = implode($spacer, $parts);
@@ -2916,6 +2916,10 @@ public function insertMulti($table, $fields, $values) {
}
$statement->execute();
$statement->closeCursor();
+
+ if ($this->fullDebug) {
+ $this->logQuery($sql, $value);
+ }
}
return $this->commit();
}
View
@@ -565,6 +565,8 @@ class Model extends Object implements CakeEventListener {
*/
protected $_associations = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany');
+// @codingStandardsIgnoreStart
+
/**
* Holds model associations temporarily to allow for dynamic (un)binding.
*
@@ -593,6 +595,8 @@ class Model extends Object implements CakeEventListener {
*/
public $__backContainableAssociation = array();
+// @codingStandardsIgnoreEnd
+
/**
* The ID of the model record that was last inserted.
*
@@ -163,9 +163,9 @@ public function isRequired() {
*/
public function checkRequired($field, &$data) {
return (
- (!isset($data[$field]) && $this->isRequired() === true) ||
+ (!array_key_exists($field, $data) && $this->isRequired() === true) ||
(
- isset($data[$field]) && (empty($data[$field]) &&
+ array_key_exists($field, $data) && (empty($data[$field]) &&
!is_numeric($data[$field])) && $this->allowEmpty === false
)
);
@@ -483,7 +483,7 @@ public function testRevoke() {
/**
* debug function - to help editing/creating test cases for the ACL component
*
- * To check the overall ACL status at any time call $this->__debug();
+ * To check the overall ACL status at any time call $this->_debug();
* Generates a list of the current aro and aco structures and a grid dump of the permissions that are defined
* Only designed to work with the db based ACL
*
@@ -3017,7 +3017,8 @@ public function testHasOneFieldsInContain() {
'User' => array(
'fields' => array('user')
)
- )
+ ),
+ 'order' => 'Article.id ASC',
));
$this->assertTrue(isset($result[0]['Article']['title']), 'title missing %s');
$this->assertTrue(isset($result[0]['Article']['body']), 'body missing %s');
@@ -3040,7 +3041,10 @@ public function testFindConditionalBinding() {
'conditions' => array('created >=' => '2007-03-18 12:24')
)
));
- $result = $this->Article->find('all', array('fields' => array('title'), 'order' => array('Article.id' => 'ASC')));
+ $result = $this->Article->find('all', array(
+ 'fields' => array('title'),
+ 'order' => array('Article.id' => 'ASC')
+ ));
$expected = array(
array(
'Article' => array('id' => 1, 'title' => 'First Article'),
@@ -4203,7 +4203,8 @@ public function testBindUnbind() {
$this->assertTrue($result);
$result = $TestModel->find('all', array(
- 'fields' => 'User.id, User.user'
+ 'fields' => 'User.id, User.user',
+ 'order' => array('User.id' => 'ASC'),
));
$expected = array(
array(
@@ -4296,7 +4297,8 @@ public function testBindUnbind() {
$this->assertTrue($result);
$result = $TestModel->find('all', array(
- 'fields' => 'User.id, User.user'
+ 'fields' => 'User.id, User.user',
+ 'order' => array('User.id' => 'ASC'),
));
$expected = array(
@@ -4407,7 +4409,8 @@ public function testBindUnbind() {
$this->assertEquals($expected, $result);
$result = $TestModel->find('all', array(
- 'fields' => 'User.id, User.user'
+ 'fields' => 'User.id, User.user',
+ 'order' => array('User.id' => 'ASC'),
));
$expected = array(
array('User' => array('id' => '1', 'user' => 'mariano')),
@@ -4417,7 +4420,8 @@ public function testBindUnbind() {
$this->assertEquals($expected, $result);
$result = $TestModel->find('all', array(
- 'fields' => 'User.id, User.user'
+ 'fields' => 'User.id, User.user',
+ 'order' => array('User.id' => 'ASC'),
));
$expected = array(
array(
@@ -4505,7 +4509,10 @@ public function testBindUnbind() {
$result = $TestModel->unbindModel(array('hasMany' => array('Comment')), false);
$this->assertTrue($result);
- $result = $TestModel->find('all', array('fields' => 'User.id, User.user'));
+ $result = $TestModel->find('all', array(
+ 'fields' => 'User.id, User.user',
+ 'order' => array('User.id' => 'ASC'),
+ ));
$expected = array(
array('User' => array('id' => '1', 'user' => 'mariano')),
array('User' => array('id' => '2', 'user' => 'nate')),
@@ -4522,7 +4529,10 @@ public function testBindUnbind() {
)));
$this->assertTrue($result);
- $result = $TestModel->find('all', array('fields' => 'User.id, User.user'));
+ $result = $TestModel->find('all', array(
+ 'fields' => 'User.id, User.user',
+ 'order' => array('User.id' => 'ASC'),
+ ));
$expected = array(
array(
'User' => array(
@@ -5113,7 +5123,10 @@ public function testCallbackDisabling() {
public function testAssociationAfterFindCalbacksDisabled() {
$this->loadFixtures('Post', 'Author', 'Comment');
$TestModel = new Post();
- $result = $TestModel->find('all', array('callbacks' => false));
+ $result = $TestModel->find('all', array(
+ 'callbacks' => false,
+ 'order' => array('Post.id' => 'ASC'),
+ ));
$expected = array(
array(
'Post' => array(
@@ -5180,6 +5193,7 @@ public function testAssociationAfterFindCalbacksDisabled() {
$result = $Author->find('all', array(
'conditions' => array('Author.id' => 1),
'recursive' => 2,
+ 'order' => array('Author.id' => 'ASC'),
'callbacks' => false
));
$expected = array(
@@ -171,4 +171,29 @@ public function testIsEmptyAllowed() {
$Rule->isUpdate(true);
$this->assertTrue($Rule->isEmptyAllowed());
}
+
+/**
+ * Test checkRequired method
+ *
+ * @return void
+ */
+ public function testCheckRequiredWhenRequiredAndAllowEmpty() {
+ $Rule = $this->getMock('CakeValidationRule', array('isRequired'));
+ $Rule->expects($this->any())
+ ->method('isRequired')
+ ->will($this->returnValue(true));
+ $Rule->allowEmpty = true;
+
+ $fieldname = 'field';
+ $data = array(
+ $fieldname => null
+ );
+
+ $this->assertFalse($Rule->checkRequired($fieldname, $data), "A null but present field should not fail requirement check if allowEmpty is true");
+
+ $Rule->allowEmpty = false;
+
+ $this->assertTrue($Rule->checkRequired($fieldname, $data), "A null but present field should fail requirement check if allowEmpty is false");
+ }
+
}
@@ -1658,72 +1658,6 @@ public function testHttpMethodOverrides() {
}
/**
- * backupEnvironment method
- *
- * @return void
- */
- protected function _backupEnvironment() {
- return array(
- 'App' => Configure::read('App'),
- 'GET' => $_GET,
- 'POST' => $_POST,
- 'SERVER' => $_SERVER
- );
- }
-
-/**
- * reloadEnvironment method
- *
- * @return void
- */
- protected function _reloadEnvironment() {
- foreach ($_GET as $key => $val) {
- unset($_GET[$key]);
- }
- foreach ($_POST as $key => $val) {
- unset($_POST[$key]);
- }
- foreach ($_SERVER as $key => $val) {
- unset($_SERVER[$key]);
- }
- Configure::write('App', array());
- }
-
-/**
- * loadEnvironment method
- *
- * @param array $env
- * @return void
- */
- protected function _loadEnvironment($env) {
- if ($env['reload']) {
- $this->_reloadEnvironment();
- }
-
- if (isset($env['App'])) {
- Configure::write('App', $env['App']);
- }
-
- if (isset($env['GET'])) {
- foreach ($env['GET'] as $key => $val) {
- $_GET[$key] = $val;
- }
- }
-
- if (isset($env['POST'])) {
- foreach ($env['POST'] as $key => $val) {
- $_POST[$key] = $val;
- }
- }
-
- if (isset($env['SERVER'])) {
- foreach ($env['SERVER'] as $key => $val) {
- $_SERVER[$key] = $val;
- }
- }
- }
-
-/**
* cachePath method
*
* @param string $here
Oops, something went wrong.

0 comments on commit e0aab77

Please sign in to comment.