Пример #1
0
 /**
  * Test that the output of the AuthorizationBuilder is what we expect.
  *
  * @dataProvider authorizationBuilderProvider
  *
  * @param int    $time
  * @param string $expected
  */
 public function testAuthorizationBuilder($time, $expected)
 {
     $mockTime = $this->getFunctionMock('JimLind\\Pie7o', 'time');
     $mockTime->expects($this->any())->willReturn($time);
     $settingList = ['accessToken' => 'YOUR ACCESS TOKEN', 'accessTokenSecret' => 'YOUR ACCESS TOKEN SECRET', 'consumerKey' => 'YOUR CONSUMER KEY', 'consumerSecret' => 'YOUR CONSUMER SECRET'];
     $builder = new AuthorizationBuilder($settingList);
     $method = 'METHOD';
     $uri = 'URI';
     $post = ['POST VALUE' => 'POST DATA'];
     $actual = $builder->build($method, $uri, $post);
     $this->assertEquals($expected, $actual);
 }
Пример #2
0
 /**
  * Build a Guzzle Request with an authorization header.
  *
  * @param array $postData
  *
  * @return Request
  */
 protected function buildRequest(array $postData)
 {
     $uri = $this->buildURI();
     $authorization = $this->authorizationBuilder->build($this->apiMethod, (string) $uri, $postData);
     $originalRequest = new Request($this->apiMethod, $uri);
     return $originalRequest->withHeader('Authorization', $authorization);
 }