mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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:
commit
82d20ed948
6 changed files with 87 additions and 75 deletions
|
@ -66,8 +66,6 @@ class CakeErrorController extends AppController {
|
||||||
if ($this->Components->enabled('Security')) {
|
if ($this->Components->enabled('Security')) {
|
||||||
$this->Components->disable('Security');
|
$this->Components->disable('Security');
|
||||||
}
|
}
|
||||||
$this->startupProcess();
|
|
||||||
|
|
||||||
$this->_set(array('cacheAction' => false, 'viewPath' => 'Errors'));
|
$this->_set(array('cacheAction' => false, 'viewPath' => 'Errors'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,11 @@ class ExceptionRenderer {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$controller = new CakeErrorController($request, $response);
|
$controller = new CakeErrorController($request, $response);
|
||||||
|
$controller->startupProcess();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
if (!empty($controller) && $controller->Components->enabled('RequestHandler')) {
|
||||||
|
$controller->RequestHandler->startup($controller);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (empty($controller)) {
|
if (empty($controller)) {
|
||||||
$controller = new Controller($request, $response);
|
$controller = new Controller($request, $response);
|
||||||
|
|
|
@ -2281,7 +2281,8 @@ class DboSource extends DataSource {
|
||||||
$virtualFields,
|
$virtualFields,
|
||||||
$fields,
|
$fields,
|
||||||
$quote,
|
$quote,
|
||||||
ConnectionManager::getSourceName($this)
|
ConnectionManager::getSourceName($this),
|
||||||
|
$model->table
|
||||||
);
|
);
|
||||||
$cacheKey = md5(serialize($cacheKey));
|
$cacheKey = md5(serialize($cacheKey));
|
||||||
if ($return = $this->cacheMethod(__FUNCTION__, $cacheKey)) {
|
if ($return = $this->cacheMethod(__FUNCTION__, $cacheKey)) {
|
||||||
|
@ -2463,6 +2464,10 @@ class DboSource extends DataSource {
|
||||||
$not = 'NOT ';
|
$not = 'NOT ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($value)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (empty($value[1])) {
|
if (empty($value[1])) {
|
||||||
if ($not) {
|
if ($not) {
|
||||||
$out[] = $not . '(' . $value[0] . ')';
|
$out[] = $not . '(' . $value[0] . ')';
|
||||||
|
|
|
@ -159,6 +159,19 @@ class DboSourceTest extends CakeTestCase {
|
||||||
$this->assertEquals(' WHERE 1 = 1', $result);
|
$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
|
* test that order() will accept objects made from DboSource::expression
|
||||||
*
|
*
|
||||||
|
|
|
@ -5401,7 +5401,7 @@ class ModelReadTest extends BaseModelTest {
|
||||||
$Post->Tag->primaryKey = 'tag';
|
$Post->Tag->primaryKey = 'tag';
|
||||||
|
|
||||||
$result = $Post->find('all', array(
|
$result = $Post->find('all', array(
|
||||||
'order' => array('Post.id' => 'ASC')
|
'order' => 'Post.id ASC',
|
||||||
));
|
));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
array(
|
array(
|
||||||
|
@ -5617,7 +5617,9 @@ class ModelReadTest extends BaseModelTest {
|
||||||
$Project = new Project();
|
$Project = new Project();
|
||||||
$Project->recursive = 3;
|
$Project->recursive = 3;
|
||||||
|
|
||||||
$result = $Project->find('all');
|
$result = $Project->find('all', array(
|
||||||
|
'order' => 'Project.id ASC',
|
||||||
|
));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
array(
|
array(
|
||||||
'Project' => array(
|
'Project' => array(
|
||||||
|
@ -5731,7 +5733,9 @@ class ModelReadTest extends BaseModelTest {
|
||||||
$TestModel = new Home();
|
$TestModel = new Home();
|
||||||
$TestModel->recursive = 2;
|
$TestModel->recursive = 2;
|
||||||
|
|
||||||
$result = $TestModel->find('all');
|
$result = $TestModel->find('all', array(
|
||||||
|
'order' => 'Home.id ASC',
|
||||||
|
));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
array(
|
array(
|
||||||
'Home' => array(
|
'Home' => array(
|
||||||
|
@ -5844,7 +5848,9 @@ class ModelReadTest extends BaseModelTest {
|
||||||
$MyUser = new MyUser();
|
$MyUser = new MyUser();
|
||||||
$MyUser->recursive = 2;
|
$MyUser->recursive = 2;
|
||||||
|
|
||||||
$result = $MyUser->find('all');
|
$result = $MyUser->find('all', array(
|
||||||
|
'order' => 'MyUser.id ASC'
|
||||||
|
));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
array(
|
array(
|
||||||
'MyUser' => array('id' => '1', 'firstname' => 'userA'),
|
'MyUser' => array('id' => '1', 'firstname' => 'userA'),
|
||||||
|
@ -6035,7 +6041,7 @@ class ModelReadTest extends BaseModelTest {
|
||||||
$fullDebug = $this->db->fullDebug;
|
$fullDebug = $this->db->fullDebug;
|
||||||
$this->db->fullDebug = true;
|
$this->db->fullDebug = true;
|
||||||
$TestModel->recursive = 6;
|
$TestModel->recursive = 6;
|
||||||
$result = $TestModel->find('all', null, null, 'CategoryThread.id ASC');
|
$result = $TestModel->find('all');
|
||||||
$expected = array(
|
$expected = array(
|
||||||
array(
|
array(
|
||||||
'CategoryThread' => array(
|
'CategoryThread' => array(
|
||||||
|
|
|
@ -40,9 +40,11 @@ class MediaViewTest extends CakeTestCase {
|
||||||
'_isActive',
|
'_isActive',
|
||||||
'_clearBuffer',
|
'_clearBuffer',
|
||||||
'_flushBuffer',
|
'_flushBuffer',
|
||||||
|
'send',
|
||||||
|
'cache',
|
||||||
'type',
|
'type',
|
||||||
'header',
|
'download',
|
||||||
'download'
|
'statusCode'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,22 +92,11 @@ class MediaViewTest extends CakeTestCase {
|
||||||
->with('css')
|
->with('css')
|
||||||
->will($this->returnArgument(0));
|
->will($this->returnArgument(0));
|
||||||
|
|
||||||
$this->MediaView->response->expects($this->at(0))
|
$this->MediaView->response->expects($this->once())->method('send');
|
||||||
->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->exactly(1))
|
$this->MediaView->response->expects($this->exactly(1))
|
||||||
->method('_isActive')
|
->method('_isActive')
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
$this->MediaView->response->expects($this->once())->method('_clearBuffer');
|
||||||
$this->MediaView->response->expects($this->once())->method('_flushBuffer');
|
$this->MediaView->response->expects($this->once())->method('_flushBuffer');
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
@ -113,6 +104,16 @@ class MediaViewTest extends CakeTestCase {
|
||||||
$output = ob_get_clean();
|
$output = ob_get_clean();
|
||||||
$this->assertEquals("/* this is the test asset css file */\n", $output);
|
$this->assertEquals("/* this is the test asset css file */\n", $output);
|
||||||
$this->assertTrue($result !== false);
|
$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')
|
->with('ini')
|
||||||
->will($this->returnValue(false));
|
->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())
|
$this->MediaView->response->expects($this->once())
|
||||||
->method('download')
|
->method('download')
|
||||||
->with('no_section.ini');
|
->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->once())->method('_clearBuffer');
|
||||||
$this->MediaView->response->expects($this->exactly(1))
|
$this->MediaView->response->expects($this->exactly(1))
|
||||||
->method('_isActive')
|
->method('_isActive')
|
||||||
|
@ -169,6 +152,17 @@ class MediaViewTest extends CakeTestCase {
|
||||||
if ($currentUserAgent !== null) {
|
if ($currentUserAgent !== null) {
|
||||||
$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
|
$_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))
|
$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')
|
->method('type')
|
||||||
->with('ini')
|
->with('ini')
|
||||||
->will($this->returnValue(false));
|
->will($this->returnValue(false));
|
||||||
|
|
||||||
$this->MediaView->response->expects($this->at(2))
|
$this->MediaView->response->expects($this->at(1))
|
||||||
->method('type')
|
->method('type')
|
||||||
->with('application/octetstream')
|
->with('application/octetstream')
|
||||||
->will($this->returnValue(false));
|
->will($this->returnValue(false));
|
||||||
|
@ -206,14 +192,7 @@ class MediaViewTest extends CakeTestCase {
|
||||||
->method('download')
|
->method('download')
|
||||||
->with('no_section.ini');
|
->with('no_section.ini');
|
||||||
|
|
||||||
$this->MediaView->response->expects($this->at(4))
|
$this->MediaView->response->expects($this->once())->method('send');
|
||||||
->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('_clearBuffer');
|
$this->MediaView->response->expects($this->once())->method('_clearBuffer');
|
||||||
$this->MediaView->response->expects($this->exactly(1))
|
$this->MediaView->response->expects($this->exactly(1))
|
||||||
->method('_isActive')
|
->method('_isActive')
|
||||||
|
@ -228,6 +207,17 @@ class MediaViewTest extends CakeTestCase {
|
||||||
if ($currentUserAgent !== null) {
|
if ($currentUserAgent !== null) {
|
||||||
$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
|
$_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))
|
$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')
|
->method('type')
|
||||||
->with('ini')
|
->with('ini')
|
||||||
->will($this->returnValue(false));
|
->will($this->returnValue(false));
|
||||||
|
|
||||||
$this->MediaView->response->expects($this->at(2))
|
$this->MediaView->response->expects($this->at(1))
|
||||||
->method('type')
|
->method('type')
|
||||||
->with('application/force-download')
|
->with('application/force-download')
|
||||||
->will($this->returnValue(false));
|
->will($this->returnValue(false));
|
||||||
|
@ -266,14 +248,7 @@ class MediaViewTest extends CakeTestCase {
|
||||||
->method('download')
|
->method('download')
|
||||||
->with('config.ini');
|
->with('config.ini');
|
||||||
|
|
||||||
$this->MediaView->response->expects($this->at(4))
|
$this->MediaView->response->expects($this->once())->method('send');
|
||||||
->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('_clearBuffer');
|
$this->MediaView->response->expects($this->once())->method('_clearBuffer');
|
||||||
$this->MediaView->response->expects($this->exactly(1))
|
$this->MediaView->response->expects($this->exactly(1))
|
||||||
->method('_isActive')
|
->method('_isActive')
|
||||||
|
@ -288,6 +263,17 @@ class MediaViewTest extends CakeTestCase {
|
||||||
if ($currentUserAgent !== null) {
|
if ($currentUserAgent !== null) {
|
||||||
$_SERVER['HTTP_USER_AGENT'] = $currentUserAgent;
|
$_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']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue