Permalink
Browse files

Add unit test for curl authenticated request

  • Loading branch information...
ornicar committed Feb 24, 2011
1 parent 984a26c commit 5913dbfd51213076d16887c28d1e9f05acc682bd
Showing with 18 additions and 0 deletions.
  1. +18 −0 test/Github/Tests/HttpClient/CurlTest.php
@@ -20,6 +20,24 @@ public function testDoRequest()
$this->assertEquals($curlResponse['response'], $responseText);
}
+ public function testDoAuthenticatedRequest()
+ {
+ $url = 'http://site.com/some/path';
+ $curlResponse = array('headers' => array('http_code' => 200), 'response' => 'hi there', 'errorNumber' => '', 'errorMessage' => '');
+ $options = array('format' => 'text', 'login' => 'mylogin', 'secret' => 'mysecret', 'auth_method' => Github_Client::AUTH_URL_TOKEN);
+
+ $httpClient = $this->getHttpClientCurlMockBuilder()
+ ->setMethods(array('doCurlCall'))
+ ->getMock();
+ $httpClient->expects($this->once())
+ ->method('doCurlCall')
+ ->will($this->returnValue($curlResponse));
+
+ $responseText = $httpClient->get($url, array(), $options);
+
+ $this->assertEquals($curlResponse['response'], $responseText);
+ }
+
public function testDoGetRequestWithParameters()
{
$url = 'http://site.com/some/path';

0 comments on commit 5913dbf

Please sign in to comment.