diff --git a/test/Eher/OAuth/ConsumerTest.php b/test/Eher/OAuth/ConsumerTest.php new file mode 100644 index 0000000..3ce742c --- /dev/null +++ b/test/Eher/OAuth/ConsumerTest.php @@ -0,0 +1,18 @@ +assertEquals( + 'Consumer[key=ConsumerKey,secret=ConsumerSecret]', + (string) $consumer + ); + } +} diff --git a/test/Eher/OAuth/RequestTest.php b/test/Eher/OAuth/RequestTest.php index f3c6847..4551695 100644 --- a/test/Eher/OAuth/RequestTest.php +++ b/test/Eher/OAuth/RequestTest.php @@ -4,7 +4,37 @@ namespace Eher\OAuth; class RequestTest extends \PHPUnit_Framework_TestCase { - public function testRequest() + public function testRequestToUrl() { + $consumer = null; + $signatureMethod = null; + $request = null; + $once = ""; + $timestamp = ""; + $signature = ""; + $expectedUrl = ""; + + $consumer = new Consumer('ConsumerKey', 'ConsumerSecret'); + $signatureMethod = new HmacSha1(); + $request = Request::from_consumer_and_token( + $consumer, + null, + "GET", + "http://www.endpoint.url/", + array() + ); + $request->sign_request($signatureMethod, $consumer, null); + + $once = $request->get_parameter('oauth_nonce'); + $timestamp = $request->get_parameter('oauth_timestamp'); + $signature = $request->get_parameter('oauth_signature'); + $expectedUrl = "http://www.endpoint.url/?" + . "oauth_consumer_key=ConsumerKey" + . "&oauth_nonce=" . $once + . "&oauth_signature=" . Util::urlencode_rfc3986($signature) + . "&oauth_signature_method=HMAC-SHA1" + . "&oauth_timestamp=" . $timestamp + . "&oauth_version=1.0"; + $this->assertEquals( $expectedUrl, (string) $request); } }