Ejemplo n.º 1
0
 /**
  * @test
  *
  * Ensure the base string has the required elements
  */
 public function ensureBaseStringFieldsArePresent()
 {
     $this->signature->setHttpMethod('post');
     $this->signature->setResourceURL('http://example.com/api/user');
     $this->signature->setTimestamp(104020507);
     $this->signature->setNonce('NONCEBRO');
     $baseString = rawurldecode($this->signature->createBaseString());
     $array = [];
     parse_str($baseString, $array);
     $this->assertEquals($array['oauth_timestamp'], 104020507);
     $this->assertEquals($array['oauth_nonce'], 'NONCEBRO');
     $this->assertEquals($array['oauth_version'], 1.0);
     $this->assertEquals($array['oauth_token'], '1234ABCD');
 }
Ejemplo n.º 2
0
 /**
  * Test to ensure the get method for sent DMs is being called correctly
  */
 public function testEnsureGetMethodIsCalledCorrectlyForSentDMS()
 {
     $signature = new HmacSha1($this->consumer, $this->access);
     $signature->setHttpMethod('GET');
     $signature->setResourceURL('https://api.twitter.com/1.1/direct_messages/sent.json');
     $signature->setTimestamp(1114234234234);
     $signature->setNonce('testNonce');
     $header = new Header();
     $header->setSignature($signature);
     $expectedHeader = $header->createAuthorizationHeader();
     $this->client->setSignature($signature);
     $this->client->expects($this->once())->method('makeGetRequest')->with('direct_messages/sent.json', []);
     $tweet = new DirectMessage($this->client);
     $tweet->retrieveLatestSentMessages();
 }
Ejemplo n.º 3
0
 /**
  * test to ensure the set properties are in the header
  */
 public function testEnsureHeaderIsBeingCreated()
 {
     $timestamp = 1420302568;
     $nonce = '3e448845e49f46fc47335a8537333ada';
     $signature = new HmacSha1($this->consumerToken, $this->accessToken);
     $signature->setResourceURL('http://api.twitter.com/1.1/statuses/show/460095281871073282.json');
     $signature->setHttpMethod('GET');
     $signature->setNonce($nonce);
     $signature->setTimestamp($timestamp);
     $matchSignature = rawurlencode($signature->sign());
     $this->twitter->setResourceUrl('http://api.twitter.com/1.1/statuses/show/460095281871073282.json');
     $this->twitter->setHttpMethod('GET');
     $this->twitter->setNonce($nonce);
     $this->twitter->setTimestamp($timestamp);
     $header = $this->twitter->getAuthorizationHeader();
     $this->assertGreaterThan(0, strpos($header, $matchSignature), $matchSignature . ' is not in ' . $header);
     $this->assertGreaterThan(0, strpos($header, $this->accessToken->getIdentifier()));
 }
Ejemplo n.º 4
0
 /**
  * Test to ensure delete is being called correctly
  */
 public function testEnsureDeleteIsHitCorrectly()
 {
     $signature = new HmacSha1($this->consumer, $this->access);
     $signature->setHttpMethod('POST');
     $signature->setResourceURL('https://api.twitter.com/1.1/statuses/destroy/1.json');
     $signature->setTimestamp(1114234234234);
     $signature->setNonce('testNonce');
     $header = new Header();
     $header->setSignature($signature);
     $expectedHeader = $header->createAuthorizationHeader();
     $this->client->setSignature($signature);
     $this->client->expects($this->once())->method('makePostRequest')->with('statuses/destroy/1.json');
     $tweet = new Tweet($this->client);
     $tweet->delete(1);
 }