Add test for setMashapeKey

This commit is contained in:
thibaultCha
2015-02-05 21:09:01 -08:00
parent fb241f6898
commit 491064f40b

View File

@@ -64,6 +64,32 @@ class UnirestRequestTest extends \PHPUnit_Framework_TestCase
$this->assertFalse(array_key_exists('Hello', $properties)); $this->assertFalse(array_key_exists('Hello', $properties));
} }
public function testSetMashapeKey()
{
Unirest\Request::setMashapeKey('abcd');
$response = Unirest\Request::get('http://httpbin.org/get');
$this->assertEquals(200, $response->code);
$headers = $response->body->headers;
$properties = get_object_vars($headers);
$this->assertTrue(array_key_exists('X-Mashape-Key', $properties));
$this->assertEquals('abcd', $headers->{'X-Mashape-Key'});
$response = Unirest\Request::get('http://httpbin.org/get');
$this->assertEquals(200, $response->code);
$headers = $response->body->headers;
$properties = get_object_vars($headers);
$this->assertTrue(array_key_exists('X-Mashape-Key', $properties));
$this->assertEquals('abcd', $headers->{'X-Mashape-Key'});
Unirest\Request::clearDefaultHeaders();
$response = Unirest\Request::get('http://httpbin.org/get');
$this->assertEquals(200, $response->code);
$headers = $response->body->headers;
$properties = get_object_vars($headers);
$this->assertFalse(array_key_exists('X-Mashape-Key', $properties));
}
public function testGzip() public function testGzip()
{ {
$response = Unirest\Request::get('http://httpbin.org/gzip'); $response = Unirest\Request::get('http://httpbin.org/gzip');