/** * @author nathanhelenihi * @group api * @dataProvider fixtureAuthCfgObject */ public function testCallApi(array $fxt) { print_r($fxt); if (!$fxt['from_env']) { $this->markTestSkipped('Environment credentials not set.'); } $obj = new LoopBookingAction($fxt); $obj->setConfig('dataFormat', 'array'); if (!$obj->isEnabled()) { $this->markTestSkipped('API is disabled!'); } // Cancel a booking $data = array('OrderId' => '6862C94E9DFA-42C9-4E11-D0F7-297C5F79', 'Actions' => array('CANCEL?reason=hotelierwasmean')); $rsp = $obj->callApiWithParams($data); $this->assertTrue(isset($rsp['response']['body']['%Booking'])); // Uncancel a booking $data = array('OrderId' => '6862C94E9DFA-42C9-4E11-D0F7-297C5F79', 'Actions' => array('UNCANCEL?reason=changedmymind')); $rsp = $obj->callApiWithParams($data); $this->assertTrue(isset($rsp['response']['body']['%Booking'])); // Modify to come at a later time }
/** * @author nathanhelenihi * @group api * @dataProvider fixtureAuthCfgObject */ public function testCallApi(array $fxt) { print_r($fxt); if (!$fxt['from_env']) { $this->markTestSkipped('Environment credentials not set.'); } $obj = new LoopBookingAction($fxt); $obj->setConfig('dataFormat', 'xml'); if (!$obj->isEnabled()) { $this->markTestSkipped('API is disabled!'); } $auth = $fxt['auth']; //Cancel booking $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <LoopBookingAction>\n <Auth>\n <VendorId>{$auth->vendorId}</VendorId>\n <VendorPassword>{$auth->vendorPassword}</VendorPassword>\n <UserToken>{$auth->userToken}</UserToken>\n <UserPassword>{$auth->userPassword}</UserPassword>\n <PropertyId>{$auth->propertyId}</PropertyId>\n </Auth>\n <OrderId>6862C94E9DFA-42C9-4E11-D0F7-297C5F79</OrderId>\n <Actions>\n <Action>CANCEL?reason=hotelierwasmean</Action>\n </Actions>\n </LoopBookingAction>\n "; $rsp = $obj->callApiWithParams($xml); $this->assertEquals(200, $rsp['response']['code']); $this->assertFalse(strpos($rsp['response']['body'], '<Errors>'), 'Response contains errors!'); //Uncancel booking $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <LoopBookingAction>\n <Auth>\n <VendorId>{$auth->vendorId}</VendorId>\n <VendorPassword>{$auth->vendorPassword}</VendorPassword>\n <UserToken>{$auth->userToken}</UserToken>\n <PropertyId>{$auth->propertyId}</PropertyId>\n </Auth>\n <OrderId>6862C94E9DFA-42C9-4E11-D0F7-297C5F79</OrderId>\n <Actions>\n <Action>UNCANCEL?reason=changedmymind</Action>\n </Actions>\n </LoopBookingAction>\n "; $rsp = $obj->callApiWithParams($xml); $this->assertEquals(200, $rsp['response']['code']); $this->assertFalse(strpos($rsp['response']['body'], '<Errors>'), 'Response contains errors!'); }