Skip to content

Commit 9512b33

Browse files
committed
Fix cURL HTTP client and its tests
1 parent d14a059 commit 9512b33

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/HttpClients/FacebookCurlHttpClient.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public function send($url, $method, $body, array $headers, $timeOut)
7070
$this->sendRequest();
7171

7272
if ($curlErrorCode = $this->facebookCurl->errno()) {
73+
$this->closeConnection();
74+
7375
throw new FacebookSDKException($this->facebookCurl->error(), $curlErrorCode);
7476
}
7577

tests/HttpClients/FacebookCurlHttpClientTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
*/
2424
namespace Facebook\Tests\HttpClients;
2525

26-
use Facebook\Exceptions\FacebookSDKException;
2726
use Facebook\HttpClients\FacebookCurlHttpClient;
2827
use Facebook\HttpClients\FacebookCurl;
2928
use Facebook\Http\GraphRawResponse;
@@ -183,7 +182,7 @@ public function testProperlyHandlesRedirectHeaders()
183182
public function testCanSendNormalRequest()
184183
{
185184
$this->curlMock->init()->shouldBeCalled();
186-
$this->curlMock->setoptArray()->shouldBeCalled();
185+
$this->curlMock->setoptArray(Argument::type('array'))->shouldBeCalled();
187186
$this->curlMock->exec()->willReturn($this->fakeRawHeader . $this->fakeRawBody);
188187
$this->curlMock->errno()->shouldBeCalled();
189188
$this->curlMock->close()->shouldBeCalled();
@@ -197,14 +196,14 @@ public function testCanSendNormalRequest()
197196
}
198197

199198
/**
200-
* @expectedException FacebookSDKException
199+
* @expectedException \Facebook\Exceptions\FacebookSDKException
201200
* @expectedExceptionCode 123
202-
* @expectedExceptionMessage "Foo error"
201+
* @expectedExceptionMessage Foo error
203202
*/
204203
public function testThrowsExceptionOnClientError()
205204
{
206205
$this->curlMock->init()->shouldBeCalled();
207-
$this->curlMock->setoptArray()->shouldBeCalled();
206+
$this->curlMock->setoptArray(Argument::type('array'))->shouldBeCalled();
208207
$this->curlMock->exec()->willReturn(false);
209208
$this->curlMock->errno()->willReturn(123);
210209
$this->curlMock->error()->willReturn('Foo error');

0 commit comments

Comments
 (0)