Skip to content

Commit

Permalink
Fix failing tests in ViewBuilder.
Browse files Browse the repository at this point in the history
Can't use assertSame() as response is immutable.
  • Loading branch information
markstory committed Nov 16, 2017
1 parent 94b395c commit 2fa8735
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Error/ExceptionRenderer.php
Expand Up @@ -200,8 +200,8 @@ public function render()
if ($unwrapped instanceof CakeException && $isDebug) {
$this->controller->set($unwrapped->getAttributes());
}

$this->controller->response = $response;

return $this->_outputMessage($template);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Routing/Filter/AssetFilter.php
Expand Up @@ -131,7 +131,7 @@ protected function _getAssetFile($url)
protected function _deliverAsset(ServerRequest $request, Response $response, $assetFile, $ext)
{
$compressionEnabled = $response->compress();
if ($response->getType($ext) === $ext) {
if ($response->getType() === $ext) {
$contentType = 'application/octet-stream';
$agent = $request->getEnv('HTTP_USER_AGENT');
if (preg_match('%Opera(/| )([0-9].[0-9]{1,2})%', $agent) || preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent)) {
Expand Down
8 changes: 5 additions & 3 deletions tests/TestCase/View/ViewBuilderTest.php
Expand Up @@ -14,6 +14,8 @@
*/
namespace Cake\Test\TestCase\View;

use Cake\Http\Response;
use Cake\Http\ServerRequest;
use Cake\TestSuite\TestCase;
use Cake\View\ViewBuilder;

Expand Down Expand Up @@ -108,8 +110,8 @@ public function testArrayPropertyMerge($property, $value)
*/
public function testBuildComplete()
{
$request = $this->getMockBuilder('Cake\Http\ServerRequest')->getMock();
$response = $this->getMockBuilder('Cake\Http\Response')->getMock();
$request = new ServerRequest();
$response = new Response();
$events = $this->getMockBuilder('Cake\Event\EventManager')->getMock();

$builder = new ViewBuilder();
Expand All @@ -136,7 +138,7 @@ public function testBuildComplete()
$this->assertEquals('TestPlugin', $view->plugin);
$this->assertEquals('TestTheme', $view->theme);
$this->assertSame($request, $view->request);
$this->assertSame($response, $view->response);
$this->assertInstanceOf(Response::class, $view->response);
$this->assertSame($events, $view->getEventManager());
$this->assertSame(['one' => 'value'], $view->viewVars);
$this->assertInstanceOf('Cake\View\Helper\HtmlHelper', $view->Html);
Expand Down

0 comments on commit 2fa8735

Please sign in to comment.