|
|
@@ -195,7 +195,9 @@ class ExceptionRendererTest extends TestCase
|
|
|
*/
|
|
|
protected function _mockResponse($error)
|
|
|
{
|
|
|
- $error->controller->response = $this->getMock('Cake\Network\Response', ['_sendHeader']);
|
|
|
+ $error->controller->response = $this->getMockBuilder('Cake\Network\Response')
|
|
|
+ ->setMethods(['_sendHeader'])
|
|
|
+ ->getMock();
|
|
|
return $error;
|
|
|
}
|
|
|
|
|
|
@@ -316,7 +318,9 @@ class ExceptionRendererTest extends TestCase
|
|
|
{
|
|
|
$exception = new MissingWidgetThingException('coding fail.');
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
- $ExceptionRenderer->controller->response = $this->getMock('Cake\Network\Response', ['statusCode', '_sendHeader']);
|
|
|
+ $ExceptionRenderer->controller->response = $this->getMockBuilder('Cake\Network\Response')
|
|
|
+ ->setMethods(['statusCode', '_sendHeader'])
|
|
|
+ ->getMock();
|
|
|
$ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with(404);
|
|
|
|
|
|
$result = $ExceptionRenderer->render();
|
|
|
@@ -334,7 +338,9 @@ class ExceptionRendererTest extends TestCase
|
|
|
{
|
|
|
$exception = new \OutOfBoundsException('foul ball.');
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
- $ExceptionRenderer->controller->response = $this->getMock('Cake\Network\Response', ['statusCode', '_sendHeader']);
|
|
|
+ $ExceptionRenderer->controller->response = $this->getMockBuilder('Cake\Network\Response')
|
|
|
+ ->setMethods(['statusCode', '_sendHeader'])
|
|
|
+ ->getMock();
|
|
|
$ExceptionRenderer->controller->response->expects($this->once())
|
|
|
->method('statusCode')
|
|
|
->with(500);
|
|
|
@@ -355,7 +361,9 @@ class ExceptionRendererTest extends TestCase
|
|
|
|
|
|
$exception = new \OutOfBoundsException('foul ball.');
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
- $ExceptionRenderer->controller->response = $this->getMock('Cake\Network\Response', ['statusCode', '_sendHeader']);
|
|
|
+ $ExceptionRenderer->controller->response = $this->getMockBuilder('Cake\Network\Response')
|
|
|
+ ->setMethods(['statusCode', '_sendHeader'])
|
|
|
+ ->getMock();
|
|
|
$ExceptionRenderer->controller->response->expects($this->once())
|
|
|
->method('statusCode')
|
|
|
->with(500);
|
|
|
@@ -375,7 +383,9 @@ class ExceptionRendererTest extends TestCase
|
|
|
{
|
|
|
$exception = new \OutOfBoundsException('foul ball.', 501);
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
- $ExceptionRenderer->controller->response = $this->getMock('Cake\Network\Response', ['statusCode', '_sendHeader']);
|
|
|
+ $ExceptionRenderer->controller->response = $this->getMockBuilder('Cake\Network\Response')
|
|
|
+ ->setMethods(['statusCode', '_sendHeader'])
|
|
|
+ ->getMock();
|
|
|
$ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with(501);
|
|
|
|
|
|
$result = $ExceptionRenderer->render();
|
|
|
@@ -397,7 +407,9 @@ class ExceptionRendererTest extends TestCase
|
|
|
|
|
|
$exception = new NotFoundException('Custom message');
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
- $ExceptionRenderer->controller->response = $this->getMock('Cake\Network\Response', ['statusCode', '_sendHeader']);
|
|
|
+ $ExceptionRenderer->controller->response = $this->getMockBuilder('Cake\Network\Response')
|
|
|
+ ->setMethods(['statusCode', '_sendHeader'])
|
|
|
+ ->getMock();
|
|
|
$ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with(404);
|
|
|
|
|
|
$result = $ExceptionRenderer->render()->body();
|
|
|
@@ -458,7 +470,9 @@ class ExceptionRendererTest extends TestCase
|
|
|
{
|
|
|
$exception = new InternalErrorException('An Internal Error Has Occurred.');
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
- $ExceptionRenderer->controller->response = $this->getMock('Cake\Network\Response', ['statusCode', '_sendHeader']);
|
|
|
+ $ExceptionRenderer->controller->response = $this->getMockBuilder('Cake\Network\Response')
|
|
|
+ ->setMethods(['statusCode', '_sendHeader'])
|
|
|
+ ->getMock();
|
|
|
$ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with(500);
|
|
|
|
|
|
$result = $ExceptionRenderer->render();
|
|
|
@@ -628,7 +642,9 @@ class ExceptionRendererTest extends TestCase
|
|
|
public function testCakeExceptionHandling($exception, $patterns, $code)
|
|
|
{
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
- $ExceptionRenderer->controller->response = $this->getMock('Cake\Network\Response', ['statusCode', '_sendHeader']);
|
|
|
+ $ExceptionRenderer->controller->response = $this->getMockBuilder('Cake\Network\Response')
|
|
|
+ ->setMethods(['statusCode', '_sendHeader'])
|
|
|
+ ->getMock();
|
|
|
$ExceptionRenderer->controller->response->expects($this->once())
|
|
|
->method('statusCode')
|
|
|
->with($code);
|
|
|
@@ -663,7 +679,9 @@ class ExceptionRendererTest extends TestCase
|
|
|
$exception = new MissingHelperException(['class' => 'Fail']);
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
|
|
|
- $ExceptionRenderer->controller = $this->getMock('Cake\Controller\Controller', ['render']);
|
|
|
+ $ExceptionRenderer->controller = $this->getMockBuilder('Cake\Controller\Controller')
|
|
|
+ ->setMethods(['render'])
|
|
|
+ ->getMock();
|
|
|
$ExceptionRenderer->controller->helpers = ['Fail', 'Boom'];
|
|
|
$ExceptionRenderer->controller->request = new Request;
|
|
|
$ExceptionRenderer->controller->expects($this->at(0))
|
|
|
@@ -692,7 +710,9 @@ class ExceptionRendererTest extends TestCase
|
|
|
$exception = new NotFoundException('Not there, sorry');
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
|
|
|
- $ExceptionRenderer->controller = $this->getMock('Cake\Controller\Controller', ['beforeRender']);
|
|
|
+ $ExceptionRenderer->controller = $this->getMockBuilder('Cake\Controller\Controller')
|
|
|
+ ->setMethods(['beforeRender'])
|
|
|
+ ->getMock();
|
|
|
$ExceptionRenderer->controller->request = new Request;
|
|
|
$ExceptionRenderer->controller->expects($this->any())
|
|
|
->method('beforeRender')
|
|
|
@@ -717,7 +737,9 @@ class ExceptionRendererTest extends TestCase
|
|
|
$exception = new NotFoundException();
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
|
|
|
- $ExceptionRenderer->controller = $this->getMock('Cake\Controller\Controller', ['render']);
|
|
|
+ $ExceptionRenderer->controller = $this->getMockBuilder('Cake\Controller\Controller')
|
|
|
+ ->setMethods(['render'])
|
|
|
+ ->getMock();
|
|
|
$ExceptionRenderer->controller->helpers = ['Fail', 'Boom'];
|
|
|
$ExceptionRenderer->controller->eventManager()->on('Controller.beforeRender', function (Event $event) {
|
|
|
$event->subject()->viewBuilder()->layoutPath('boom');
|
|
|
@@ -754,7 +776,9 @@ class ExceptionRendererTest extends TestCase
|
|
|
$exception = new NotFoundException();
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
|
|
|
- $ExceptionRenderer->controller = $this->getMock('Cake\Controller\Controller', ['render']);
|
|
|
+ $ExceptionRenderer->controller = $this->getMockBuilder('Cake\Controller\Controller')
|
|
|
+ ->setMethods(['render'])
|
|
|
+ ->getMock();
|
|
|
$ExceptionRenderer->controller->plugin = 'TestPlugin';
|
|
|
$ExceptionRenderer->controller->request = $this->getMockBuilder('Cake\Network\Request')->getMock();
|
|
|
|
|
|
@@ -787,7 +811,9 @@ class ExceptionRendererTest extends TestCase
|
|
|
$exception = new NotFoundException();
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
|
|
|
- $ExceptionRenderer->controller = $this->getMock('Cake\Controller\Controller', ['render']);
|
|
|
+ $ExceptionRenderer->controller = $this->getMockBuilder('Cake\Controller\Controller')
|
|
|
+ ->setMethods(['render'])
|
|
|
+ ->getMock();
|
|
|
$ExceptionRenderer->controller->plugin = 'TestPlugin';
|
|
|
$ExceptionRenderer->controller->request = $this->getMockBuilder('Cake\Network\Request')->getMock();
|
|
|
|
|
|
@@ -886,7 +912,9 @@ class ExceptionRendererTest extends TestCase
|
|
|
$exception->queryString = 'SELECT * from poo_query < 5 and :seven';
|
|
|
$exception->params = ['seven' => 7];
|
|
|
$ExceptionRenderer = new ExceptionRenderer($exception);
|
|
|
- $ExceptionRenderer->controller->response = $this->getMock('Cake\Network\Response', ['statusCode', '_sendHeader']);
|
|
|
+ $ExceptionRenderer->controller->response = $this->getMockBuilder('Cake\Network\Response')
|
|
|
+ ->setMethods(['statusCode', '_sendHeader'])
|
|
|
+ ->getMock();
|
|
|
$ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with(500);
|
|
|
|
|
|
$result = $ExceptionRenderer->render()->body();
|