Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/112'
Browse files Browse the repository at this point in the history
close #112
  • Loading branch information
weierophinney committed Mar 20, 2017
2 parents df72b10 + 5bd9b2f commit e94e1eb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ All notable changes to this project will be documented in this file, in reverse
- [#104](https://github.com/zendframework/zend-view/pull/104) fixes the
`@method` annotation for the `Placeholder` view helper to use the correct case,
fixing issues with method completion in IDEs.
- [#112](https://github.com/zendframework/zend-view/pull/112) fixes an issue in
the `PhpRendererStrategy` whereby absence of a response instance in the
`ViewEvent` would lead to a fatal error.

## 2.8.1 - 2016-06-30

Expand Down
4 changes: 2 additions & 2 deletions src/Strategy/PhpRendererStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ public function selectRenderer(ViewEvent $e)
public function injectResponse(ViewEvent $e)
{
$renderer = $e->getRenderer();
if ($renderer !== $this->renderer) {
$response = $e->getResponse();
if ($renderer !== $this->renderer || $response === null) {
return;
}

$result = $e->getResult();
$response = $e->getResponse();

// Set content
// If content is empty, check common placeholders to determine if they are
Expand Down
3 changes: 2 additions & 1 deletion test/Helper/HeadMetaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ public function testCharsetPosition()
$this->assertEquals(
'<meta charset="utf-8">' . PHP_EOL
. '<meta property="description" content="foobar">',
$view->plugin('headMeta')->toString());
$view->plugin('headMeta')->toString()
);
}

/**
Expand Down
13 changes: 13 additions & 0 deletions test/Strategy/PhpRendererStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class PhpRendererStrategyTest extends TestCase
{
use EventListenerIntrospectionTrait;

/** @var PhpRendererStrategy */
private $strategy;

public function setUp()
{
$this->renderer = new PhpRenderer;
Expand Down Expand Up @@ -168,4 +171,14 @@ public function testDetachesListeners()
$listeners = iterator_to_array($this->getListenersForEvent('response', $events));
$this->assertCount(0, $listeners);
}

public function testInjectResponseWorksWithAnEventWithNoResponse()
{
$e = new ViewEvent();
$e->setRenderer($this->strategy->getRenderer());

$this->strategy->injectResponse($e);

$this->assertNull($e->getResponse());
}
}

0 comments on commit e94e1eb

Please sign in to comment.