Skip to content

Commit 769fea1

Browse files
committed
Merge pull request #437 from nosnickid/master
Bugfix for php 5.3
2 parents 734d6b2 + e124a6c commit 769fea1

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

src/OAuth/OAuth1/Service/AbstractService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ protected function buildAuthorizationHeaderForAPIRequest(
216216
$signatureParams = (is_array($bodyParams)) ? array_merge($authParameters, $bodyParams) : $authParameters;
217217
$authParameters['oauth_signature'] = $this->signature->getSignature($uri, $signatureParams, $method);
218218

219-
if (isset($bodyParams['oauth_session_handle'])) {
219+
if (is_array($bodyParams) && isset($bodyParams['oauth_session_handle'])) {
220220
$authParameters['oauth_session_handle'] = $bodyParams['oauth_session_handle'];
221221
unset($bodyParams['oauth_session_handle']);
222222
}

tests/Unit/OAuth1/Service/AbstractServiceTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,31 @@ public function testRequest()
212212

213213
$this->assertSame('response!', $service->request('/my/awesome/path'));
214214
}
215+
216+
/**
217+
* This test only captures a regression in php 5.3.
218+
*
219+
* @covers OAuth\OAuth1\Service\AbstractService::request
220+
*/
221+
public function testRequestNonArrayBody()
222+
{
223+
$client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
224+
$client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('response!'));
225+
226+
$token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface');
227+
228+
$storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface');
229+
$storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token));
230+
231+
$service = new Mock(
232+
$this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
233+
$client,
234+
$storage,
235+
$this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'),
236+
$this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface')
237+
);
238+
239+
$this->assertSame('response!', $service->request('/my/awesome/path', 'GET', 'A text body'));
240+
}
241+
215242
}

0 commit comments

Comments
 (0)