diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..90af7ec --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: php +install: + - pear install -fa package.xml +php: + - 5.4 +script: phpunit tests/ \ No newline at end of file diff --git a/HTTP/OAuth.php b/HTTP/OAuth.php index 2b48681..23b8612 100644 --- a/HTTP/OAuth.php +++ b/HTTP/OAuth.php @@ -142,15 +142,18 @@ static public function buildHttpQuery(array $params) return ''; } - $keys = self::urlencode(array_keys($params)); - $values = self::urlencode(array_values($params)); - $params = array_combine($keys, $values); - - uksort($params, 'strcmp'); + ksort($params, SORT_STRING); $pairs = array(); foreach ($params as $key => $value) { - $pairs[] = $key . '=' . $value; + if (is_array($value)) { + sort($value, SORT_STRING); + foreach ($value as $multiValue) { + $pairs[] = self::urlencode($key) . '=' . self::urlencode($multiValue); + } + } else { + $pairs[] = self::urlencode($key) . '=' . self::urlencode($value); + } } return implode('&', $pairs); diff --git a/HTTP/OAuth/Consumer/Request.php b/HTTP/OAuth/Consumer/Request.php index c29f677..afadae6 100644 --- a/HTTP/OAuth/Consumer/Request.php +++ b/HTTP/OAuth/Consumer/Request.php @@ -217,10 +217,11 @@ public function send() $headers = $request->getHeaders(); $contentType = isset($headers['content-type']) ? $headers['content-type'] : ''; - if ($this->getMethod() == 'POST' - && $contentType == 'application/x-www-form-urlencoded' - ) { + // RFC 5849 3.4.1.3.1 allows any HTTP method with the correct + // content-type and body content. Don't check method type here. + // See PEAR Bug 17806. + if ($contentType == 'application/x-www-form-urlencoded') { $body = $this->getHTTPRequest2()->getBody(); $body = str_replace('+', '%20', $body); $this->getHTTPRequest2()->setBody($body); @@ -229,7 +230,12 @@ public function send() try { $response = $this->getHTTPRequest2()->send(); } catch (Exception $e) { - throw new HTTP_OAuth_Exception($e->getMessage(), $e->getCode()); + if (version_compare(PHP_VERSION, '5.3.0', 'ge')) { + // Use exception chaining if available. See PEAR Bug #18574. + throw new HTTP_OAuth_Exception($e->getMessage(), $e->getCode(), $e); + } else { + throw new HTTP_OAuth_Exception($e->getMessage(), $e->getCode()); + } } return new HTTP_OAuth_Consumer_Response($response); @@ -280,6 +286,8 @@ protected function buildRequest() switch ($this->getMethod()) { case 'POST': + case 'PUT': + case 'DELETE': foreach ($this->getParameters() as $name => $value) { if (substr($name, 0, 6) == 'oauth_') { continue; @@ -289,6 +297,7 @@ protected function buildRequest() } break; case 'GET': + case 'HEAD': $url = $this->getUrl(); foreach ($this->getParameters() as $name => $value) { if (substr($name, 0, 6) == 'oauth_') { diff --git a/HTTP/OAuth/Message.php b/HTTP/OAuth/Message.php index 4ea3a10..39ba7be 100644 --- a/HTTP/OAuth/Message.php +++ b/HTTP/OAuth/Message.php @@ -97,8 +97,7 @@ public function getOAuthParameters() public function getParameters() { $params = $this->parameters; - ksort($params); - + ksort($params, SORT_STRING); return $params; } diff --git a/HTTP/OAuth/Provider/Request.php b/HTTP/OAuth/Provider/Request.php index 984d4bc..b4b0e84 100644 --- a/HTTP/OAuth/Provider/Request.php +++ b/HTTP/OAuth/Provider/Request.php @@ -55,17 +55,53 @@ class HTTP_OAuth_Provider_Request extends HTTP_OAuth_Message */ protected $method = ''; + /** + * Body data from the incoming request + * + * @var string raw body data from the incoming request + */ + protected $body = ''; + /** * Construct * + * @param string $body optional. The HTTP request body. Use this if your + * framework automatically reads the php://input + * stream. + * * @return void */ - public function __construct() + public function __construct($body = '') { $this->setHeaders(); + $this->setBody($body); $this->setParametersFromRequest(); } + /** + * Sets the body data for this request + * + * This is useful if your framework automatically reads the php://input + * stream and your API puts parameters in the request body. + * + * @param string $body the HTTP request body. + * + * @return HTTP_OAuth_Provider_Request the current object, for fluent + * interface. + */ + public function setBody($body = '') + { + if (empty($body)) { + // @codeCoverageIgnoreStart + $this->body = file_get_contents('php://input'); + // @codeCoverageIgnoreEnd + } else { + $this->body = (string)$body; + } + + return $this; + } + /** * Set incoming request headers * @@ -83,7 +119,7 @@ public function setHeaders(array $headers = array()) } else if (is_array($this->peclHttpHeaders())) { $this->debug('Using pecl_http to get request headers'); $this->headers = $this->peclHttpHeaders(); - } else { + } else { $this->debug('Using $_SERVER to get request headers'); foreach ($_SERVER as $name => $value) { if (substr($name, 0, 5) == 'HTTP_') { @@ -149,34 +185,39 @@ public function setParametersFromRequest() $auth = $this->getHeader('Authorization'); if ($auth !== null) { $this->debug('Using OAuth data from header'); + + // strip leading OAuth authentication scheme + $auth = preg_replace('/^oauth /i', '', $auth); + + // split auth parameters $parts = explode(',', $auth); foreach ($parts as $part) { - list($key, $value) = explode('=', trim($part)); - if (strstr(strtolower($key), 'oauth ') - || strstr(strtolower($key), 'uth re') - || substr(strtolower($key), 0, 6) != 'oauth_' - ) { + list($key, $value) = explode('=', $part, 2); + + // strip spaces from around comma and equals delimiters + $key = trim($key); + $value = trim($value); + + // ignore auth parameters that are not prefixed with oauth_ + if (substr(strtolower($key), 0, 6) != 'oauth_') { continue; } - $value = trim($value); $value = str_replace('"', '', $value); - $params[$key] = $value; + $params[HTTP_OAuth::urldecode($key)] = HTTP_OAuth::urldecode($value); } } - if ($this->getRequestMethod() == 'POST') { - $this->debug('getting data from POST'); - $contentType = substr($this->getHeader('Content-Type'), 0, 33); - if ($contentType !== 'application/x-www-form-urlencoded') { - throw new HTTP_OAuth_Provider_Exception_InvalidRequest('Invalid ' . - 'content type for POST request'); - } - + // RFC 5849 3.4.1.3.1 allows any HTTP method with the correct + // content-type and body content. Don't check method type here. + // See PEAR Bug 17806. + $contentType = $this->getHeader('Content-Type'); + if (strncmp($contentType, 'application/x-www-form-urlencoded', 33) === 0) { + $this->debug('getting application/x-www-form-urlencoded data from request body'); $params = array_merge( $params, - $this->parseQueryString($this->getPostData()) + $this->parseQueryString($this->getBody()) ); } @@ -190,7 +231,7 @@ public function setParametersFromRequest() 'data found from request'); } - $this->setParameters(HTTP_OAuth::urldecode($params)); + $this->setParameters($params); } /** @@ -321,22 +362,22 @@ public function getHeaders() return $this->headers; } - // @codeCoverageIgnoreStart /** - * Gets POST data + * Gets request body * - * @return string Post data + * @return string request data */ - protected function getPostData() + public function getBody() { - return file_get_contents('php://input'); + return $this->body; } - // @codeCoverageIgnoreEnd /** * Parses a query string * - * Does not urldecode the name or values like $_GET and $_POST + * Does not use built-in urldecoding of name or values like $_GET and + * $_POST. Instead, names and values are decoded using RFC 3986 as required + * by OAuth. * * @param string $string Query string * @@ -355,7 +396,22 @@ protected function parseQueryString($string) } list($key, $value) = explode('=', $part); - $data[$key] = self::urldecode($value); + + $key = HTTP_OAuth::urldecode($key); + $value = HTTP_OAuth::urldecode($value); + + if (isset($data[$key])) { + if (is_array($data[$key])) { + $data[$key][] = $value; + } else { + $data[$key] = array( + $data[$key], + $value + ); + } + } else { + $data[$key] = $value; + } } return $data; diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d91e43e --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ +Copyright (c) 2009 Jeff Hodsdon, 2009 Bill Shupp, 2013 silverorange Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README b/README.md similarity index 91% rename from README rename to README.md index fa79d48..41b39ca 100644 --- a/README +++ b/README.md @@ -1,15 +1,18 @@ +# HTTP_OAuth - Implementation of the OAuth specification + HTTP_OAuth is a PEAR package implementing the OAuth 1.0a protocol. Consumer, Provier (request and response) classes are provided. See the Consumer examples below: -HTTP_OAuth_Consumer +## HTTP_OAuth_Consumer Main consumer class that assists consumers in establishing OAuth creditials and making OAuth requests. -Example: +### Example: +```php $consumer = new HTTP_OAuth_Consumer('key', 'secret'); $consumer->getRequestToken('http://example.com/oauth/request_token', $callback); @@ -31,3 +34,4 @@ $_SESSION['token_secret'] = $consumer->getTokenSecret(); // $response is an instance of HTTP_OAuth_Consumer_Response $response = $consumer->sendRequest('http://example.com/oauth/protected_resource'); +``` diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..9ffc9b7 --- /dev/null +++ b/composer.json @@ -0,0 +1,42 @@ +{ + "name": "pear/http_oauth", + "description": "Implementation of the OAuth 1.0a specification.", + "type": "library", + "keywords": [ "http", "oauth" ], + "homepage": "https://github.com/pear/HTTP_OAuth", + "license": "BSD-2-Clause", + "authors": [ + { + "name": "Michael Gauthier", + "email": "mike@silverorange.com" + }, + { + "name": "Jeff Hodsdon", + "email": "jeffhodsdon@gmail.com" + }, + { + "name": "Bill Shupp", + "email": "shupp@php.net" + } + ], + "require": { + "php": ">=5.1.2", + "ext-date": "*", + "ext-hash": "*", + "ext-spl": "*", + "pear/pear-core-minimal": "^1.9.0", + "pear/http_request2": "^2.0.0" + }, + "suggest": { + "pear/log": "Allows logging requests for debugging", + "pear/cache_lite": "Caching of requests." + }, + "autoload": { + "psr-0": { + "HTTP_OAuth": "" + } + }, + "include-path": [ + "./" + ] +} diff --git a/generatePackage.php b/generatePackage.php index 9954f83..fcf31f7 100644 --- a/generatePackage.php +++ b/generatePackage.php @@ -13,13 +13,17 @@ 'simpleoutput' => true, 'packagedirectory' => './', 'filelistgenerator' => 'file', + 'exceptions' => array( + 'LICENSE' => 'doc', + 'README' => 'doc', + ), 'ignore' => array( 'runTests.php', 'generatePackage.php', 'phpunit-bootstrap.php', 'phpunit.xml', - 'README', - 'coverage*' + 'coverage*', + '*.tgz', ), 'dir_roles' => array( 'tests' => 'test', @@ -32,15 +36,30 @@ $packagexml->setDescription('Allows the use of the consumer and provider angles of the OAuth 1.0a specification'); $packagexml->setChannel('pear.php.net'); -$packagexml->setAPIVersion('0.2.0'); -$packagexml->setReleaseVersion('0.2.3'); +$packagexml->setAPIVersion('0.3.0'); +$packagexml->setReleaseVersion('0.3.1'); $packagexml->setReleaseStability('alpha'); $packagexml->setAPIStability('alpha'); -$packagexml->setNotes('* Fixed GH issue #10. don\'t use reset() to get the first array value -* Disabled E_DEPRECTED error logging when creating packages +$packagexml->setNotes('API changes: + * added $body parameter to HTTP_OAuth_Provider::__construct() + * added HTTP_OAuth_Provider::setBody() + * renamed HTTP_OAuth_Provider::getPostData() to getBody() + * made HTTP_OAuth_Provider::getBody() public + +New features and bugs fixed: + * Fixed PEAR #17806. DELETE method is not supported. + * Fixed PEAR #18574. Avoid try-catch-rethrow. + * Fixed PEAR #18701. Only variables should be passed by reference. + * Fixed PEAR #18425. Array keys not decoded in HTTP_OAuth_Provider. + * Fixed PEAR #18431. Handle PUT requests better in HTTP_OAuth_Provider. + * Fixed PEAR #20106. rawBodyData always included in provider request. + * Fixed PEAR #20107. Handle multiple query params with same name as array. + * Added LICENSE file. + * Include README in package file. + * Fixed reset() call in MessageTest in unit tests. '); $packagexml->setPackageType('php'); $packagexml->addRelease(); @@ -55,6 +74,10 @@ 'shupp', 'Bill Shupp', 'shupp@php.net'); +$packagexml->addMaintainer('developer', + 'gauthierm', + 'Michael Gauthier', + 'mike@silverorange.com'); $packagexml->setLicense('New BSD License', 'http://www.opensource.org/licenses/bsd-license.php'); diff --git a/package.xml b/package.xml index 6d6f1ac..13d1688 100644 --- a/package.xml +++ b/package.xml @@ -1,5 +1,5 @@ - @@ -19,11 +19,17 @@ shupp@php.net yes - 2011-07-16 - + + Michael Gauthier + gauthierm + mike@silverorange.com + yes + + 2013-11-01 + - 0.2.3 - 0.2.0 + 0.3.0 + 0.3.0 alpha @@ -31,8 +37,20 @@ New BSD License -* Fixed GH issue #10. don't use reset() to get the first array value -* Disabled E_DEPRECTED error logging when creating packages +API changes: + * added $body parameter to HTTP_OAuth_Provider::__construct() + * added HTTP_OAuth_Provider::setBody() + * renamed HTTP_OAuth_Provider::getPostData() to getBody() + * made HTTP_OAuth_Provider::getBody() public + +New features and bugs fixed: + * Fixed PEAR #17806. DELETE method is not supported. + * Fixed PEAR #18574. Avoid try-catch-rethrow. + * Fixed PEAR #18701. Only variables should be passed by reference. + * Fixed PEAR #18425. Array keys not decoded in HTTP_OAuth_Provider. + * Fixed PEAR #18431. Handle PUT requests better in HTTP_OAuth_Provider. + * Fixed PEAR #20106. rawBodyData always included in provider request. + * Fixed PEAR #20107. Handle multiple query params with same name as array. @@ -141,6 +159,7 @@ + @@ -544,5 +563,33 @@ Updated digg example * Disabled E_DEPRECTED error logging when creating packages + + + 0.3.0 + 0.3.0 + + + alpha + alpha + + 2013-11-01 + New BSD License + +API changes: + * added $body parameter to HTTP_OAuth_Provider::__construct() + * added HTTP_OAuth_Provider::setBody() + * renamed HTTP_OAuth_Provider::getPostData() to getBody() + * made HTTP_OAuth_Provider::getBody() public + +New features and bugs fixed: + * Fixed PEAR #17806. DELETE method is not supported. + * Fixed PEAR #18574. Avoid try-catch-rethrow. + * Fixed PEAR #18701. Only variables should be passed by reference. + * Fixed PEAR #18425. Array keys not decoded in HTTP_OAuth_Provider. + * Fixed PEAR #18431. Handle PUT requests better in HTTP_OAuth_Provider. + * Fixed PEAR #20106. rawBodyData always included in provider request. + * Fixed PEAR #20107. Handle multiple query params with same name as array. + + diff --git a/tests/HTTP/OAuth/Consumer/Exception/InvalidResponseTest.php b/tests/HTTP/OAuth/Consumer/Exception/InvalidResponseTest.php index 7dad71a..5f7c49b 100644 --- a/tests/HTTP/OAuth/Consumer/Exception/InvalidResponseTest.php +++ b/tests/HTTP/OAuth/Consumer/Exception/InvalidResponseTest.php @@ -21,7 +21,6 @@ * @link http://github.com/jeffhodsdon/HTTP_OAuth_Provider */ -require_once 'PHPUnit/Framework/TestCase.php'; require_once 'HTTP/OAuth/Consumer/Exception/InvalidResponse.php'; class HTTP_OAuth_Consumer_Exception_InvalidResponseTest diff --git a/tests/HTTP/OAuth/Consumer/RequestTest.php b/tests/HTTP/OAuth/Consumer/RequestTest.php index 050a194..876b4d6 100644 --- a/tests/HTTP/OAuth/Consumer/RequestTest.php +++ b/tests/HTTP/OAuth/Consumer/RequestTest.php @@ -21,7 +21,6 @@ * @link http://github.com/jeffhodsdon/HTTP_OAuth_Provider */ -require_once 'PHPUnit/Framework/TestCase.php'; require_once 'HTTP/OAuth/Consumer/Request.php'; require_once 'HTTP/Request2.php'; require_once 'HTTP/Request2/Adapter/Mock.php'; diff --git a/tests/HTTP/OAuth/Consumer/ResponseTest.php b/tests/HTTP/OAuth/Consumer/ResponseTest.php index 7611aef..d35c42b 100644 --- a/tests/HTTP/OAuth/Consumer/ResponseTest.php +++ b/tests/HTTP/OAuth/Consumer/ResponseTest.php @@ -21,7 +21,6 @@ * @link http://github.com/jeffhodsdon/HTTP_OAuth_Provider */ -require_once 'PHPUnit/Framework/TestCase.php'; require_once 'HTTP/OAuth/Consumer/Response.php'; class HTTP_OAuth_Consumer_ResponseTest extends PHPUnit_Framework_TestCase diff --git a/tests/HTTP/OAuth/ConsumerTest.php b/tests/HTTP/OAuth/ConsumerTest.php index 852b689..1f4cb60 100644 --- a/tests/HTTP/OAuth/ConsumerTest.php +++ b/tests/HTTP/OAuth/ConsumerTest.php @@ -21,7 +21,6 @@ * @link http://github.com/jeffhodsdon/HTTP_OAuth_Provider */ -require_once 'PHPUnit/Framework/TestCase.php'; require_once 'HTTP/OAuth/Consumer.php'; require_once 'HTTP/OAuth/Consumer/Request.php'; diff --git a/tests/HTTP/OAuth/MessageTest.php b/tests/HTTP/OAuth/MessageTest.php index d602ddb..771583c 100644 --- a/tests/HTTP/OAuth/MessageTest.php +++ b/tests/HTTP/OAuth/MessageTest.php @@ -21,7 +21,6 @@ * @link http://github.com/jeffhodsdon/HTTP_OAuth_Provider */ -require_once 'PHPUnit/Framework/TestCase.php'; require_once 'tests/HTTP/OAuth/MessageMock.php'; class HTTP_OAuth_MessageTest extends PHPUnit_Framework_TestCase @@ -65,7 +64,8 @@ public function testGetParametersIsSorted() $params = array('z' => 'foo', 'a' => 'bar'); $m = new HTTP_OAuth_MessageMock; $m->setParameters($params); - $this->assertEquals('bar', reset($m->getParameters())); + $params = $m->getParameters(); + $this->assertEquals('bar', reset($params)); } public function testMagicGetter() diff --git a/tests/HTTP/OAuth/Provider/RequestTest.php b/tests/HTTP/OAuth/Provider/RequestTest.php index 9f11540..1245c97 100644 --- a/tests/HTTP/OAuth/Provider/RequestTest.php +++ b/tests/HTTP/OAuth/Provider/RequestTest.php @@ -19,7 +19,6 @@ * @link http://github.com/jeffhodsdon/HTTP_OAuth_Provider */ -require_once 'PHPUnit/Framework/TestCase.php'; require_once 'HTTP/OAuth.php'; require_once 'HTTP/OAuth/Provider/Request.php'; @@ -57,10 +56,11 @@ class HTTP_OAuth_Provider_RequestTest extends PHPUnit_Framework_TestCase 'foo' => 'bar bar', 'oauth_consumer_key' => 'key', 'oauth_signature_method' => 'HMAC-SHA1', - 'oauth_signature' => 'jMenbpx3MWa8qyxgQr4olVrXTBU=', + 'oauth_signature' => 'UOXlPAfN0jLuph8vZaseA5hi59Y=', 'oauth_timestamp' => '1251317781', 'oauth_nonce' => '2E0A8559-8660-45F9-832F-6AC466615C79', - 'oauth_version' => '1.0' + 'oauth_version' => '1.0', + 'arrayparam[]' => array('1', '2'), ); /** @@ -108,10 +108,18 @@ public function testSetHeaders() $this->assertArrayHasKey('foo', $request->getHeaders()); } + public function testSetBody() + { + $body = 'test1=foo&test2=bar'; + $request = $this->mockedRequest(); + $request->setBody($body); + $this->assertEquals($body, $request->getBody()); + } + public function testSetParametersFromRequest() { $header = 'Authorization: OAuth realm="", oauth_consumer_key="key", oauth_signature_method="HMAC-SHA1", oauth_signature="ZUgC96UBRxYOl1Pml32hNDsNNUc%3D", oauth_timestamp="1251304744", oauth_nonce="18B2129F-4A4E-4502-8EB5-801DE2BB0247", oauth_version="1.0"'; - $queryString = 'foo=bar%20bar&oauth_consumer_key=key&oauth_signature_method=HMAC-SHA1&oauth_signature=ZUgC96UBRxYOl1Pml32hNDsNNUc%3D&oauth_timestamp=1251304744&oauth_nonce=18B2129F-4A4E-4502-8EB5-801DE2BB0247&oauth_version=1.0¶mwithnovalue'; + $queryString = 'foo=bar%20bar&oauth_consumer_key=key&oauth_signature_method=HMAC-SHA1&oauth_signature=ZUgC96UBRxYOl1Pml32hNDsNNUc%3D&oauth_timestamp=1251304744&oauth_nonce=18B2129F-4A4E-4502-8EB5-801DE2BB0247&oauth_version=1.0¶mwithnovalue&arrayparam%5B%5D=1&arrayparam%5B%5D=2'; $expected = array( 'foo' => 'bar bar', 'oauth_consumer_key' => 'key', @@ -120,6 +128,7 @@ public function testSetParametersFromRequest() 'oauth_signature_method' => 'HMAC-SHA1', 'oauth_timestamp' => '1251304744', 'oauth_version' => '1.0', + 'arrayparam[]' => array('1', '2'), ); $request = $this->mockedRequest(); @@ -128,13 +137,18 @@ public function testSetParametersFromRequest() $this->assertEquals($expected, $request->getParameters()); $this->assertEquals(array('Authorization' => $header), $request->getHeaders()); - $request = $this->mockedRequest(array('getRequestMethod')); + $request = $this->mockedRequest(array('getRequestMethod', 'getBody')); + $request->expects($this->any())->method('getRequestMethod') ->will($this->returnValue('POST')); - $request->expects($this->any())->method('getPostData') + + $request->expects($this->any())->method('getBody') ->will($this->returnValue($queryString)); + $request->setHeaders( - array('Content-Type' => 'application/x-www-form-urlencoded')); + array('Content-Type' => 'application/x-www-form-urlencoded') + ); + $request->setParametersFromRequest(); $this->assertEquals($expected, $request->getParameters()); @@ -245,8 +259,12 @@ public function testSetHeadersWithServer() protected function mockedRequest(array $methods = array()) { - $methods = array_unique(array_merge($methods, - array('getPostData', 'apacheRequestHeaders', 'peclHttpHeaders'))); + $methods = array_unique( + array_merge( + $methods, + array('apacheRequestHeaders', 'peclHttpHeaders') + ) + ); $_SERVER['HTTP_AUTHORIZATION'] = 'OAuth realm="", oauth_consumer_key="key", oauth_signature_method="HMAC-SHA1", oauth_signature="ZUgC96UBRxYOl1Pml32hNDsNNUc%3D", oauth_timestamp="1251304744", oauth_nonce="18B2129F-4A4E-4502-8EB5-801DE2BB0247", oauth_version="1.0"'; $request = $this->getMock('HTTP_OAuth_Provider_Request', $methods); diff --git a/tests/HTTP/OAuth/Provider/ResponseTest.php b/tests/HTTP/OAuth/Provider/ResponseTest.php index 267f392..0d5471f 100644 --- a/tests/HTTP/OAuth/Provider/ResponseTest.php +++ b/tests/HTTP/OAuth/Provider/ResponseTest.php @@ -1,6 +1,5 @@