Пример #1
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();
 }
Пример #2
0
 /**
  * @test
  *
  * Test to ensure plaintext signature is added to the header
  */
 public function verifyPlaintextSignatureIsAdded()
 {
     $expectedSignature = rawurlencode($this->consumer->getSecret());
     $expectedSignature .= '%26';
     $expectedSignature .= rawurlencode($this->user->getSecret());
     $this->plaintext->setHttpMethod('get');
     $this->plaintext->setResourceURL('https://example.com/api');
     $this->plaintext->setNonce('123456');
     $header = new Header();
     $header->setSignature($this->plaintext);
     $headerString = $header->createAuthorizationHeader();
     $this->assertContains($expectedSignature, $headerString, 'Signature was not found');
     $this->assertContains('OAuth', $headerString, 'OAuth Authorization type not found');
     $this->assertContains('oauth_nonce="123456"', $headerString, 'Nonce not found');
 }
Пример #3
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);
 }