Add content negociation provider

This commit is contained in:
Nicolas Le Goff
2014-06-03 11:16:20 +02:00
parent e17493aa0b
commit 45e53518ed
5 changed files with 49 additions and 78 deletions

View File

@@ -242,34 +242,6 @@ class API_V1_resultTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals($expected_value, $response->response->$field);
}
public function testGet_content_type()
{
$server = array("HTTP_ACCEPT" => "application/json");
$request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
$api_result = new API_V1_result(self::$DI['app'], $request, $this->api);
$this->assertEquals("application/json", $api_result->get_content_type());
$server = array("HTTP_ACCEPT" => "application/yaml");
$request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
$api_result = new API_V1_result(self::$DI['app'], $request, $this->api);
$this->assertEquals('application/yaml', $api_result->get_content_type());
$server = array("HTTP_ACCEPT" => "text/yaml");
$request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
$api_result = new API_V1_result(self::$DI['app'], $request, $this->api);
$this->assertEquals('application/yaml', $api_result->get_content_type());
$server = array("HTTP_ACCEPT" => "");
$request = new Request(array("callback" => "hello"), array(), array(), array(), array(), $server);
$api_result = new API_V1_result(self::$DI['app'], $request, $this->api);
$this->assertEquals('text/javascript', $api_result->get_content_type());
$server = array("HTTP_ACCEPT" => "unknow");
$request = new Request(array("callback" => ""), array(), array(), array(), array(), $server);
$api_result = new API_V1_result(self::$DI['app'], $request, $this->api);
$this->assertEquals("application/json", $api_result->get_content_type());
}
/**
* @depends testFormatJson
*/