/**
  * @expectedException \Facebook\Exceptions\FacebookSDKException
  */
 public function testThrowsExceptionOnClientError()
 {
     $this->curlMock->shouldReceive('init')->once()->andReturn(null);
     $this->curlMock->shouldReceive('setoptArray')->once()->andReturn(null);
     $this->curlMock->shouldReceive('exec')->once()->andReturn(false);
     $this->curlMock->shouldReceive('errno')->once()->andReturn(123);
     $this->curlMock->shouldReceive('error')->once()->andReturn('Foo error');
     $this->curlClient->send('http://foo.com/', 'GET', '', [], 60);
 }
 /**
  * @expectedException \Facebook\Exceptions\FacebookSDKException
  */
 public function testThrowsExceptionOnClientError()
 {
     $this->curlMock->shouldReceive('init')->once()->andReturn(null);
     $this->curlMock->shouldReceive('setopt_array')->once()->andReturn(null);
     $this->curlMock->shouldReceive('exec')->once()->andReturn(false);
     $this->curlMock->shouldReceive('errno')->once()->andReturn(123);
     $this->curlMock->shouldReceive('error')->once()->andReturn('Foo error');
     $this->curlMock->shouldReceive('getinfo')->with(CURLINFO_HTTP_CODE)->once()->andReturn(null);
     $this->curlClient->send('http://foo.com/');
 }
 public function testProperlyHandlesRedirectHeaders()
 {
     $rawHeader = $this->fakeRawRedirectHeader . $this->fakeRawHeader;
     $this->curlMock->shouldReceive('getinfo')->with(CURLINFO_HEADER_SIZE)->once()->andReturn(mb_strlen($rawHeader));
     $this->curlMock->shouldReceive('version')->once()->andReturn(array('version_number' => self::CURL_VERSION_STABLE));
     $this->curlMock->shouldReceive('exec')->once()->andReturn($rawHeader . $this->fakeRawBody);
     $this->curlClient->sendRequest();
     list($rawHeaders, $rawBody) = $this->curlClient->extractResponseHeadersAndBody();
     $this->assertEquals($rawHeaders, trim($rawHeader));
     $this->assertEquals($rawBody, $this->fakeRawBody);
     $headers = FacebookCurlHttpClient::headersToArray($rawHeaders);
     $this->assertEquals($headers, $this->fakeHeadersAsArray);
 }
Ejemplo n.º 4
0
 /**
  * @param string $key
  * @param string $value
  */
 public function addRequestHeader($key, $value)
 {
     if ($key !== 'User-Agent') {
         parent::addRequestHeader($key, $value);
     }
 }