Skip to content

Commit

Permalink
[LanguageNegotiator] More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
willdurand committed Jan 20, 2014
1 parent 208ad27 commit 786405c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Negotiation/LanguageNegotiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ protected function parseHeader($header)
*/
protected function match(array $acceptHeaders, array $priorities = array())
{
$wildcardAccept = null;

$prioritiesSet = array();
$prioritiesSet[] = $priorities;
$prioritiesSet[] = array_map(function ($priority) {
Expand Down
22 changes: 22 additions & 0 deletions tests/Negotiation/Tests/LanguageNegotiatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,28 @@ public function testGenericLanguageAreMappedToSpecific()
$this->assertEquals('en-US', $acceptHeader->getValue());
}

public function testGetBestWithWildcard()
{
$acceptLanguageHeader = 'en, *;q=0.9';
$priorities = array('fr');

$acceptHeader = $this->negotiator->getBest($acceptLanguageHeader, $priorities);

$this->assertInstanceOf('Negotiation\AcceptHeader', $acceptHeader);
$this->assertEquals('fr', $acceptHeader->getValue());
}

public function testGetBestDoesNotMatchPriorities()
{
$acceptLanguageHeader = 'en, de';
$priorities = array('fr');

$acceptHeader = $this->negotiator->getBest($acceptLanguageHeader, $priorities);

$this->assertInstanceOf('Negotiation\AcceptHeader', $acceptHeader);
$this->assertEquals('en', $acceptHeader->getValue());
}

public static function dataProviderForGetBest()
{
return array(
Expand Down

0 comments on commit 786405c

Please sign in to comment.