From a45c80f740df4084342d9ed963680cb29ce164db Mon Sep 17 00:00:00 2001 From: blanchonvincent Date: Mon, 17 Feb 2014 19:27:34 +1100 Subject: [PATCH 1/3] Add fail test case --- .../Controller/AbstractControllerTestCaseTest.php | 6 ++++++ .../ZendTest/Test/_files/Baz/config/module.config.php | 10 ++++++++++ .../_files/Baz/src/Baz/Controller/IndexController.php | 9 +++++++++ 3 files changed, 25 insertions(+) diff --git a/tests/ZendTest/Test/PHPUnit/Controller/AbstractControllerTestCaseTest.php b/tests/ZendTest/Test/PHPUnit/Controller/AbstractControllerTestCaseTest.php index fdfc25f2b08..36f9d25a641 100644 --- a/tests/ZendTest/Test/PHPUnit/Controller/AbstractControllerTestCaseTest.php +++ b/tests/ZendTest/Test/PHPUnit/Controller/AbstractControllerTestCaseTest.php @@ -301,4 +301,10 @@ public function testExplicityPutParamsOverrideRequestContent() $this->dispatch('/tests', 'PUT', array('a' => 1)); $this->assertEquals('a=1', $this->getRequest()->getContent()); } + + public function testCustomResponseObject() + { + $this->dispatch('/custom-response'); + $this->assertResponseStatusCode(999); + } } diff --git a/tests/ZendTest/Test/_files/Baz/config/module.config.php b/tests/ZendTest/Test/_files/Baz/config/module.config.php index f83fdc4672c..1869f615143 100644 --- a/tests/ZendTest/Test/_files/Baz/config/module.config.php +++ b/tests/ZendTest/Test/_files/Baz/config/module.config.php @@ -81,6 +81,16 @@ ), ), ), + 'custom-response' => array( + 'type' => 'literal', + 'options' => array( + 'route' => '/custom-response', + 'defaults' => array( + 'controller' => 'baz_index', + 'action' => 'custom-response', + ), + ), + ), ), ), 'controllers' => array( diff --git a/tests/ZendTest/Test/_files/Baz/src/Baz/Controller/IndexController.php b/tests/ZendTest/Test/_files/Baz/src/Baz/Controller/IndexController.php index 696ebfbfcb8..bb1766c31e1 100644 --- a/tests/ZendTest/Test/_files/Baz/src/Baz/Controller/IndexController.php +++ b/tests/ZendTest/Test/_files/Baz/src/Baz/Controller/IndexController.php @@ -10,6 +10,7 @@ namespace Baz\Controller; use Zend\Mvc\Controller\AbstractActionController; +use Zend\Http\Response; class IndexController extends AbstractActionController { @@ -37,4 +38,12 @@ public function exceptionAction() { throw new \RuntimeException('Foo error !'); } + + public function customResponseAction() + { + $response = new Response(); + $response->setStatusCode(999); + + return $response; + } } From 55a795a0f793ac6e80ed80ce4702b9a32d5e650a Mon Sep 17 00:00:00 2001 From: blanchonvincent Date: Mon, 17 Feb 2014 19:28:09 +1100 Subject: [PATCH 2/3] Add fix --- .../Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php b/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php index 3673720d2d0..8fd550ce6ea 100644 --- a/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php +++ b/library/Zend/Test/PHPUnit/Controller/AbstractControllerTestCase.php @@ -181,7 +181,7 @@ public function getRequest() */ public function getResponse() { - return $this->getApplication()->getResponse(); + return $this->getApplication()->getMvcEvent()->getResponse(); } /** From 064726b4c2aa6272700a3aac439cab64be7bd758 Mon Sep 17 00:00:00 2001 From: blanchonvincent Date: Mon, 17 Feb 2014 19:29:26 +1100 Subject: [PATCH 3/3] Fix CS --- .../Test/PHPUnit/Controller/AbstractControllerTestCaseTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/ZendTest/Test/PHPUnit/Controller/AbstractControllerTestCaseTest.php b/tests/ZendTest/Test/PHPUnit/Controller/AbstractControllerTestCaseTest.php index 36f9d25a641..8c7c07f6c8a 100644 --- a/tests/ZendTest/Test/PHPUnit/Controller/AbstractControllerTestCaseTest.php +++ b/tests/ZendTest/Test/PHPUnit/Controller/AbstractControllerTestCaseTest.php @@ -34,6 +34,7 @@ public static function rmdir($dir) foreach ($files as $file) { (is_dir("$dir/$file")) ? static::rmdir("$dir/$file") : unlink("$dir/$file"); } + return rmdir($dir); } @@ -301,7 +302,7 @@ public function testExplicityPutParamsOverrideRequestContent() $this->dispatch('/tests', 'PUT', array('a' => 1)); $this->assertEquals('a=1', $this->getRequest()->getContent()); } - + public function testCustomResponseObject() { $this->dispatch('/custom-response');