Esempio n. 1
0
 public function testFindAcceptableContentType()
 {
     $acceptType = array("text/html" => "Html", "application/json" => "Json", "text/xml" => "Xml");
     $_SERVER["HTTP_ACCEPT"] = "";
     $this->assertEquals("Html", $this->router->findAcceptableContentType($acceptType));
     $_SERVER["HTTP_ACCEPT"] = "text/html,*/*";
     $this->assertEquals("Html", $this->router->findAcceptableContentType($acceptType));
     $_SERVER["HTTP_ACCEPT"] = "text/xml";
     $this->assertEquals("Xml", $this->router->findAcceptableContentType($acceptType));
     $_SERVER["HTTP_ACCEPT"] = "text/xml;*/*";
     $this->assertEquals("Xml", $this->router->findAcceptableContentType($acceptType));
     $_SERVER["HTTP_ACCEPT"] = "application/json";
     $this->assertEquals("Json", $this->router->findAcceptableContentType($acceptType));
     $_SERVER["HTTP_ACCEPT"] = "application/json;*/*";
     $this->assertEquals("Json", $this->router->findAcceptableContentType($acceptType));
     foreach ($this->acceptHeaders as $acceptHeader) {
         $_SERVER["HTTP_ACCEPT"] = $acceptHeader;
         $this->assertEquals("Html", $this->router->findAcceptableContentType($acceptType), "Testng " . $acceptHeader);
     }
 }