willdurand/Negotiation

getBest returns a value when no acceptable headers match any of the priorities

iby opened this issue · 0 comments

iby commented

I'm about to make a pull request for a small bug while discovered the following and want to clarify first. Currently there's only one place where this is found in LanguageNegotiatorTest:

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());
}

Basically what happens is: the client says I will accept only en or de, but the only thing we can offer is fr. The rational action is to return null as we can't satisfy the request, but we return en instead (which we can't provide). I am assuming the way this works is wrong?