Ejemplo n.º 1
0
 /**
  * Test the protected prepare method
  *
  * @test
  */
 public function prepare()
 {
     // Arrange
     $service = new OAuth2Service();
     $client = Mockery::mock('GuzzleHttp\\Client');
     $response = Mockery::mock('GuzzleHttp\\Message\\Response');
     $token = ['access_token' => '4cc3st0k3n'];
     $endpoint = 'users/me';
     $client->shouldReceive('get')->once()->with($endpoint)->andReturn($response);
     $client->shouldReceive('setDefaultOption')->once()->with('headers/Authorization', 'OAuth ' . $token['access_token'])->andReturn($client);
     $service->setClient($client);
     $service->setToken($token);
     // Act
     $returned = $service->get($endpoint);
     // Assert
     $this->assertEquals($response, $returned);
 }