mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-05-27 18:03:33 +00:00
Merge branch 'master' into 2.3
This commit is contained in:
commit
59e948fb1b
9 changed files with 76 additions and 44 deletions
lib/Cake/Test/Case/Error
|
@ -691,25 +691,49 @@ class ExceptionRendererTest extends CakeTestCase {
|
|||
$exception = new MissingHelperException(array('class' => 'Fail'));
|
||||
$ExceptionRenderer = new ExceptionRenderer($exception);
|
||||
|
||||
$ExceptionRenderer->controller = $this->getMock('Controller');
|
||||
$ExceptionRenderer->controller = $this->getMock('Controller', array('render'));
|
||||
$ExceptionRenderer->controller->helpers = array('Fail', 'Boom');
|
||||
$ExceptionRenderer->controller->request = $this->getMock('CakeRequest');
|
||||
$ExceptionRenderer->controller->expects($this->at(2))
|
||||
$ExceptionRenderer->controller->expects($this->at(0))
|
||||
->method('render')
|
||||
->with('missingHelper')
|
||||
->will($this->throwException($exception));
|
||||
|
||||
$ExceptionRenderer->controller->expects($this->at(4))
|
||||
->method('render')
|
||||
->with('error500')
|
||||
->will($this->returnValue(true));
|
||||
$response = $this->getMock('CakeResponse');
|
||||
$response->expects($this->once())
|
||||
->method('body')
|
||||
->with($this->stringContains('Helper class Fail'));
|
||||
|
||||
$ExceptionRenderer->controller->response = $this->getMock('CakeResponse');
|
||||
$ExceptionRenderer->controller->response = $response;
|
||||
$ExceptionRenderer->render();
|
||||
sort($ExceptionRenderer->controller->helpers);
|
||||
$this->assertEquals(array('Form', 'Html', 'Session'), $ExceptionRenderer->controller->helpers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that exceptions in beforeRender() are handled by outputMessageSafe
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRenderExceptionInBeforeRender() {
|
||||
$exception = new NotFoundException('Not there, sorry');
|
||||
$ExceptionRenderer = new ExceptionRenderer($exception);
|
||||
|
||||
$ExceptionRenderer->controller = $this->getMock('Controller', array('beforeRender'));
|
||||
$ExceptionRenderer->controller->request = $this->getMock('CakeRequest');
|
||||
$ExceptionRenderer->controller->expects($this->any())
|
||||
->method('beforeRender')
|
||||
->will($this->throwException($exception));
|
||||
|
||||
$response = $this->getMock('CakeResponse');
|
||||
$response->expects($this->once())
|
||||
->method('body')
|
||||
->with($this->stringContains('Not there, sorry'));
|
||||
|
||||
$ExceptionRenderer->controller->response = $response;
|
||||
$ExceptionRenderer->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that missing subDir/layoutPath don't cause other fatal errors.
|
||||
*
|
||||
|
@ -719,32 +743,31 @@ class ExceptionRendererTest extends CakeTestCase {
|
|||
$exception = new NotFoundException();
|
||||
$ExceptionRenderer = new ExceptionRenderer($exception);
|
||||
|
||||
$ExceptionRenderer->controller = $this->getMock('Controller');
|
||||
$ExceptionRenderer->controller = $this->getMock('Controller', array('render'));
|
||||
$ExceptionRenderer->controller->helpers = array('Fail', 'Boom');
|
||||
$ExceptionRenderer->controller->layoutPath = 'json';
|
||||
$ExceptionRenderer->controller->subDir = 'json';
|
||||
$ExceptionRenderer->controller->viewClass = 'Json';
|
||||
$ExceptionRenderer->controller->request = $this->getMock('CakeRequest');
|
||||
|
||||
$ExceptionRenderer->controller->expects($this->at(1))
|
||||
$ExceptionRenderer->controller->expects($this->once())
|
||||
->method('render')
|
||||
->with('error400')
|
||||
->will($this->throwException($exception));
|
||||
|
||||
$ExceptionRenderer->controller->expects($this->at(3))
|
||||
->method('render')
|
||||
->with('error500')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$ExceptionRenderer->controller->response = $this->getMock('CakeResponse');
|
||||
$ExceptionRenderer->controller->response->expects($this->once())
|
||||
$response = $this->getMock('CakeResponse');
|
||||
$response->expects($this->once())
|
||||
->method('body')
|
||||
->with($this->stringContains('Not Found'));
|
||||
$response->expects($this->once())
|
||||
->method('type')
|
||||
->with('html');
|
||||
|
||||
$ExceptionRenderer->controller->response = $response;
|
||||
|
||||
$ExceptionRenderer->render();
|
||||
$this->assertEquals('', $ExceptionRenderer->controller->layoutPath);
|
||||
$this->assertEquals('', $ExceptionRenderer->controller->subDir);
|
||||
$this->assertEquals('View', $ExceptionRenderer->controller->viewClass);
|
||||
$this->assertEquals('Errors/', $ExceptionRenderer->controller->viewPath);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue