From f198ffdb9c41c4bb928d6a40e5ad64f5a972bfec Mon Sep 17 00:00:00 2001 From: Gareth Ellis Date: Mon, 29 Jul 2019 10:35:43 +0100 Subject: [PATCH 1/2] Moves creation of ControllerTestDispatcher to its own protected method --- lib/Cake/TestSuite/ControllerTestCase.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Cake/TestSuite/ControllerTestCase.php b/lib/Cake/TestSuite/ControllerTestCase.php index f891f35da..98611bf9b 100644 --- a/lib/Cake/TestSuite/ControllerTestCase.php +++ b/lib/Cake/TestSuite/ControllerTestCase.php @@ -265,7 +265,7 @@ abstract class ControllerTestCase extends CakeTestCase { ->will($this->returnValue($options['data'])); } - $Dispatch = new ControllerTestDispatcher(); + $Dispatch = $this->createDispatcher(); foreach (Router::$routes as $route) { if ($route instanceof RedirectRoute) { $route->response = $this->getMock('CakeResponse', array('send')); @@ -315,6 +315,15 @@ abstract class ControllerTestCase extends CakeTestCase { return $this->{$options['return']}; } +/** + * Creates the test dispatcher class + * + * @return Dispatcher + */ + protected function createDispatcher() { + return new ControllerTestDispatcher(); + } + /** * Generates a mocked controller and mocks any classes passed to `$mocks`. By * default, `_stop()` is stubbed as is sending the response headers, so to not From dba84d65d7af1d5f10f0fb2a8d738e766c2a7720 Mon Sep 17 00:00:00 2001 From: Gareth Ellis Date: Mon, 29 Jul 2019 15:27:45 +0100 Subject: [PATCH 2/2] Corrects style error from PHPCS by prefixing method name with an underscore --- lib/Cake/TestSuite/ControllerTestCase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/TestSuite/ControllerTestCase.php b/lib/Cake/TestSuite/ControllerTestCase.php index 98611bf9b..b13ce7df3 100644 --- a/lib/Cake/TestSuite/ControllerTestCase.php +++ b/lib/Cake/TestSuite/ControllerTestCase.php @@ -265,7 +265,7 @@ abstract class ControllerTestCase extends CakeTestCase { ->will($this->returnValue($options['data'])); } - $Dispatch = $this->createDispatcher(); + $Dispatch = $this->_createDispatcher(); foreach (Router::$routes as $route) { if ($route instanceof RedirectRoute) { $route->response = $this->getMock('CakeResponse', array('send')); @@ -320,7 +320,7 @@ abstract class ControllerTestCase extends CakeTestCase { * * @return Dispatcher */ - protected function createDispatcher() { + protected function _createDispatcher() { return new ControllerTestDispatcher(); }