public function deletePost(ApiTester $I) { $id = $I->haveRecord('posts', $this->getPostAttributes(['title' => 'Game of Thrones'])); $I->sendDELETE($this->endpoint . "/{$id}"); $I->seeResponseCodeIs(200); $I->dontSeeRecord('posts', ['id' => $id]); }
/** * Preberem zapis * * @param ApiTester $I * @depends create */ public function read(\ApiTester $I) { $ent = $I->successfullyGet($this->restUrl, $this->obj['id']); $I->assertEquals($ent['sifra'], 'ZZ'); $I->assertEquals($ent['naziv'], 'uu'); $I->assertEquals($ent['opis'], 'zz'); }
/** * get meta * * @param ApiTester $I */ public function getMeta(\ApiTester $I) { $controller = "drzava"; $view = ""; $expected = ""; $I->testFormMeta('drzava', ''); }
/** * Preberem zapis in preverim vsa polja * * @depends create * @param ApiTester $I */ public function readDatum(\ApiTester $I) { $ent = $I->successfullyGet($this->restUrl, $this->obj3['id']); codecept_debug($ent); $I->assertEquals($ent['zacetek'], '2009-09-14T00:00:00+0200'); //konec spremenjen v +0200 $ent = $I->successfullyGet($this->restUrl, $this->obj2['id']); $I->assertEquals($ent['zacetek'], '2003-02-01T00:00:00+0100'); }
/** * Preberem zapis in preverim vsa polja * * @depends create * @param ApiTester $I */ public function read(\ApiTester $I) { $ent = $I->successfullyGet($this->restUrl, $this->obj1['id']); $I->assertGuid($ent['id']); $I->assertEquals($ent['oznaka'], 'AA'); $I->assertEquals($ent['naziv'], 'uu'); $I->assertEquals($ent['aktiven'], TRUE); $I->assertEquals($ent['znacka'], TRUE); $I->assertEquals($ent['ikona'], 'AA'); }
public function testGetLocationsWithFilters() { $token = $this->doLogin('*****@*****.**', '123456'); $this->tester->haveHttpHeader('Content-type', 'application/json'); $this->tester->haveHttpHeader('X-Api-token', $token); $filter = ['game' => 1]; $this->tester->sendGET('/api/locations', $filter); $this->checkLocationList(); $data = json_decode($this->tester->grabResponse(), true); foreach ($data['data'] as $item) { $this->assertEquals($filter['game'], $item['game']); } }
/** * @depends update */ public function delete(ApiTester $I) { $I->wantTo('Delete a new Contact in com_contacts using DELETE'); $I->amHttpAuthenticated('admin', 'admin'); $I->sendDELETE('index.php' . '?option=contact' . '&api=Hal' . '&webserviceClient=administrator' . '&webserviceVersion=1.0.0' . "&id={$this->id}"); $I->seeResponseCodeIs(200); $I->sendGET('index.php' . '?option=contact' . '&api=Hal' . '&webserviceClient=administrator' . '&webserviceVersion=1.0.0' . "&id={$this->id}"); $I->seeResponseCodeIs(404); $I->seeResponseIsJson(); $I->seeResponseContains('"message":"Item not found with given key.","code":404,"type":"Exception"'); }
public function deleteUser(ApiTester $I, \Codeception\Scenario $scenario) { //$scenario->skip('ownCloud master is broken'); $I->wantTo('delete the user'); $I->amHttpAuthenticated('admin', 'admin'); $I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded'); $I->sendDELETE($this->apiUrl . '/users/' . $this->userId); $I->seeResponseCodeIs(200); $I->seeResponseIsXml(); $I->seeXmlResponseIncludes(XmlUtils::toXml(['status' => 'ok'])); }
/** * Preberem abonma * * @param ApiTester $I * @depends create */ public function read(\ApiTester $I) { $ent = $I->successfullyGet($this->restUrl, $this->obj1['id']); codecept_debug($ent); $I->assertEquals($ent['stPredstav'], 5); $I->assertEquals($ent['stKuponov'], 55); $I->assertEquals($ent['ime'], 'zz'); $I->assertEquals($ent['opis'], 'zz'); $I->assertEquals($ent['kapaciteta'], 444); $I->assertEquals($ent['barva'], '#123456'); }
public function delete(ApiTester $I) { $I->wantTo('delete 1 contact in Joomla using SOAP'); $I->amHttpAuthenticated('admin', 'admin'); $I->sendSoapRequest('delete', ['id' => $this->id]); $I->seeSoapResponseIncludes("<result>true</result>"); $I->sendSoapRequest('readItem', ['id' => $this->id]); $I->dontSeeSoapResponseIncludes("<name>{$this->name}</name>"); }
public function deleteDiscussion(ApiTester $I) { $I->wantTo('delete a discussion via API'); $user = $I->amAuthenticated(); $user->groups()->attach(4); // Make the user a moderator $discussion = Factory::create('Flarum\\Core\\Models\\Discussion', ['start_user_id' => $user->id]); $I->sendDELETE($this->endpoint . '/' . $discussion->id); $I->seeResponseCodeIs(204); $I->seeResponseEquals(''); $I->expect('the discussion was deleted in the database'); $I->dontSeeRecord('discussions', ['id' => $discussion->id]); }
public function unknownDeviceSystemMessage(ApiTester $I) { $I->am('sending a valid system message'); $I->wantTo('confirm it is received and handled correctly'); //Post the keyfob to the endpoint $I->sendPOST('/access-control/main-door', ['data' => ':unknown|unknown']); //The endpoint always returns 200 $I->seeResponseCodeIs(200); //Confirm an access log record was created //$I->seeInDatabase('access_log', ['user_id'=>$user->id, 'key_fob_id'=>$keyFob->id, 'response'=>200, 'service'=>'main-door']); }
public function invalidTime(ApiTester $I) { $I->am('an invalid device'); $I->wantTo('verify the endpoint returns validation failures - invalid time'); //Send a bad code to the endpoint $I->haveHttpHeader('Content-Type', 'application/json'); $I->haveHttpHeader('Accept', 'application/json'); $I->sendPOST('/acs', ['device' => 'main-door', 'tag' => 'ABCDEF123456', 'message' => 'boot', 'service' => 'entry', 'time' => 'abcdefgh']); $I->canSeeResponseCodeIs(422); }
/** * Preberem zapis in preverim vsa polja * * @depends create * @param ApiTester $I */ public function read(\ApiTester $I) { $ent = $I->successfullyGet($this->restUrl, $this->obj1['id']); codecept_debug($ent); $I->assertGuid($ent['id']); $I->assertEquals($ent['name'], 'TESTA'); $I->assertEquals($ent['description'], 'to je A'); $I->assertEquals($ent['builtIn'], false); //sam določi }
public function doCheckLogout($token) { // Do Logout $this->tester->haveHttpHeader('Content-type', 'application/json'); $this->tester->haveHttpHeader('X-Api-Token', $token); $this->tester->sendPOST('/api/logout'); $this->tester->seeResponseCodeIs(200); $this->tester->seeResponseIsJson(); // Check is logged out $this->checkIsLogin($token, false); }
/** * Preberem zapis in preverim vsa polja * * @depends create * @param ApiTester $I */ public function read(\ApiTester $I) { $ent = $I->successfullyGet($this->restUrl, $this->obj1['id']); $I->assertNotEmpty($ent['id']); $I->assertEquals($ent['uprizoritev']['id'], $this->lookUprizoritev['id']); $I->assertEquals($ent['krajGostovanja'], 'zz'); $I->assertEquals($ent['drzavaGostovanja'], $this->objDrzava1['id']); $I->assertEquals($ent['ustanova'], 'zz'); $I->assertEquals($ent['datumGostovanja'], '2011-02-01T00:00:00+0100'); $I->assertEquals($ent['ponoviInt'], 9); $I->assertEquals($ent['ponoviKoprInt'], 9); $I->assertEquals($ent['obiskInt'], 9); $I->assertEquals($ent['obiskKoprInt'], 9); $I->assertEquals($ent['zaproseno'], 9.119999999999999, "izračunano zaprošeno"); $I->assertEquals($ent['celotnaVrednost'], 45.6); $I->assertEquals($ent['nasDelez'], 45.6); $I->assertEquals($ent['transportniStroski'], 9.119999999999999); $I->assertEquals($ent['dnevPrvZad'], 9.119999999999999); $I->assertEquals($ent['tantieme'], 9.119999999999999); $I->assertEquals($ent['materialni'], 9.119999999999999); $I->assertEquals($ent['avtorskePravice'], 0); $I->assertEquals($ent['avtorskiHonorarji'], 9.119999999999999); $I->assertEquals($ent['avtorskiHonorarjiSamoz'], 9.119999999999999); $I->assertEquals($ent['vlozekGostitelja'], 2.34); $I->assertEquals($ent['lastnaSredstva'], $ent['nasDelez'] - $ent['zaproseno'] - $ent['drugiJavni'] - $ent['vlozekGostitelja'], "lastna sredstva"); $I->assertEquals($ent['celotnaVrednostMat'], 0); // $I->assertEquals($ent['drugiViri'], 9.12); $I->assertEquals($ent['drugiJavni'], 9.119999999999999); $I->assertEquals($ent['dokument'], NULL); $I->assertEquals($ent['gostitelj']['id'], $this->lookPopa1['id']); $I->assertEquals($ent['sort'], 1); $I->assertEquals($ent['imaKoprodukcije'], TRUE); }
<?php include 'version.php'; $I = new ApiTester($scenario); $I->wantTo('fetch the version information for the web app'); $I->sendGET('version'); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseContainsJson(["api_version" => $api_version, "app_version" => $app_version, "webapp_version" => $webapp_version]);
/** * Preberem zapis in preverim vsa polja * * @depends create * @param ApiTester $I */ public function read(\ApiTester $I) { $ent = $I->successfullyGet($this->restUrl, $this->obj1['id']); codecept_debug($ent); $I->assertGuid($ent['id']); $I->assertEquals($ent['celotnaVrednost'], 4.94, "celotna vrednost"); $I->assertEquals($ent['nasDelez'], 4.94, "naš delež"); $I->assertEquals($ent['zaproseno'], 0.66, "zaprošeno"); $I->assertEquals($ent['avtorskiHonorarji'], 1.24); $I->assertEquals($ent['avtorskiHonorarjiSamoz'], 1.24); $I->assertEquals($ent['tantieme'], 1.22, "tantieme"); $I->assertEquals($ent['materialni'], 1.24, "materialni"); $I->assertEquals($ent['avtorskePravice'], 1.24); $I->assertEquals($ent['drugiJavni'], 1.24); $I->assertEquals($ent['vlozekGostitelja'], 0); $I->assertEquals($ent['lastnaSredstva'], $ent['nasDelez'] - $ent['zaproseno'] - $ent['drugiJavni'] - $ent['vlozekGostitelja'], " lastna sredstva (ni nejavnih virov)"); // $I->assertEquals($ent['vlozekGostitelja'],1.24); $I->assertEquals($ent['obiskDoma'], 1); $I->assertEquals($ent['obiskKopr'], 0); // $I->assertEquals($ent['obiskGost' ],1 ); // $I->assertEquals($ent['obiskZamejo' ],1 ); // $I->assertEquals($ent['obiskInt' ],1 ); // $I->assertEquals($ent['ponoviDoma' ],1 ); // $I->assertEquals($ent['ponoviZamejo' ],1 ); // $I->assertEquals($ent['ponoviGost' ],1 ); // $I->assertEquals($ent['ponoviInt' ],1 ); $I->assertEquals($ent['uprizoritev']['id'], $this->lookUprizoritev['id']); $I->assertEquals($ent['tipProgramskeEnote'], $this->lookTipProgramskeEnote1['id']); $I->assertEquals($ent['kpe'], 0.4); $I->assertEquals($ent['dokument'], null); $I->assertEquals($ent['sort'], 1, "sort"); $I->assertEquals($ent['stZaposUmet'], 1); $I->assertEquals($ent['stZaposDrug'], 1); $I->assertEquals($ent['stHonorarnihZun'], 1); $I->assertEquals($ent['stHonorarnihZunIgr'], 1); $I->assertEquals($ent['stHonorarnihZunIgrTujJZ'], 1, "honor. igralec tuj JZ"); $I->assertEquals($ent['stHonorarnihZunSamoz'], 1, "samozaposlen igralec"); // še pri koproducentu $ent = $I->successfullyGet($this->restUrl, $this->obj4['id']); codecept_debug($ent); $I->assertGuid($ent['id']); $I->assertEquals($ent['priKoproducentu'], true); $I->assertEquals($ent['obiskDoma'], 0); // ali forsiral na 0 $I->assertEquals($ent['obiskKopr'], 123); }
<?php $I = new ApiTester($scenario); $I->wantTo('Test the database/export endpoint via GET'); $I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6'); $I->haveHttpHeader('X-Hash', 'e651e0f6450f89d82ab0a34c1d421097a635897f5e719179e49263ff145e6ed9'); $I->sendGET('database/export'); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseContainsJson(array('assets' => array(0 => array('AssetID' => '4b67517f4462a', 'GenericAssetID' => '12636', 'UMDNS' => '12636', 'AssetFullName' => 'Dash', 'ManufacturerID' => '4c44276c3c2c0', 'Model' => '4000 ', 'SerialNumber' => 'SD008484463GA', 'InternalIventoryNumber' => '01382928', 'LocationID' => '4b6b4f5120321', 'ResponsiblePers' => NULL, 'AssetStatusID' => '1', 'AssetUtilizationID' => '1', 'PurchaseDate' => NULL, 'InstallationDate' => NULL, 'Lifetime' => '10', 'PurchasePrice' => '131174', 'CurrentValue' => '104939', 'WarrantyContractID' => '1', 'AgentID' => '4c90677ca7db7', 'WarrantyContractExp' => NULL, 'WarrantyContractNotes' => NULL, 'EmployeeID' => '4cb6b8bbb9df6', 'SupplierID' => '4b595a7124c8b', 'DonorID' => '4c9066fc81b53', 'Notes' => NULL, 'Picture' => 'gen_images/12636.jpg', 'lastmodified' => '2010-02-05 01:47:18', 'by_user' => 'demo', 'URL_Manual' => NULL, 'MetrologyDocument' => NULL, 'MetrologyDate' => NULL, 'Metrology' => '0')))); $I->seeResponseContainsJson(array('location' => array(0 => array('LocationID' => '4b6b4f5120321', 'FacilityID' => '11', 'DeptID' => '2', 'Roomnb' => '', 'Floor' => '', 'Building' => '', 'NotetoTech' => '-')))); $I->seeResponseContainsJson(array('facilities' => array(0 => array('FacilityID' => '11', 'DistrictID' => '10001', 'FacilityName' => 'Central Hosptial')))); $I->seeResponseContainsJson(array('facilities' => array(0 => array('FacilityID' => '11', 'DistrictID' => '10001', 'FacilityName' => 'Central Hosptial')))); $I->seeResponseContainsJson(array('contacttype' => array(0 => array('ContactTypeID' => '1', 'ContactTypeName' => 'Manufacturer')))); $I->seeResponseContainsJson(array('contact' => array(0 => array('ContactID' => '4ac3718e8d251', 'ContactTypeID' => '3', 'ContactName' => 'Nespecificat', 'ContactPersonName' => NULL, 'ContactTitle' => NULL, 'Address' => NULL, 'City' => NULL, 'PostalCode' => NULL, 'CountryID' => '99999', 'PhoneNumber' => NULL, 'FaxNumber' => NULL, 'Website' => '', 'Services' => NULL)))); $I->seeResponseContainsJson(array('donors' => array(0 => array('DonorID' => '0', 'ContactID' => '4ac3718e8d251')))); $I->seeResponseContainsJson(array('agents' => array(0 => array('AgentID' => '0', 'ContactID' => '4ac3718e8d251')))); $I->seeResponseContainsJson(array('suppliers' => array(0 => array('SupplierID' => '4b59581a8bb8f', 'ContactID' => '4b59581a8abf1')))); $I->seeResponseContainsJson(array('manufactures' => array(0 => array('ManufacturerID' => '4b0be58d2806b', 'ContactID' => '4b0be58d2612c')))); $I->seeResponseContainsJson(array('consumables' => array(0 => array('ConsumableID' => '1', 'Name' => 'Sensor debit', 'ManufacturerID' => '4c62506a58149', 'PartNumber' => '121', 'PackageQty' => '1', 'SupplierID' => '4c36d8223e3cf', 'UnitPrice' => '1', 'Notes' => '1', 'lastmodified' => '2012-01-17 14:15:11', 'by_user' => 'demo', 'TypeCons' => NULL)))); $I->seeResponseContainsJson(array('consumables_linked' => array(0 => array('Consumable_linkedID' => '1', 'ConsumableID' => '1', 'AssetID' => '4f154ff62df0e', 'AnnualConsumption' => '100', 'Notes' => 'Order 2 month before')))); $I->seeResponseContainsJson(array('employees' => array(0 => array('EmployeeID' => '0', 'LoginID' => '3', 'FirstName' => 'admin', 'LastName' => 'admin', 'Position' => NULL, 'TechnicianYN' => '1', 'LocationID' => '4b0be83d5d1d7', 'WorkPhone' => NULL, 'HandPhone' => NULL, 'Email' => NULL, 'Fax' => NULL, 'Accesslevel' => ' AND (facilities.FacilityID=12)')))); $I->seeResponseContainsJson(array('department' => array(3 => array('DeptID' => '4', 'DepartmentDesc' => 'Allergology')))); $I->seeResponseContainsJson(array('essential_equipment' => array(0 => array('EssentialEquipmentID' => '1', 'FacilityID' => '11', 'GenericAssetID' => '10134', 'MinimalQuantity' => '2', 'Notes' => NULL)))); $I->seeResponseContainsJson(array('assetgenericname' => array(0 => array('GenericAssetID' => '10134', 'GenericAssetCode' => '10134', 'GenericAssetName' => 'Anaesthesia Units', 'AssetCategoryID' => '5', 'GenericPicture' => 'gen_images/10134.jpg')))); $I->seeResponseContainsJson(array('assetutilization' => array(0 => array('AssetUtilizationID' => '1', 'AssetUtilizationDesc' => 'Normal')))); $I->seeResponseContainsJson(array('assetstatus' => array(0 => array('AssetStatusID' => '1', 'AssetStatusDesc' => 'Fully functional')))); $I->seeResponseContainsJson(array('assetcategory' => array(0 => array('AssetCategoryID' => '1', 'AssetCategoryNr' => '1', 'AssetCategoryName' => 'Dental')))); $I->seeResponseContainsJson(array('intervention' => array(0 => array('IntervID' => '532c5b53aab95', 'Date' => '2014-03-21', 'EmployeeID' => '4d64045c4a525', 'AssetStatusID' => '1', 'AssetID_Visit' => '4b67517f4462a', 'Request_id' => '52fddba460044', 'FaildPart' => 'Cable', 'FailurCategID' => '2', 'FailureCauseID' => '0', 'Interv_desc' => 'Description Intervention', 'Interv_desc_eg' => '', 'Comments' => 'Comments', 'RespEng' => '4c8fcac9f06fa', 'TotalWork' => '0', 'TotalCosts' => '0', 'lastmodified' => '2014-03-21 16:59:22', 'by_user' => 'demo')))); $I->seeResponseContainsJson(array('request' => array(0 => array('Request_id' => '52fddba460044', 'Request_date' => '2014-02-14', 'Request_desc' => 'Repair', 'Request_desc_eg' => 'Repair', 'AssetID' => '4b67517f4462a', 'Request_st_id' => '1', 'Request_contact_name' => 'Agata Correia', 'Request_note' => 'Notes', 'lastmodified' => '2014-02-14 10:02:53', 'by_user' => 'demo', 'VisiTpID' => '1')))); $I->seeResponseContainsJson(array('request_st' => array(0 => array('Request_st_id' => '1', 'Request_st_desc' => 'Open'))));
<?php Yii::$app->redis->executeCommand('FLUSHDB'); use Codeception\Util\Debug; $model = new \app\models\Message(); $model->author_email = '*****@*****.**'; $model->author_name = 'test'; $model->message = str_repeat('A', 140); $model->save(); $I = new ApiTester($scenario); $I->wantTo('Ver a lista de mensagens'); $I->sendGET('messages', []); $I->seeResponseIsJson(); $I->seeResponseJsonMatchesJsonPath('$[0].author_name'); $I->seeResponseJsonMatchesJsonPath('$[0].author_email'); $I->seeResponseJsonMatchesJsonPath('$[0].message'); $I->seeResponseJsonMatchesJsonPath('$[0].id'); $I->seeResponseJsonMatchesJsonPath('$[0].creation_time');
public function testTestUsersCreation(ApiTester $I) { $I->wantTo('make sure my test users have been created'); $I->amHttpAuthenticated('admin', 'admin'); $I->sendGET($this->baseUrl . '/users/' . $this->userId); $I->seeResponseCodeIs(200); $I->seeResponseIsXml(); $I->seeXmlResponseIncludes(XmlUtils::toXml(['status' => 'ok'])); $I->sendGET($this->baseUrl . '/users/' . $this->sharerUserId); $I->seeResponseCodeIs(200); $I->seeResponseIsXml(); $I->seeXmlResponseIncludes(XmlUtils::toXml(['status' => 'ok'])); }
<?php $I = new ApiTester($scenario); $I->wantTo('Get user with not exists id'); $I->sendGET('users/500000000'); $I->seeResponseCodeIs(404); $I->seeResponseIsJson(); $I->haveHttpHeader('Content-Type', 'application/json');
<?php use Aws\Glacier\TreeHash; $I = new ApiTester($scenario); $I->wantTo('Upload, retrieve and delete an archive.'); $I->haveAuth(); $I->sendPUT('/-/vaults/testvault'); $I->seeResponseCodeIs(201); $data = ''; $archiveSize = 1024 * 1024 + 10; for ($i = 0; $i < $archiveSize; $i++) { $data .= chr(rand(0, 255)); } $data[0] = 'A'; $data[1] = 'B'; $data[2] = 'C'; $data[3] = 'D'; $treeHash = new TreeHash(); $treeHash->update($data); $treeHash = bin2hex($treeHash->complete()); $hash = hash('sha256', $data); $I->haveHttpHeader('Content-Type', 'application/octet-stream'); $I->haveHttpHeader('x-amz-archive-description', 'test123'); $I->haveHttpHeader('x-amz-sha256-tree-hash', $treeHash); $I->haveHttpHeader('x-amz-content-sha256', $hash); $I->sendPOST('/-/vaults/testvault/archives', $data); $I->seeResponseCodeIs(201); $I->seeResponseEquals(''); $archiveID = $I->grabHttpHeader('x-amz-archive-id'); $I->haveHttpHeader('Content-Type', 'application/json'); $I->sendPOST('/-/vaults/testvault/jobs', ['Type' => 'archive-retrieval', 'ArchiveId' => $archiveID]);
<?php $I = new ApiTester($scenario); $I->wantTo('Check for hot tips'); //$I->amHttpAuthenticated('service_user', '123456'); ////$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded'); $I->sendGet('http://api.invendium-dev.com/?source='); //$I->seeResponseCodeIs(200); //$I->seeResponseIsJson(); //$I->seeResponseContains('odds_rounded'); //$I->seeResponseContains('popularity'); //$I->seeResponseContainsJson(array('sport' => 'Football')); $tips = $I->grabDataFromResponseByJsonPath('$.tips'); $array = array(); foreach ($tips[0] as $tip) { $array[] = $tip['sportname']; } $array = array_count_values($array); foreach ($array as $sportname => $tipsCount) { $I->assertGreaterThanOrEqual('10', $tipsCount, "{$sportname} has only {$tipsCount} tips."); }
<?php $I = new ApiTester($scenario); $I->wantTo('Test the cart behaviour with items'); $I->amGoingTo('confirm the cart is empty'); $I->sendGET('cart'); $I->seeCodeAndJson(200, ['items' => [], 'total' => floatify(0)]); /** * @var array $item1 * @var array $item2 * @var int $item_id */ require "_AddItems.php"; $I->amGoingTo('Verify order'); $I->sendGET('cart'); $I->expectTo('see items in order'); $I->seeCodeAndJson(200, ['items' => [$item1, $item2]]); $I->expectTo('see correct total'); $I->seeResponseContainsJson(['total' => floatify($item1['final_price'] + $item2['final_price'])]); $I->amGoingTo('delete an item'); $I->sendDELETE('cart/item/' . $item_id); $I->seeResponseCodeIs(204); $I->seeResponseEquals(''); $I->sendGET('cart'); $I->seeCodeAndJson(200, ['items' => [$item2], 'total' => floatify($item2['final_price'])]); $I->amGoingTo('clear the cart'); $I->sendDELETE('cart'); $I->seeResponseCodeIs(204); $I->seeResponseEquals(''); $I->sendGET('cart'); $I->seeCodeAndJson(200, ['items' => [], 'total' => floatify(0)]);
/** * Preberem zapis in preverim vsa polja * * @depends createZWriteZWriteZaEntitetoLasnika * @param ApiTester $I */ public function readZReadZReadZaEntitetoLasnika(\ApiTester $I) { $I->amHttpAuthenticated(\IfiTest\AuthPage::$rikard, \IfiTest\AuthPage::$rikardPass); $ent = $I->successfullyGet($this->restUrl, $this->obj1['id']); $I->assertGuid($ent['id']); $resp = $I->successfullyGetList($this->restUrl . "?lastnik=" . $this->lookUprizoritev5['id'], []); $list = $resp['data']; $I->assertNotEmpty($list); }
function obtainAuthCodeGrantRedirectsToLogin(ApiTester $I) { $client = factory(App\Models\OAuthClient::class, 1)->create(); $grant = \App\Models\OAuthGrant::find('authorization_code'); $client->oauth_grants()->attach($grant); $scope = \App\Models\OAuthScope::find('user_read'); $client->oauth_scopes()->attach($scope); $endpoint = factory(App\Models\OAuthClientEndpoint::class, 1)->make(); $endpoint->oauth_client()->associate($client); $endpoint->save(); $I->wantTo('Be redirected to login page when un authenticated user visits auth code page'); $I->amOnPage('authorize?client_id=' . $client->id . '&redirect_uri=' . $endpoint->redirect_uri . '&response_type=code&scope=user_read'); $I->seeInCurrentUrl('login'); }
/** * Preverim, ali ima user nima več rol * * @param ApiTester $I * @depends userRevokeDveRoli */ public function preberiUserjaAliNimaRol(\ApiTester $I) { $user = $I->successfullyGet($this->restUrl, $this->obj['id']); $I->assertNotEmpty($user); $I->assertTrue(isset($user['roles'])); $I->assertEquals(0, count($user['roles'])); }
<?php $I = new ApiTester($scenario); $I->wantTo('Get a 404 when I want to delete an asset that does not exist'); $I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8'); $I->haveHttpHeader('X-Hash', 'e651e0f6450f89d82ab0a34c1d421097a635897f5e719179e49263ff145e6ed9'); $I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6'); $I->sendDELETE('asset/xyz123456', ''); $I->seeResponseCodeIs(404);
<?php $scenario->group('rels'); $I = new ApiTester($scenario); $I->wantTo('load the initial rels'); $I->sendGET('/rels'); $I->grabDataFromResponseByJsonPath('$'); $I->seeResponseContainsJson(['loadList' => '/list/elements', 'addToList' => '/list/elements', 'removeFromList' => '/list/elements']);