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

Commit

Permalink
Update Zend\View to latest Zend\Http changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jurian Sluiman committed Jun 30, 2012
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/Helper/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class Json extends AbstractHelper

/**
* Set the response object
*
* @param Response $response
*
* @param Response $response
* @return Json
*/
public function setResponse(Response $response)
Expand All @@ -63,7 +63,7 @@ public function __invoke($data, array $jsonOptions = array())
$data = JsonFormatter::encode($data, null, $jsonOptions);

if ($this->response instanceof Response) {
$headers = $this->response->headers();
$headers = $this->response->getHeaders();
$headers->addHeaderLine('Content-Type', 'application/json');
}

Expand Down
4 changes: 2 additions & 2 deletions src/Strategy/FeedStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function selectRenderer(ViewEvent $e)
return;
}

$headers = $request->headers();
$headers = $request->getHeaders();
if ($headers->has('accept')) {
$accept = $headers->get('accept');
foreach ($accept->getPrioritized() as $mediaType) {
Expand Down Expand Up @@ -165,7 +165,7 @@ public function injectResponse(ViewEvent $e)
// Populate response
$response = $e->getResponse();
$response->setContent($result);
$headers = $response->headers();
$headers = $response->getHeaders();
$headers->addHeaderLine('content-type', $feedType);
}
}
6 changes: 3 additions & 3 deletions src/Strategy/JsonStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function selectRenderer(ViewEvent $e)
return;
}

