Ejemplo n.º 1
0
 protected function callFunction($controller, $functionName, $parameters)
 {
     // Catch all exceptions rather than letting them hit the top level exception handler.
     try {
         parent::callFunction($controller, $functionName, $parameters);
     } catch (Exception $e) {
         $this->view->displayError(500, $e);
         exit(500);
     }
 }
Ejemplo n.º 2
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);
     }
 }