/** * @author nathanhelenihi * @group api * @dataProvider fixtureAuthCfgObject */ public function testCallApi(array $fxt) { if (!$fxt['from_env']) { $this->markTestSkipped('Environment credentials not set.'); } $obj = new RoomAvailabilityList($fxt); $obj->setConfig('dataFormat', 'xml'); if (!$obj->isEnabled()) { $this->markTestSkipped('API is disabled!'); } $auth = $fxt['auth']; $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <RoomAvailabilityList>\n <Auth>\n <VendorId>{$auth->vendorId}</VendorId>\n <VendorPassword>{$auth->vendorPassword}</VendorPassword>\n <UserId>{$auth->userId}</UserId>\n <UserPassword>{$auth->userPassword}</UserPassword>\n <PropertyId>{$auth->propertyId}</PropertyId>\n </Auth>\n <StartDate>2014-12-10</StartDate>\n <EndDate>2014-12-20</EndDate>\n </RoomAvailabilityList>\n "; $rsp = $obj->callApiWithParams($xml); $this->assertEquals(200, $rsp['response']['code']); $this->assertFalse(strpos($rsp['response']['body'], '<Errors>'), 'Response contains errors!'); }
/** * @author nathanhelenihi * @group api * @dataProvider fixtureAuthCfgObject */ public function testCallApi(array $fxt) { if (!$fxt['from_env']) { $this->markTestSkipped('Environment credentials not set.'); } $obj = new RoomAvailabilityList($fxt); $obj->setConfig('dataFormat', 'array'); if (!$obj->isEnabled()) { $this->markTestSkipped('API is disabled!'); } // No req args should fail $caught = false; try { $rsp = $obj->callApi(); } catch (\exception $e) { $caught = true; $this->assertInstanceOf('MyAllocator\\phpsdk\\src\\Exception\\ApiException', $e); } if (!$caught) { $this->fail('should have thrown an exception'); } $rsp = $obj->callApiWithParams(array('StartDate' => '2015-03-01', 'EndDate' => '2015-03-31')); $this->assertTrue(isset($rsp['response']['body']['Rooms'])); }