/** * @author nathanhelenihi * @group api * @dataProvider fixtureAuthCfgObject */ public function testCallApi(array $fxt) { if (!$fxt['from_env']) { $this->markTestSkipped('Environment credentials not set.'); } $obj = new RoomCreate($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 <RoomCreate>\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 <CreateRooms>\n <RoomTypes>\n <RoomType>\n <Label>SuiteX</Label>\n <Units>5</Units>\n <Occupancy>2</Occupancy>\n <Gender>MI</Gender>\n <PrivateRoom>true</PrivateRoom>\n </RoomType>\n </RoomTypes>\n </CreateRooms>\n </RoomCreate>\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 RoomCreate($fxt); $obj->setConfig('dataFormat', 'array'); if (!$obj->isEnabled()) { $this->markTestSkipped('API is disabled!'); } // No optional args should fail (at least 1 required) $caught = false; try { $rsp = $obj->callApiWithParams(array()); } catch (\exception $e) { $caught = true; $this->assertInstanceOf('MyAllocator\\phpsdk\\src\\Exception\\ApiException', $e); } if (!$caught) { $this->fail('should have thrown an exception'); } // Create single room type $data = array('Rooms' => array(array('PMSRoomId' => '310', 'Label' => 'King', 'Units' => '10', 'Occupancy' => '2', 'Gender' => 'MI', 'PrivateRoom' => 'true'))); $rsp = $obj->callApiWithParams($data); $this->assertTrue(isset($rsp['response']['body']['Success'])); $this->assertEquals($rsp['response']['body']['Success'], 'true'); $this->assertTrue(isset($rsp['response']['body']['Rooms'])); // Create multiple room types $data = array('Rooms' => array(array('PMSRoomId' => '306', 'Label' => 'Suite G', 'Units' => '8', 'Occupancy' => '1', 'Gender' => 'FE', 'PrivateRoom' => 'false'), array('PMSRoomId' => '307', 'Label' => 'Suite H', 'Units' => '10', 'Occupancy' => '2', 'Gender' => 'MI', 'PrivateRoom' => 'false'))); $rsp = $obj->callApiWithParams($data); $this->assertTrue(isset($rsp['response']['body']['Success'])); $this->assertEquals($rsp['response']['body']['Success'], 'true'); $this->assertTrue(isset($rsp['response']['body']['Rooms'])); }