Create test to Request and Consumer
This commit is contained in:
parent
9d2d8b0c1e
commit
79300e5a58
18
test/Eher/OAuth/ConsumerTest.php
Normal file
18
test/Eher/OAuth/ConsumerTest.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Eher\OAuth;
|
||||||
|
|
||||||
|
class ConsumerTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function testConsumer()
|
||||||
|
{
|
||||||
|
$consumer = null;
|
||||||
|
|
||||||
|
$consumer = new Consumer("ConsumerKey", "ConsumerSecret");
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
'Consumer[key=ConsumerKey,secret=ConsumerSecret]',
|
||||||
|
(string) $consumer
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,37 @@ namespace Eher\OAuth;
|
|||||||
|
|
||||||
class RequestTest extends \PHPUnit_Framework_TestCase
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user