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/2660'
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Strategy/JsonStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public function selectRenderer(ViewEvent $e)
}
return $this->renderer;
}

return ($model instanceof Model\JsonModel) ? $this->renderer : null;
}

/**
Expand Down
10 changes: 10 additions & 0 deletions test/Strategy/JsonStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ public function testJavascriptAcceptHeaderSelectsJsonStrategy()
$this->assertFalse($result->hasJsonpCallback());
}

public function testJsonModelMatchedAcceptHeaderMatchSelectsJsonStrategy()
{
$this->event->setModel(new JsonModel());
$request = new HttpRequest();
$request->getHeaders()->addHeaderLine('Accept', '*/*');
$this->event->setRequest($request);
$result = $this->strategy->selectRenderer($this->event);
$this->assertSame($this->renderer, $result);
}

public function testJsonModelJavascriptAcceptHeaderSetsJsonpCallback()
{
$this->event->setModel(new JsonModel());
Expand Down

0 comments on commit a29bbbc

Please sign in to comment.