Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' into 2.3

Conflicts:
	lib/Cake/Test/Case/Model/ModelReadTest.php
	lib/Cake/Test/Case/View/MediaViewTest.php
  • Loading branch information...
commit 82d20ed9480156c7bc7d019f8c5581c1e6ae8a2b 2 parents 4025794 + 3083b01
@markstory markstory authored
View
2  lib/Cake/Controller/CakeErrorController.php
@@ -66,8 +66,6 @@ public function __construct($request = null, $response = null) {
if ($this->Components->enabled('Security')) {
$this->Components->disable('Security');
}
- $this->startupProcess();
-
$this->_set(array('cacheAction' => false, 'viewPath' => 'Errors'));
}
View
4 lib/Cake/Error/ExceptionRenderer.php
@@ -151,7 +151,11 @@ protected function _getController($exception) {
try {
$controller = new CakeErrorController($request, $response);
+ $controller->startupProcess();
} catch (Exception $e) {
+ if (!empty($controller) && $controller->Components->enabled('RequestHandler')) {
+ $controller->RequestHandler->startup($controller);
+ }
}
if (empty($controller)) {
$controller = new Controller($request, $response);
View
7 lib/Cake/Model/Datasource/DboSource.php
@@ -2281,7 +2281,8 @@ public function fields(Model $model, $alias = null, $fields = array(), $quote =
$virtualFields,
$fields,
$quote,
- ConnectionManager::getSourceName($this)
+ ConnectionManager::getSourceName($this),
+ $model->table
);
$cacheKey = md5(serialize($cacheKey));
if ($return = $this->cacheMethod(__FUNCTION__, $cacheKey)) {
@@ -2463,6 +2464,10 @@ public function conditionKeysToString($conditions, $quoteValues = true, $model =
$not = 'NOT ';
}
+ if (empty($value)) {
+ continue;
+ }
+
if (empty($value[1])) {
if ($not) {
$out[] = $not . '(' . $value[0] . ')';
View
13 lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php
@@ -160,6 +160,19 @@ public function testBooleanNullConditionsParsing() {
}
/**
+ * test that booleans work on empty set.
+ *
+ * @return void
+ */
+ public function testBooleanEmptyConditionsParsing() {
+ $result = $this->testDb->conditions(array('OR' => array()));
+ $this->assertEquals(' WHERE 1 = 1', $result, 'empty conditions failed');
+
+ $result = $this->testDb->conditions(array('OR' => array('OR' => array())));
+ $this->assertEquals(' WHERE 1 = 1', $result, 'nested empty conditions failed');
+ }
+
+/**
* test that order() will accept objects made from DboSource::expression
*
* @return void
View
16 lib/Cake/Test/Case/Model/ModelReadTest.php
@@ -5401,7 +5401,7 @@ public function testNonNumericHabtmJoinKey() {
$Post->Tag->primaryKey = 'tag';
$result = $Post->find('all', array(
- 'order' => array('Post.id' => 'ASC')
+ 'order' => 'Post.id ASC',
));
$expected = array(
array(
@@ -5617,7 +5617,9 @@ public function testHasManyLimitOptimization() {
$Project = new Project();
$Project->recursive = 3;
- $result = $Project->find('all');
+ $result = $Project->find('all', array(
+ 'order' => 'Project.id ASC',
+ ));
$expected = array(
array(
'Project' => array(
@@ -5731,7 +5733,9 @@ public function testFindAllRecursiveSelfJoin() {
$TestModel = new Home();
$TestModel->recursive = 2;
- $result = $TestModel->find('all');
+ $result = $TestModel->find('all', array(
+ 'order' => 'Home.id ASC',
+ ));
$expected = array(
array(
'Home' => array(
@@ -5844,7 +5848,9 @@ public function testFindAllRecursiveWithHabtm() {
$MyUser = new MyUser();
$MyUser->recursive = 2;
- $result = $MyUser->find('all');
+ $result = $MyUser->find('all', array(
+ 'order' => 'MyUser.id ASC'
+ ));
$expected = array(
array(
'MyUser' => array('id' => '1', 'firstname' => 'userA'),
@@ -6035,7 +6041,7 @@ public function testFindAllFakeThread() {
$fullDebug = $this->db->fullDebug;
$this->db->fullDebug = true;
$TestModel->recursive = 6;
- $result = $TestModel->find('all', null, null, 'CategoryThread.id ASC');
+ $result = $TestModel->find('all');
$expected = array(
array(
'CategoryThread' => array(
View
120 lib/Cake/Test/Case/View/MediaViewTest.php
@@ -40,9 +40,11 @@ public function setUp() {
'_isActive',
'_clearBuffer',
'_flushBuffer',
+ 'send',
+ 'cache',
'type',
- 'header',
- 'download'
+ 'download',
+ 'statusCode'
));
}
@@ -90,22 +92,11 @@ public function testRender() {
->with('css')
->will($this->returnArgument(0));
- $this->MediaView->response->expects($this->at(0))
- ->method('header')
- ->with(array(
- 'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT',
- 'Cache-Control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
- 'Last-Modified' => gmdate('D, d M Y H:i:s', time()) . ' GMT'
- ));
-
- $this->MediaView->response->expects($this->at(2))
- ->method('header')
- ->with('Content-Length', 38);
-
- $this->MediaView->response->expects($this->once())->method('_clearBuffer');
+ $this->MediaView->response->expects($this->once())->method('send');
$this->MediaView->response->expects($this->exactly(1))
->method('_isActive')
->will($this->returnValue(true));
+ $this->MediaView->response->expects($this->once())->method('_clearBuffer');
$this->MediaView->response->expects($this->once())->method('_flushBuffer');
ob_start();
@@ -113,6 +104,16 @@ public function testRender() {
$output = ob_get_clean();
$this->assertEquals("/* this is the test asset css file */\n", $output);
$this->assertTrue($result !== false);
+
+ $headers = $this->MediaView->response->header();
+ $this->assertEquals(31, $headers['Content-Length']);
+ $this->assertEquals(0, $headers['Expires']);
+ $this->assertEquals(
+ 'private, must-revalidate, post-check=0, pre-check=0',
+ $headers['Cache-Control']
+ );
+ $this->assertEquals('no-cache', $headers['Pragma']);
+ $this->assertContains(gmdate('D, d M Y H:i', time()), $headers['Date']);
}
/**
@@ -133,28 +134,10 @@ public function testRenderWithUnknownFileTypeGeneric() {
->with('ini')
->will($this->returnValue(false));
- $this->MediaView->response->expects($this->at(0))
- ->method('header')
- ->with($this->logicalAnd(
- $this->arrayHasKey('Last-Modified'),
- $this->arrayHasKey('Expires'),
- $this->arrayHasKey('Cache-Control'),
- $this->contains('Mon, 26 Jul 1997 05:00:00 GMT'),
- $this->contains('no-store, no-cache, must-revalidate, post-check=0, pre-check=0')
- ));
-
$this->MediaView->response->expects($this->once())
->method('download')
->with('no_section.ini');
- $this->MediaView->response->expects($this->at(3))
- ->method('header')
- ->with('Accept-Ranges', 'bytes');
-
- $this->MediaView->response->expects($this->at(4))
- ->method('header')
- ->with('Content-Length', 35);
-
$this->MediaView->response->expects($this->once())->method('_clearBuffer');
$this->MediaView->response->expects($this->exactly(1))
->method('_isActive')
@@ -169,6 +152,17 @@ public function testRenderWithUnknownFileTypeGeneric() {
if ($currentUserAgent !== null) {
$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
}
+
+ $headers = $this->MediaView->response->header();
+ $this->assertEquals(35, $headers['Content-Length']);
+ $this->assertEquals(0, $headers['Expires']);
+ $this->assertEquals('bytes', $headers['Accept-Ranges']);
+ $this->assertEquals(
+ 'private, must-revalidate, post-check=0, pre-check=0',
+ $headers['Cache-Control']
+ );
+ $this->assertEquals('no-cache', $headers['Pragma']);
+ $this->assertContains(gmdate('D, d M Y H:i', time()), $headers['Date']);
}
/**
@@ -185,19 +179,11 @@ public function testRenderWithUnknownFileTypeOpera() {
);
$this->MediaView->response->expects($this->at(0))
- ->method('header')
- ->with(array(
- 'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT',
- 'Cache-Control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
- 'Last-Modified' => gmdate('D, d M Y H:i:s', time()) . ' GMT'
- ));
-
- $this->MediaView->response->expects($this->at(1))
->method('type')
->with('ini')
->will($this->returnValue(false));
- $this->MediaView->response->expects($this->at(2))
+ $this->MediaView->response->expects($this->at(1))
->method('type')
->with('application/octetstream')
->will($this->returnValue(false));
@@ -206,14 +192,7 @@ public function testRenderWithUnknownFileTypeOpera() {
->method('download')
->with('no_section.ini');
- $this->MediaView->response->expects($this->at(4))
- ->method('header')
- ->with('Accept-Ranges', 'bytes');
-
- $this->MediaView->response->expects($this->at(5))
- ->method('header')
- ->with('Content-Length', 35);
-
+ $this->MediaView->response->expects($this->once())->method('send');
$this->MediaView->response->expects($this->once())->method('_clearBuffer');
$this->MediaView->response->expects($this->exactly(1))
->method('_isActive')
@@ -228,6 +207,17 @@ public function testRenderWithUnknownFileTypeOpera() {
if ($currentUserAgent !== null) {
$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
}
+
+ $headers = $this->MediaView->response->header();
+ $this->assertEquals(35, $headers['Content-Length']);
+ $this->assertEquals(0, $headers['Expires']);
+ $this->assertEquals('bytes', $headers['Accept-Ranges']);
+ $this->assertEquals(
+ 'private, must-revalidate, post-check=0, pre-check=0',
+ $headers['Cache-Control']
+ );
+ $this->assertEquals('no-cache', $headers['Pragma']);
+ $this->assertContains(gmdate('D, d M Y H:i', time()), $headers['Date']);
}
/**
@@ -245,19 +235,11 @@ public function testRenderWithUnknownFileTypeIE() {
);
$this->MediaView->response->expects($this->at(0))
- ->method('header')
- ->with(array(
- 'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT',
- 'Cache-Control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
- 'Last-Modified' => gmdate('D, d M Y H:i:s', time()) . ' GMT'
- ));
-
- $this->MediaView->response->expects($this->at(1))
->method('type')
->with('ini')
->will($this->returnValue(false));
- $this->MediaView->response->expects($this->at(2))
+ $this->MediaView->response->expects($this->at(1))
->method('type')
->with('application/force-download')
->will($this->returnValue(false));
@@ -266,14 +248,7 @@ public function testRenderWithUnknownFileTypeIE() {
->method('download')
->with('config.ini');
- $this->MediaView->response->expects($this->at(4))
- ->method('header')
- ->with('Accept-Ranges', 'bytes');
-
- $this->MediaView->response->expects($this->at(5))
- ->method('header')
- ->with('Content-Length', 35);
-
+ $this->MediaView->response->expects($this->once())->method('send');
$this->MediaView->response->expects($this->once())->method('_clearBuffer');
$this->MediaView->response->expects($this->exactly(1))
->method('_isActive')
@@ -288,6 +263,17 @@ public function testRenderWithUnknownFileTypeIE() {
if ($currentUserAgent !== null) {
$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
}
+
+ $headers = $this->MediaView->response->header();
+ $this->assertEquals(35, $headers['Content-Length']);
+ $this->assertEquals(0, $headers['Expires']);
+ $this->assertEquals('bytes', $headers['Accept-Ranges']);
+ $this->assertEquals(
+ 'private, must-revalidate, post-check=0, pre-check=0',
+ $headers['Cache-Control']
+ );
+ $this->assertEquals('no-cache', $headers['Pragma']);
+ $this->assertContains(gmdate('D, d M Y H:i', time()), $headers['Date']);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.