Browse Source

Remove use of deprecated controller properties from exceptionrenderer

ADmad 10 years ago
parent
commit
073c8d08f9

+ 1 - 2
src/Error/ExceptionRenderer.php

@@ -331,12 +331,11 @@ class ExceptionRenderer
     protected function _outputMessageSafe($template)
     {
         $this->controller->layoutPath = null;
-        $this->controller->subDir = null;
         $this->controller->viewPath = 'Error';
-        $this->controller->layout = 'error';
         $this->controller->helpers = ['Form', 'Html'];
 
         $view = $this->controller->createView();
+        $view->layout = 'error';
         $this->controller->response->body($view->render($template, 'error'));
         $this->controller->response->type('html');
         return $this->controller->response;

+ 2 - 4
tests/TestCase/Error/ExceptionRendererTest.php

@@ -694,11 +694,11 @@ class ExceptionRendererTest extends TestCase
     }
 
     /**
-     * Test that missing subDir/layoutPath don't cause other fatal errors.
+     * Test that missing layoutPath don't cause other fatal errors.
      *
      * @return void
      */
-    public function testMissingSubdirRenderSafe()
+    public function testMissingLayoutPathRenderSafe()
     {
         $exception = new NotFoundException();
         $ExceptionRenderer = new ExceptionRenderer($exception);
@@ -706,7 +706,6 @@ class ExceptionRendererTest extends TestCase
         $ExceptionRenderer->controller = $this->getMock('Cake\Controller\Controller', ['render']);
         $ExceptionRenderer->controller->helpers = ['Fail', 'Boom'];
         $ExceptionRenderer->controller->layoutPath = 'boom';
-        $ExceptionRenderer->controller->subDir = 'boom';
         $ExceptionRenderer->controller->request = new Request;
 
         $ExceptionRenderer->controller->expects($this->once())
@@ -726,7 +725,6 @@ class ExceptionRendererTest extends TestCase
 
         $ExceptionRenderer->render();
         $this->assertEquals('', $ExceptionRenderer->controller->layoutPath);
-        $this->assertEquals('', $ExceptionRenderer->controller->subDir);
         $this->assertEquals('Error', $ExceptionRenderer->controller->viewPath);
     }
 

+ 1 - 1
tests/test_app/TestApp/Error/TestAppsExceptionRenderer.php

@@ -24,7 +24,7 @@ class TestAppsExceptionRenderer extends ExceptionRenderer
         $response = new Response();
         try {
             $controller = new TestAppsErrorController($request, $response);
-            $controller->layout = 'banana';
+            $controller->getView()->layout = 'banana';
         } catch (\Exception $e) {
             $controller = new Controller($request, $response);
             $controller->viewPath = 'Error';