Пример #1
0
 /**
  * Create Bpi Client
  *
  * @param string $endpoint URL
  * @param string $agency_id Agency ID
  * @param string $api_key App key
  * @param string $secret_key
  */
 public function __construct($endpoint, $agency_id, $api_key, $secret_key)
 {
     $this->client = new \Goutte\Client();
     $this->authorization = new \Bpi\Sdk\Authorization($agency_id, $api_key, $secret_key);
     $this->current_document = $this->endpoint = $this->createDocument();
     $this->endpoint->loadEndpoint($endpoint);
 }
Пример #2
0
 protected function createMockDocument($fixture)
 {
     $client = $this->getMock('Goutte\\Client');
     $client->expects($this->at(0))->method('request')->will($this->returnValue(new Crawler(file_get_contents(__DIR__ . '/Fixtures/' . $fixture . '.bpi'))));
     $client->expects($this->any())->method('getResponse')->will($this->returnValue(new Response()));
     $doc = new Document($client, new Authorization(mt_rand(), mt_rand(), mt_rand()));
     $doc->loadEndpoint('http://example.com');
     return $doc;
 }
Пример #3
0
 public function testAuthorization()
 {
     $agency_id = mt_rand();
     $public_key = mt_rand();
     $secret_key = mt_rand();
     $authorization = new Authorization($agency_id, $public_key, $secret_key);
     $client = $this->getMock('Goutte\\Client');
     $client->expects($this->at(0))->method('request')->with($this->equalTo('GET'), $this->equalTo('http://example.com'), $this->equalTo(array()), $this->equalTo(array()), $this->equalTo(array('HTTP_Auth' => $authorization->toHTTPHeader(), 'HTTP_Content_Type' => 'application/vnd.bpi.api+xml')))->will($this->returnValue(new Crawler(file_get_contents(__DIR__ . '/Fixtures/Node.bpi'))));
     $client->expects($this->once())->method('getResponse')->will($this->returnValue(new Response()));
     $doc = new Document($client, $authorization);
     $doc->loadEndpoint('http://example.com');
 }