$headers = $request->headers();
$headers = $request->getHeaders();
if ($headers->has('accept')) {
$accept = $headers->get('Accept');
foreach ($accept->getPrioritized() as $mediaType) {
Expand All @@ -119,7 +119,7 @@ public function selectRenderer(ViewEvent $e)
}
if (0 === strpos($mediaType, 'application/javascript')) {
// application/javascript Accept header found
if (false != ($callback = $request->query()->get('callback'))) {
if (false != ($callback = $request->getQuery()->get('callback'))) {
$this->renderer->setJsonpCallback($callback);
}
return $this->renderer;
Expand Down Expand Up @@ -154,7 +154,7 @@ public function injectResponse(ViewEvent $e)
// Populate response
$response = $e->getResponse();
$response->setContent($result);
$headers = $response->headers();
$headers = $response->getHeaders();
if ($this->renderer->hasJsonpCallback()) {
$headers->addHeaderLine('content-type', 'application/javascript');
} else {
Expand Down
2 changes: 1 addition & 1 deletion test/Helper/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function setUp()

public function verifyJsonHeader()
{
$headers = $this->response->headers();
$headers = $this->response->getHeaders();
$this->assertTrue($headers->has('Content-Type'));
$header = $headers->get('Content-Type');
$this->assertEquals('application/json', $header->getFieldValue());
Expand Down
12 changes: 6 additions & 6 deletions test/Strategy/FeedStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testFeedModelSelectsFeedStrategy()
public function testRssAcceptHeaderSelectsFeedStrategy()
{
$request = new HttpRequest();
$request->headers()->addHeaderLine('Accept', 'application/rss+xml');
$request->getHeaders()->addHeaderLine('Accept', 'application/rss+xml');
$this->event->setRequest($request);
$result = $this->strategy->selectRenderer($this->event);
$this->assertSame($this->renderer, $result);
Expand All @@ -69,7 +69,7 @@ public function testRssAcceptHeaderSelectsFeedStrategy()
public function testAtomAcceptHeaderSelectsFeedStrategy()
{
$request = new HttpRequest();
$request->headers()->addHeaderLine('Accept', 'application/atom+xml');
$request->getHeaders()->addHeaderLine('Accept', 'application/atom+xml');
$this->event->setRequest($request);
$result = $this->strategy->selectRenderer($this->event);
$this->assertSame($this->renderer, $result);
Expand All @@ -85,7 +85,7 @@ public function testLackOfFeedModelOrAcceptHeaderDoesNotSelectFeedStrategy()
protected function assertResponseNotInjected()
{
$content = $this->response->getContent();
$headers = $this->response->headers();
$headers = $this->response->getHeaders();
$this->assertTrue(empty($content));
$this->assertFalse($headers->has('content-type'));
}
Expand Down Expand Up @@ -125,7 +125,7 @@ public function testMatchingRendererAndStringResultInjectsResponse()

$this->strategy->injectResponse($this->event);
$content = $this->response->getContent();
$headers = $this->response->headers();
$headers = $this->response->getHeaders();
$this->assertEquals($expected, $content);
$this->assertTrue($headers->has('content-type'));
$this->assertEquals('application/atom+xml', $headers->get('content-type')->getFieldValue());
Expand Down Expand Up @@ -182,7 +182,7 @@ public function testMatchingRendererAndFeedResultInjectsResponse()

$this->strategy->injectResponse($this->event);
$content = $this->response->getContent();
$headers = $this->response->headers();
$headers = $this->response->getHeaders();
$this->assertEquals($expected->export('atom'), $content);
$this->assertTrue($headers->has('content-type'));
$this->assertEquals('application/atom+xml', $headers->get('content-type')->getFieldValue());
Expand All @@ -198,7 +198,7 @@ public function testResponseContentTypeIsBasedOnFeedType()

$this->strategy->injectResponse($this->event);
$content = $this->response->getContent();
$headers = $this->response->headers();
$headers = $this->response->getHeaders();
$this->assertEquals($expected->export('rss'), $content);
$this->assertTrue($headers->has('content-type'));
$this->assertEquals('application/rss+xml', $headers->get('content-type')->getFieldValue());
Expand Down
12 changes: 6 additions & 6 deletions test/Strategy/JsonStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testJsonModelSelectsJsonStrategy()
public function testJsonAcceptHeaderSelectsJsonStrategy()
{
$request = new HttpRequest();
$request->headers()->addHeaderLine('Accept', 'application/json');
$request->getHeaders()->addHeaderLine('Accept', 'application/json');
$this->event->setRequest($request);
$result = $this->strategy->selectRenderer($this->event);
$this->assertSame($this->renderer, $result);
Expand All @@ -69,7 +69,7 @@ public function testJsonAcceptHeaderSelectsJsonStrategy()
public function testJavascriptAcceptHeaderSelectsJsonStrategy()
{
$request = new HttpRequest();
$request->headers()->addHeaderLine('Accept', 'application/javascript');
$request->getHeaders()->addHeaderLine('Accept', 'application/javascript');
$this->event->setRequest($request);
$result = $this->strategy->selectRenderer($this->event);
$this->assertSame($this->renderer, $result);
Expand All @@ -79,7 +79,7 @@ public function testJavascriptAcceptHeaderSelectsJsonStrategy()
public function testJavascriptAcceptHeaderSelectsJsonStrategyAndSetsJsonpCallback()
{
$request = new HttpRequest();
$request->headers()->addHeaderLine('Accept', 'application/javascript');
$request->getHeaders()->addHeaderLine('Accept', 'application/javascript');
$request->setQuery(new Parameters(array('callback' => 'foo')));
$this->event->setRequest($request);
$result = $this->strategy->selectRenderer($this->event);
Expand All @@ -97,7 +97,7 @@ public function testLackOfJsonModelOrAcceptHeaderDoesNotSelectJsonStrategy()
protected function assertResponseNotInjected()
{
$content = $this->response->getContent();
$headers = $this->response->headers();
$headers = $this->response->getHeaders();
$this->assertTrue(empty($content));
$this->assertFalse($headers->has('content-type'));
}
Expand Down Expand Up @@ -136,7 +136,7 @@ public function testMatchingRendererAndStringResultInjectsResponse()

$this->strategy->injectResponse($this->event);
$content = $this->response->getContent();
$headers = $this->response->headers();
$headers = $this->response->getHeaders();
$this->assertEquals($expected, $content);
$this->assertTrue($headers->has('content-type'));
$this->assertEquals('application/json', $headers->get('content-type')->getFieldValue());
Expand All @@ -152,7 +152,7 @@ public function testMatchingRendererAndStringResultInjectsResponseJsonp()

$this->strategy->injectResponse($this->event);
$content = $this->response->getContent();
$headers = $this->response->headers();
$headers = $this->response->getHeaders();
$this->assertEquals($expected, $content);
$this->assertTrue($headers->has('content-type'));
$this->assertEquals('application/javascript', $headers->get('content-type')->getFieldValue());
Expand Down
6 changes: 3 additions & 3 deletions test/Strategy/PhpRendererStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function testSelectRendererAlwaysSelectsPhpRenderer()
protected function assertResponseNotInjected()
{
$content = $this->response->getContent();
$headers = $this->response->headers();
$headers = $this->response->getHeaders();
$this->assertTrue(empty($content));
$this->assertFalse($headers->has('content-type'));
}
Expand All @@ -79,7 +79,7 @@ public function testNonMatchingRendererDoesNotInjectResponse()
$this->strategy->injectResponse($this->event);
$this->assertResponseNotInjected();
}

public function testResponseContentSetToContentPlaceholderWhenResultAndArticlePlaceholderAreEmpty()
{
$this->renderer->placeholder('content')->set('Content');
Expand Down Expand Up @@ -152,7 +152,7 @@ public function testAttachesListenersAtExpectedPriorities()
$this->assertTrue($found, 'Listener not found');
}
}

public function testCanAttachListenersAtSpecifiedPriority()
{
$events = new EventManager();
Expand Down

0 comments on commit de83270

Please sign in to comment.