public function WebserviceIsAvailable(ApiTester $I) { $I->wantTo("check the availability of the webservice"); $I->amHttpAuthenticated('admin', 'admin'); $I->sendGET('index.php' . '?option=contact' . '&api=Hal' . '&webserviceClient=administrator' . '&webserviceVersion=1.0.0'); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeHttpHeader('Webservice-name', 'contact'); $I->seeHttpHeader('Webservice-version', '1.0.0'); }
<?php $I = new ApiTester($scenario); $I->wantTo('create a new device'); $user = $I->haveAnAccount(); $I->amHttpAuthenticated($user['email'], $user['password']); $I->sendPOST('devices', ['mac' => '00:19:20:A1:B4:FC', 'name' => 'Manuel']); $I->seeResponseCodeIs(422); $I->seeResponseIsJson(); $I->sendPOST('devices', ['ip' => '192.168.1.123', 'mac' => '00:19:20:A1:B4:FC', 'name' => 'Manuel']); $I->seeResponseCodeIs(201); $I->seeHttpHeader('Location', 'http://localhost/api/v1/devices/1'); $I->seeResponseIsJson(); $I->seeResponseContainsJson(['data' => ['ip' => '192.168.1.123', 'name' => 'Manuel', 'on_home_page' => 'auto', 'group' => null]]); $I->seeResponseJsonMatchesXpath('//data//device_added'); $I->seeResponseJsonMatchesXpath('//data//last_contact'); $I->seeRecord('devices', ['ip' => '192.168.1.123', 'mac' => '00:19:20:A1:B4:FC', 'name' => 'Manuel', 'public' => 'auto', 'group' => null]);
<?php $I = new ApiTester($scenario); $I->wantTo('get json via database/scheme'); $I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6'); $I->haveHttpHeader('X-Hash', 'e651e0f6450f89d82ab0a34c1d421097a635897f5e719179e49263ff145e6ed9'); $I->sendGET('database/scheme'); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeHttpHeader('Content-Type', 'application/json;charset=utf-8'); // we check not every field, just assets, location and facilities. //automatic counter for array index $i = -1; $I->seeResponseContainsJson(array('assets' => array(++$i => array('Field' => 'AssetID', 'Type' => 'char(13)', 'Null' => 'NO', 'Key' => 'PRI', 'Default' => NULL, 'Extra' => '')))); $I->seeResponseContainsJson(array('assets' => array(++$i => array('Field' => 'GenericAssetID', 'Type' => 'int(10)', 'Null' => 'YES', 'Key' => 'MUL', 'Default' => NULL, 'Extra' => '')))); $I->seeResponseContainsJson(array('assets' => array(++$i => array('Field' => 'UMDNS', 'Type' => 'int(10)', 'Null' => 'YES', 'Key' => '', 'Default' => NULL, 'Extra' => '')))); $I->seeResponseContainsJson(array('assets' => array(++$i => array('Field' => 'AssetFullName', 'Type' => 'varchar(255)', 'Null' => 'YES', 'Key' => '', 'Default' => NULL, 'Extra' => '')))); $I->seeResponseContainsJson(array('assets' => array(++$i => array('Field' => 'ManufacturerID', 'Type' => 'char(13)', 'Null' => 'YES', 'Key' => 'MUL', 'Default' => NULL, 'Extra' => '')))); $I->seeResponseContainsJson(array('assets' => array(++$i => array('Field' => 'Model', 'Type' => 'varchar(255)', 'Null' => 'YES', 'Key' => '', 'Default' => NULL, 'Extra' => '')))); $I->seeResponseContainsJson(array('assets' => array(++$i => array('Field' => 'SerialNumber', 'Type' => 'varchar(255)', 'Null' => 'YES', 'Key' => '', 'Default' => NULL, 'Extra' => '')))); $I->seeResponseContainsJson(array('assets' => array(++$i => array('Field' => 'InternalIventoryNumber', 'Type' => 'varchar(255)', 'Null' => 'YES', 'Key' => '', 'Default' => NULL, 'Extra' => '')))); $I->seeResponseContainsJson(array('assets' => array(++$i => array('Field' => 'LocationID', 'Type' => 'char(13)', 'Null' => 'YES', 'Key' => 'MUL', 'Default' => NULL, 'Extra' => '')))); $I->seeResponseContainsJson(array('assets' => array(++$i => array('Field' => 'ResponsiblePers', 'Type' => 'varchar(50)', 'Null' => 'YES', 'Key' => '', 'Default' => NULL, 'Extra' => '')))); $I->seeResponseContainsJson(array('assets' => array(++$i => array('Field' => 'AssetStatusID', 'Type' => 'int(10)', 'Null' => 'YES', 'Key' => 'MUL', 'Default' => NULL, 'Extra' => '')))); $I->seeResponseContainsJson(array('assets' => array(++$i => array('Field' => 'AssetUtilizationID', 'Type' => 'int(10)', 'Null' => 'YES', 'Key' => 'MUL', 'Default' => NULL, 'Extra' => '')))); $I->seeResponseContainsJson(array('assets' => array(++$i => array('Field' => 'PurchaseDate', 'Type' => 'date', 'Null' => 'YES', 'Key' => '', 'Default' => NULL, 'Extra' => '')))); $I->seeResponseContainsJson(array('assets' => array(++$i => array('Field' => 'InstallationDate', 'Type' => 'date', 'Null' => 'YES', 'Key' => '', 'Default' => NULL, 'Extra' => '')))); $I->seeResponseContainsJson(array('assets' => array(++$i => array('Field' => 'Lifetime', 'Type' => 'int(11)', 'Null' => 'YES', 'Key' => '', 'Default' => NULL, 'Extra' => '')))); $I->seeResponseContainsJson(array('assets' => array(++$i => array('Field' => 'PurchasePrice', 'Type' => 'double(24,0)', 'Null' => 'YES', 'Key' => '', 'Default' => NULL, 'Extra' => '')))); $I->seeResponseContainsJson(array('assets' => array(++$i => array('Field' => 'CurrentValue', 'Type' => 'double(24,0)', 'Null' => 'YES', 'Key' => '', 'Default' => NULL, 'Extra' => '')))); $I->seeResponseContainsJson(array('assets' => array(++$i => array('Field' => 'WarrantyContractID', 'Type' => 'int(10)', 'Null' => 'YES', 'Key' => 'MUL', 'Default' => NULL, 'Extra' => ''))));