コード例 #1
0
 /**
  * Some API responses contain an EanWsError attribute instead of EanError
  */
 public function testEanErrorException_EanWsError()
 {
     $client = HotelClient::factory(['defaults' => ['cid' => '', 'apiKey' => '', 'customerIpAddress' => '', 'customerUserAgent' => '']]);
     $mock = new Mock([new Response(200, ['Content-Type' => 'application/xml'], Stream::factory('<ns2:HotelListResponse xmlns:ns2="http://v3.hotel.wsapi.ean.com/">' . '<EanWsError>' . '<itineraryId>-1</itineraryId>' . '<handling>RECOVERABLE</handling>' . '<category>DATA_VALIDATION</category>' . '<exceptionConditionId>-1</exceptionConditionId>' . '<presentationMessage>Data in this request could not be ' . 'validated: Specified city could not be resolved as valid ' . 'location.' . '</presentationMessage>' . '<verboseMessage>Data in this request could not be validated: ' . 'Specified city could not be resolved as valid location.' . '</verboseMessage>' . '<ServerInfo instance="131" timestamp="1413960307" serverTime="01:45:07.109-0500"/>' . '</EanWsError>' . '<customerSessionId>0ABAAA83-0D3B-C891-4932-697275196B14</customerSessionId>' . '</ns2:HotelListResponse>'))]);
     $client->getHttpClient()->getEmitter()->attach($mock);
     $client->getEmitter()->attach(new EanError());
     $command = $client->getCommand('GetHotelList');
     try {
         $client->execute($command);
     } catch (EanErrorException $e) {
         $this->assertEquals('RECOVERABLE', $e->getHandling());
         $this->assertEquals('DATA_VALIDATION', $e->getCategory());
         return true;
     }
     $this->fail("An EanErrorException was not thrown");
 }
コード例 #2
0
 /**
  * @dataProvider providerForTestRequestUrl
  */
 public function testRequestUrl($command, $params, $expectedMethod, $expectedUrl)
 {
     $client = HotelClient::factory(['auth' => ['cid' => '55505', 'apiKey' => 'cbrzfta369qwyrm9t5b8y8kf'], 'defaults' => ['minorRev' => 30, 'locale' => 'en_US', 'currencyCode' => 'AUD', 'customerSessionId' => 'x', 'customerIpAddress' => 'y', 'customerUserAgent' => 'z']]);
     $mock = new Mock([new Response(200)]);
     $history = new History();
     $emitter = $client->getHttpClient()->getEmitter();
     $emitter->attach($mock);
     $emitter->attach($history);
     $command = $client->getCommand($command, $params);
     $client->execute($command);
     $request = $history->getLastRequest();
     $this->assertEquals($expectedMethod, $request->getMethod());
     $this->assertEquals('application/xml', $request->getHeader('Accept'));
     $this->assertEquals('gzip,deflate', $request->getHeader('Accept-Encoding'));
     $this->assertEquals($expectedUrl, $request->getUrl());
 }
コード例 #3
0
 /**
  * AddressInfo.postalCode only submits the first 10 characters.
  * @see http://dev.ean.com/docs/read/book_reservation#lastName
  */
 public function testAddressInfoMaxPostalCode()
 {
     $client = HotelClient::factory();
     $input = str_repeat('a', 300);
     $param = $client->getDescription()->getOperation('PostReservation')->getParam('AddressInfo')->getProperty('postalCode');
     $this->assertEquals(10, strlen($param->filter($input)), 'AddressInfo.postalCode cannot contain more than 10 characters');
 }