From 491064f40b45b3ad78310dfe6e3aa90f3145e20f Mon Sep 17 00:00:00 2001 From: thibaultCha Date: Thu, 5 Feb 2015 21:09:01 -0800 Subject: [PATCH] Add test for setMashapeKey --- tests/Unirest/RequestTest.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/Unirest/RequestTest.php b/tests/Unirest/RequestTest.php index 44d1024..ffb36b2 100644 --- a/tests/Unirest/RequestTest.php +++ b/tests/Unirest/RequestTest.php @@ -64,6 +64,32 @@ class UnirestRequestTest extends \PHPUnit_Framework_TestCase $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() { $response = Unirest\Request::get('http://httpbin.org/gzip');