Permalink
Browse files

Merge branch 'master' into 2.3

Conflicts:
	lib/Cake/View/Helper/FormHelper.php
  • Loading branch information...
2 parents 31a5401 + e8f727f commit c24bec679bbe76bae615518b65c832e0532ef508 @markstory markstory committed Oct 28, 2012
@@ -51,7 +51,11 @@ class CakeErrorController extends AppController {
*/
public function __construct($request = null, $response = null) {
parent::__construct($request, $response);
- if (count(Router::extensions())) {
+ if (
+ count(Router::extensions()) &&
+ !array_key_exists('RequestHandler', $this->components) &&
+ !in_array('RequestHandler', $this->components, true)
+ ) {
$this->components[] = 'RequestHandler';
}
$this->constructClasses();
@@ -2623,9 +2623,12 @@ public function hasAny($conditions = null) {
*
* Note: find(list) + database views have issues with MySQL 5.0. Try upgrading to MySQL 5.1 if you
* have issues with database views.
+ *
+ * Note: find(count) has its own return values.
+ *
* @param string $type Type of find operation (all / first / count / neighbors / list / threaded)
* @param array $query Option fields (conditions / fields / joins / limit / offset / order / page / group / callbacks)
- * @return array Array of records
+ * @return array Array of records, or Null on failure.
* @link http://book.cakephp.org/2.0/en/models/deleting-data.html#deleteall
*/
public function find($type = 'first', $query = array()) {
@@ -2648,10 +2651,10 @@ public function find($type = 'first', $query = array()) {
if ($type === 'all') {
return $results;
- } else {
- if ($this->findMethods[$type] === true) {
- return $this->{'_find' . ucfirst($type)}('after', $query, $results);
- }
+ }
+
+ if ($this->findMethods[$type] === true) {
+ return $this->{'_find' . ucfirst($type)}('after', $query, $results);
}
}
@@ -2717,7 +2720,7 @@ protected function _findFirst($state, $query, $results = array()) {
return $query;
} elseif ($state === 'after') {
if (empty($results[0])) {
- return false;
+ return array();
}
return $results[0];
}
@@ -15,8 +15,7 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-
-App::uses('Set', 'Utility');
+App::uses('Hash', 'Utility');
/**
* A class that helps wrap Request information and particulars about a single request.
@@ -353,7 +352,7 @@ protected function _processFileData($path, $data, $field) {
$this->_processFileData($newPath, $fields, $field);
} else {
$newPath .= '.' . $field;
- $this->data = Set::insert($this->data, $newPath, $fields);
+ $this->data = Hash::insert($this->data, $newPath, $fields);
}
}
}
@@ -67,7 +67,7 @@ public function testArrayDiffKey() {
$one = array('minYear' => null, 'maxYear' => null, 'separator' => '-', 'interval' => 1, 'monthNames' => true);
$two = array('minYear' => null, 'maxYear' => null, 'separator' => '-', 'interval' => 1, 'monthNames' => true);
$result = array_diff_key($one, $two);
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
}
/**
@@ -229,12 +229,11 @@ public function testExpiry() {
$result = Cache::write('other_test', $data, 'memcache');
$this->assertTrue($result);
- sleep(2);
+ sleep(3);
$result = Cache::read('other_test', 'memcache');
$this->assertFalse($result);
Cache::config('memcache', array('duration' => '+1 second'));
- sleep(2);
$result = Cache::read('other_test', 'memcache');
$this->assertFalse($result);
@@ -177,7 +177,7 @@ public function testDelete() {
$Aro = ClassRegistry::init('Aro');
$result = $Aro->findById(3);
- $this->assertFalse($result);
+ $this->assertSame(array(), $result);
}
/**
@@ -181,7 +181,7 @@ public function testGetNameInvalidIndex() {
public function testDoHelpersNo() {
$this->Task->expects($this->any())->method('in')->will($this->returnValue('n'));
$result = $this->Task->doHelpers();
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
}
/**
@@ -218,7 +218,7 @@ public function testDoHelpersTrailingCommas() {
public function testDoComponentsNo() {
$this->Task->expects($this->any())->method('in')->will($this->returnValue('n'));
$result = $this->Task->doComponents();
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
}
/**
@@ -347,7 +347,7 @@ public function testListObjects() {
$this->assertEquals($expected, $result);
$result = App::objects('NonExistingType');
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
App::build(array(
'plugins' => array(
@@ -414,9 +414,9 @@ public function testListObjectsInPlugin() {
$this->assertTrue(in_array('OtherComponent', $result));
$result = App::objects('TestPluginTwo.behavior');
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
$result = App::objects('TestPluginTwo.Model/Behavior');
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
$result = App::objects('model', null, false);
$this->assertTrue(in_array('Comment', $result));
@@ -175,7 +175,7 @@ public function testDrop() {
CakeLog::drop('file');
$result = CakeLog::configured();
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
}
/**
@@ -422,7 +422,7 @@ public function testMissingTranslation() {
$TestModel = new TranslatedItem();
$TestModel->locale = 'rus';
$result = $TestModel->read(null, 1);
- $this->assertFalse($result);
+ $this->assertSame(array(), $result);
$TestModel->locale = array('rus');
$result = $TestModel->read(null, 1);
@@ -460,10 +460,10 @@ public function testTranslatedFindList() {
Configure::write('debug', 0);
$result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => false));
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
$result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => 'after'));
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
Configure::write('debug', $debug);
}
@@ -582,7 +582,7 @@ public function testBuildIndex() {
$indexes = array('client_id' => array('column' => 'client_id'));
$result = $this->db->buildIndex($indexes, 'items');
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
$indexes = array('client_id' => array('column' => array('client_id', 'period_id'), 'unique' => 1));
$result = $this->db->buildIndex($indexes, 'items');
@@ -107,12 +107,12 @@ public function testDeleteHabtmReferenceWithConditions() {
$result = $Portfolio->find('first', array(
'conditions' => array('Portfolio.id' => 1)
));
- $this->assertFalse($result);
+ $this->assertSame(array(), $result);
$result = $Portfolio->ItemsPortfolio->find('all', array(
'conditions' => array('ItemsPortfolio.portfolio_id' => 1)
));
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
}
/**
@@ -195,7 +195,7 @@ public function testDelete() {
$this->assertTrue($result);
$result = $TestModel->read(null, 2);
- $this->assertFalse($result);
+ $this->assertSame(array(), $result);
$TestModel->recursive = -1;
$result = $TestModel->find('all', array(
@@ -216,7 +216,7 @@ public function testDelete() {
$this->assertTrue($result);
$result = $TestModel->read(null, 3);
- $this->assertFalse($result);
+ $this->assertSame(array(), $result);
$TestModel->recursive = -1;
$result = $TestModel->find('all', array(
@@ -448,16 +448,16 @@ public function testRecursiveDel() {
$TestModel->recursive = 2;
$result = $TestModel->read(null, 2);
- $this->assertFalse($result);
+ $this->assertSame(array(), $result);
$result = $TestModel->Comment->read(null, 5);
- $this->assertFalse($result);
+ $this->assertSame(array(), $result);
$result = $TestModel->Comment->read(null, 6);
- $this->assertFalse($result);
+ $this->assertSame(array(), $result);
$result = $TestModel->Comment->Attachment->read(null, 1);
- $this->assertFalse($result);
+ $this->assertSame(array(), $result);
$result = $TestModel->find('count');
$this->assertEquals(2, $result);
@@ -4290,7 +4290,7 @@ public function testBindUnbind() {
$TestModel->resetAssociations();
$result = $TestModel->hasMany;
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
$result = $TestModel->bindModel(array('hasMany' => array('Comment')), false);
$this->assertTrue($result);
@@ -4536,7 +4536,7 @@ public function testSaveAllValidateFirst() {
$this->assertFalse($result);
$result = $model->find('all');
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
$expected = array('Comment' => array(
1 => array('comment' => array('This field cannot be left blank'))
));
@@ -5940,7 +5940,7 @@ public function testSaveAssociatedValidateFirst() {
$this->assertFalse($result);
$result = $model->find('all');
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
$expected = array('Comment' => array(
1 => array('comment' => array('This field cannot be left blank'))
));
@@ -111,7 +111,7 @@ public function testMapResources() {
$_SERVER['REQUEST_METHOD'] = 'GET';
$result = Router::parse('/posts/add');
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
Router::reload();
$resources = Router::mapResources('Posts', array('id' => '[a-z0-9_]+'));
@@ -1907,7 +1907,7 @@ public function testParsingWithPatternOnAction() {
$this->assertEquals($expected, $result);
$result = Router::parse('/blog/foobar');
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
$result = Router::url(array('controller' => 'blog_posts', 'action' => 'foo'));
$this->assertEquals('/blog_posts/foo', $result);
@@ -2117,7 +2117,7 @@ public function testRegexRouteMatching() {
$this->assertEquals($expected, $result);
$result = Router::parse('/badness/test/test_action');
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
Router::reload();
Router::connect('/:locale/:controller/:action/*', array(), array('locale' => 'dan|eng'));
@@ -474,7 +474,7 @@ public function testToServer() {
date_default_timezone_set('UTC');
- $serverTime = new DateTime('now');
+ $serverTime = new DateTime('2012-12-11 14:15:20');
$timezones = array('Europe/London', 'Europe/Brussels', 'UTC', 'America/Denver', 'America/Caracas', 'Asia/Kathmandu');
foreach ($timezones as $timezone) {
@@ -509,17 +509,18 @@ public function testToAtom() {
* @return void
*/
public function testToRss() {
- $this->assertEquals(date('r'), $this->Time->toRss(time()));
-
- if (!$this->skipIf(!class_exists('DateTimeZone'), '%s DateTimeZone class not available.')) {
- $timezones = array('Europe/London', 'Europe/Brussels', 'UTC', 'America/Denver', 'America/Caracas', 'Asia/Kathmandu');
- foreach ($timezones as $timezone) {
- $yourTimezone = new DateTimeZone($timezone);
- $yourTime = new DateTime('now', $yourTimezone);
- $userOffset = $yourTimezone->getOffset($yourTime) / HOUR;
- $this->assertEquals($yourTime->format('r'), $this->Time->toRss(time(), $userOffset));
- $this->assertEquals($yourTime->format('r'), $this->Time->toRss(time(), $timezone));
- }
+ $date = '2012-08-12 12:12:45';
+ $time = strtotime($date);
+ $this->assertEquals(date('r', $time), $this->Time->toRss($time));
+
+ $timezones = array('Europe/London', 'Europe/Brussels', 'UTC', 'America/Denver', 'America/Caracas', 'Asia/Kathmandu');
+ foreach ($timezones as $timezone) {
+ $yourTimezone = new DateTimeZone($timezone);
+ $yourTime = new DateTime($date, $yourTimezone);
+ $userOffset = $yourTimezone->getOffset($yourTime) / HOUR;
+ $time = $yourTime->getTimestamp();
+ $this->assertEquals($yourTime->format('r'), $this->Time->toRss($time, $userOffset), "Failed on $timezone");
+ $this->assertEquals($yourTime->format('r'), $this->Time->toRss($time, $timezone), "Failed on $timezone");
}
}
@@ -1967,7 +1967,7 @@ public function testCombine() {
$this->assertEquals($expected, $result);
$result = Set::combine($a, 'fail', 'fail');
- $this->assertEquals(array(), $result);
+ $this->assertSame(array(), $result);
}
/**
Oops, something went wrong. Retry.

0 comments on commit c24bec6

Please sign in to comment.