Skip to content

Commit

Permalink
Merge pull request #437 from nosnickid/master
Browse files Browse the repository at this point in the history
Bugfix for php 5.3
  • Loading branch information
elliotchance committed Dec 21, 2015
2 parents 734d6b2 + e124a6c commit 769fea1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/OAuth/OAuth1/Service/AbstractService.php
Expand Up @@ -216,7 +216,7 @@ protected function buildAuthorizationHeaderForAPIRequest(
$signatureParams = (is_array($bodyParams)) ? array_merge($authParameters, $bodyParams) : $authParameters;
$authParameters['oauth_signature'] = $this->signature->getSignature($uri, $signatureParams, $method);

if (isset($bodyParams['oauth_session_handle'])) {
if (is_array($bodyParams) && isset($bodyParams['oauth_session_handle'])) {
$authParameters['oauth_session_handle'] = $bodyParams['oauth_session_handle'];
unset($bodyParams['oauth_session_handle']);
}
Expand Down
27 changes: 27 additions & 0 deletions tests/Unit/OAuth1/Service/AbstractServiceTest.php
Expand Up @@ -212,4 +212,31 @@ public function testRequest()

$this->assertSame('response!', $service->request('/my/awesome/path'));
}

/**
* This test only captures a regression in php 5.3.
*
* @covers OAuth\OAuth1\Service\AbstractService::request
*/
public function testRequestNonArrayBody()
{
$client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
$client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('response!'));

$token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface');

$storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface');
$storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token));

$service = new Mock(
$this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
$client,
$storage,
$this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'),
$this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface')
);

$this->assertSame('response!', $service->request('/my/awesome/path', 'GET', 'A text body'));
}

}

0 comments on commit 769fea1

Please sign in to comment.