Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function getRequest()
*/
public function getResponse()
{
return $this->getApplication()->getResponse();
return $this->getApplication()->getMvcEvent()->getResponse();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -301,4 +302,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);
}
}
10 changes: 10 additions & 0 deletions tests/ZendTest/Test/_files/Baz/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@
),
),
),
'custom-response' => array(
'type' => 'literal',
'options' => array(
'route' => '/custom-response',
'defaults' => array(
'controller' => 'baz_index',
'action' => 'custom-response',
),
),
),
),
),
'controllers' => array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Baz\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\Http\Response;

class IndexController extends AbstractActionController
{
Expand Down Expand Up @@ -37,4 +38,12 @@ public function exceptionAction()
{
throw new \RuntimeException('Foo error !');
}

public function customResponseAction()
{
$response = new Response();
$response->setStatusCode(999);

return $response;
}
}