public function testPrioritizesValuesBasedOnQParameter() { $header = AcceptLanguage::fromString('Accept-Language: da;q=0.8,en-gb,*;q=0.4'); $expected = array('en-gb', 'da', '*'); $test = array(); foreach ($header->getPrioritized() as $type) { $test[] = $type; } $this->assertEquals($expected, $test); }
public function testWildcards() { $accept = AcceptLanguage::fromString('*, en-*, en-us'); $res = $accept->getPrioritized(); $this->assertEquals('en-us', $res[0]->getLanguage()); $this->assertEquals('en', $res[0]->getPrimaryTag()); $this->assertEquals('us', $res[0]->getSubTag()); $this->assertEquals('en-*', $res[1]->getLanguage()); $this->assertEquals('en', $res[1]->getPrimaryTag()); $this->assertTrue($accept->hasLanguage('nl')); }
public function testAcceptLanguageFromStringCreatesValidAcceptLanguageHeader() { $acceptLanguageHeader = AcceptLanguage::fromString('Accept-Language: xxx'); $this->assertInstanceOf('Zend\\Http\\Header\\HeaderDescription', $acceptLanguageHeader); $this->assertInstanceOf('Zend\\Http\\Header\\AcceptLanguage', $acceptLanguageHeader); }