Merge branch 'master' into 2.3

Conflicts:
	lib/Cake/Test/Case/Model/ModelReadTest.php
	lib/Cake/Test/Case/View/MediaViewTest.php
This commit is contained in:
mark_story 2012-11-24 15:44:52 -05:00
commit 82d20ed948
6 changed files with 87 additions and 75 deletions

View file

@ -66,8 +66,6 @@ class CakeErrorController extends AppController {
if ($this->Components->enabled('Security')) {
$this->Components->disable('Security');
}
$this->startupProcess();
$this->_set(array('cacheAction' => false, 'viewPath' => 'Errors'));
}

View file

@ -151,7 +151,11 @@ class ExceptionRenderer {
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 file

@ -2281,7 +2281,8 @@ class DboSource extends DataSource {
$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 @@ class DboSource extends DataSource {
$not = 'NOT ';
}
if (empty($value)) {
continue;
}
if (empty($value[1])) {
if ($not) {
$out[] = $not . '(' . $value[0] . ')';

View file

@ -159,6 +159,19 @@ class DboSourceTest extends CakeTestCase {
$this->assertEquals(' WHERE 1 = 1', $result);
}
/**
* 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
*

View file

@ -5401,7 +5401,7 @@ class ModelReadTest extends BaseModelTest {
$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 @@ class ModelReadTest extends BaseModelTest {
$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 @@ class ModelReadTest extends BaseModelTest {
$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 @@ class ModelReadTest extends BaseModelTest {
$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 @@ class ModelReadTest extends BaseModelTest {
$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 file

@ -40,9 +40,11 @@ class MediaViewTest extends CakeTestCase {
'_isActive',
'_clearBuffer',
'_flushBuffer',
'send',
'cache',
'type',
'header',
'download'
'download',
'statusCode'
));
}
@ -90,22 +92,11 @@ class MediaViewTest extends CakeTestCase {
->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 @@ class MediaViewTest extends CakeTestCase {
$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 @@ class MediaViewTest extends CakeTestCase {
->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 @@ class MediaViewTest extends CakeTestCase {
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 @@ class MediaViewTest extends CakeTestCase {
);
$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 @@ class MediaViewTest extends CakeTestCase {
->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 @@ class MediaViewTest extends CakeTestCase {
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 @@ class MediaViewTest extends CakeTestCase {
);
$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 @@ class MediaViewTest extends CakeTestCase {
->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 @@ class MediaViewTest extends CakeTestCase {
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']);
}
/**