本文整理汇总了PHP中ApiTester::seeInDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiTester::seeInDatabase方法的具体用法?PHP ApiTester::seeInDatabase怎么用?PHP ApiTester::seeInDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiTester
的用法示例。
在下文中一共展示了ApiTester::seeInDatabase方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: successfullEnd
public function successfullEnd(ApiTester $I)
{
$I->am('a valid user');
$I->wantTo('verify the endpoint returns a success response and creates the proper records');
$user = $I->getActiveKeyholderMember();
$keyFob = $I->getMemberKeyFob($user->id);
//Send a bad code to the endpoint
$I->sendPOST('/access-control/device', ['data' => $keyFob->key_id . '|welder|start']);
//The device endpoint always returns 200
$I->canSeeResponseCodeIs(200);
//Make sure a success is returned and a session started
$I->canSeeResponseContainsJson(['valid' => '1']);
$I->seeInDatabase('equipment_log', ['user_id' => $user->id, 'device' => 'welder', 'active' => 1]);
$I->sendPOST('/access-control/device', ['data' => $keyFob->key_id . '|welder|end']);
$I->canSeeResponseCodeIs(200);
$I->dontSeeHttpHeader('Set-Cookie');
$I->dontSeeHttpHeader('Built-By');
$I->canSeeResponseContainsJson(['valid' => '1']);
//Make sure our database record is not active
$I->seeInDatabase('equipment_log', ['user_id' => $user->id, 'device' => 'welder', 'active' => 0]);
//And make sure there is no other active record
$I->cantSeeInDatabase('equipment_log', ['user_id' => $user->id, 'device' => 'welder', 'active' => 1]);
}
示例2: inactiveMemberLogin
public function inactiveMemberLogin(ApiTester $I)
{
$I->am('an inactive member');
$I->wantTo('post to the main door endpoint and get an OK back');
$user = $I->getInactiveKeyholderMember();
$keyFob = $I->getMemberKeyFob($user->id);
//Post the keyfob to the endpoint
$I->sendPOST('/access-control/main-door', ['data' => $keyFob->key_id]);
//The endpoint always returns 200
$I->seeResponseCodeIs(200);
//Make sure a good response is returned
$I->seeResponseIsJson();
//Response contains their name
//$I->seeResponseContains($user->given_name);
//Make sure the request was allowed
$I->seeResponseContainsJson(['valid' => '0']);
//Confirm an access log record was created
$I->seeInDatabase('access_log', ['user_id' => $user->id, 'key_fob_id' => $keyFob->id, 'response' => 402, 'service' => 'main-door']);
}
示例3: ApiTester
<?php
$I = new ApiTester($scenario);
$I->wantTo('update an existing asset via PUT');
$I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8');
// no whitespaces in content hash!
$I->haveHttpHeader('X-Hash', '5bb14dac8d49806a4f10bc24aff299b33c1f229eed775e7784b3e7a2888b593f');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
// no whitespaces in json
$I->sendPUT('asset/4b0beb98ce160', '{"AgentID":"99999","AssetFullName":"TAPPETO T2100ee","AssetStatusID":"1","AssetUtilizationID":"1","CurrentValue":"null","DonorID":"4cf67d984d94f","EmployeeID":"4d64045c4a525","GenericAssetID":"18427","InstallationDate":"2014-7-19","InternalIventoryNumber":"1234567890","Lifetime":"14","LocationID":"4d1481c1a54c5","ManufacturerID":"4d6f38daa55e4","Metrology":"0","MetrologyDate":"2014-7-19","MetrologyDocument":"null","Model":"T2100","Notes":"null","Picture":"null","PurchaseDate":"2013-6-20","PurchasePrice":"10000","ResponsiblePers":"null","SerialNumber":"SAS2345678WA","ServiceManual":"null","SupplierID":"4ce525f47e550","UMDNS":"14141","URL_Manual":"null","WarrantyContractExp":"2014-6-30","WarrantyContractID":"1","WarrantyContractNotes":"null","by_user":"null","lastmodified":"null"}');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeInDatabase('assets', array('AgentID' => '99999', "AssetFullName" => 'TAPPETO T2100ee', "AssetID" => "4b0beb98ce160"));
示例4: ApiTester
<?php
$I = new ApiTester($scenario);
$I->wantTo('create a request on a asset via POST');
$I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8');
//no whitespaces in content hash!
$I->haveHttpHeader('X-Hash', '9fdcd3d292ce958b3d14c803aba077c965e54ebb1b991fee0d01038c9e8951c5');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
$I->sendPOST('asset/4b674c6d9e9ff/request', '{"Request_date":"2014-02-14","Request_desc":"blob","Request_contact_name":"Nicola Keller","Request_note":"somenotes","Request_st_id":"1","VisiTpID":"4"}');
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
//we don't test request_id response because its everytime different (PHP's uniqid())
$I->seeResponseContainsJson(array("error" => false));
$I->seeResponseContainsJson(array("message" => "Request added"));
$I->seeInDatabase('request', array("AssetID" => "4b674c6d9e9ff", "Request_contact_name" => "Nicola Keller"));
示例5: ApiTester
<?php
$I = new ApiTester($scenario);
$I->wantTo('create new intervention via POST');
$I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8');
//no whitespaces in content hash!
$I->haveHttpHeader('X-Hash', '34756c567620857fac3539130db7c4e7d52162c7c349baeb82f635cf7003716a');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
//no whitespaces in json
$I->sendPOST('asset/4b6342489a963/532c5ad50d547/intervention', '{"Date":"2014-01-01","EmployeeID":"4d64045c4a525","AssetStatusID":1,"FaildPart":"Cable","FailurCategID":2,"FailureCauseID":1,"Interv_desc":"cables fixed","Comments":"repeat","RespEng":"4c8fcac9f06fa","TotalWork":1,"TotalCosts":2}');
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(array("error" => false));
$I->seeResponseContainsJson(array("message" => "Intervention added"));
$I->seeInDatabase('intervention', array('AssetID_Visit' => '4b6342489a963', "Request_id" => '532c5ad50d547', "EmployeeID" => "4d64045c4a525"));
示例6: ApiTester
<?php
$I = new ApiTester($scenario);
$I->wantTo('create new intervention work via POST');
$I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8');
$I->haveHttpHeader('X-Hash', 'f6ddc80ba5123475c102ba654f5092e130df09bcec335e503db7757468cb7428');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
//no whitespaces in json
$I->sendPOST('intervention/work', '{"IntervID":"532c5b53aab95","Action":"yesitis","Date_action":"2014-01-01","Time":20}');
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(array("error" => false));
$I->seeResponseContainsJson(array("message" => "Intervention work created"));
$I->seeInDatabase('intervention_work', array("IntervID" => "532c5b53aab95", "Action" => "yesitis"));
示例7: ApiTester
<?php
$I = new ApiTester($scenario);
$I->wantTo('create new intervention material via POST');
$I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8');
//no whitespaces in content hash!
$I->haveHttpHeader('X-Hash', '604f063497b262f82851998915b85ad16502c8f1a4aa85e7b2fac4f04038bc0f');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
//no whitespaces in json
$I->sendPOST('intervention/material', '{"Description":"test","Amount":10,"PartNumber":"abc","UnitPrice":5.0,"IntervID":"532c5b53aab95"}');
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(array("error" => false));
$I->seeResponseContainsJson(array("message" => "Intervention material created"));
$I->seeInDatabase('intervention_material', array("IntervID" => "532c5b53aab95", "Description" => "test", "Amount" => 10));
示例8: ApiTester
<?php
$I = new ApiTester($scenario);
$I->wantTo('create new asset via POST');
$I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8');
//no whitespaces in content hash!
$I->haveHttpHeader('X-Hash', '6fb6b38ce5277f1fdfce13e8aed07ccc5421c67c01d0580894c3f067503138ae');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
//no whitespaces in json
$I->sendPOST('asset', '{"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","ServiceManual":"","Notes":null,"Picture":"gen_images/12636.jpg","by_user":"demo","URL_Manual":null,"MetrologyDocument":null,"MetrologyDate":null,"Metrology":"0"}');
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(array("error" => false, "message" => "Asset created"));
$I->seeInDatabase('assets', array('GenericAssetID' => '12636', "AssetFullName" => 'Dash'));
示例9: ApiTester
<?php
use Codeception\Module\ApiHelper;
$testPostData = ['title' => 'This is a cool topic!', 'details' => 'Where is the seismic moon? Ships meet on mankind at atlantis tower! Transporter of a ' . 'sub-light energy, arrest the voyage! Why does the planet meet? Planets die from ' . 'voyages like ship-wide space suits.', 'excerpt' => 'Yuck! Pieces o\' life are forever swashbuckling. Madness ho! scrape to be commanded.', 'owned_by_creator' => true];
$I = new ApiTester($scenario);
$I->wantTo('create a topic for me to talk about');
// Headers
$I->haveHttpHeader('Content-Type', 'application/json');
// Submit
$I->sendPOST(ApiHelper::ENDPOINT_TOPICS, $testPostData);
// Response
$I->seeResponseCodeIs(201);
$I->seeResponseIsJson();
$I->canSeeResponseJsonMatchesJsonPath('$.id');
$I->assertEquals($testPostData['details'], $I->grabDataFromResponseByJsonPath('$.details')[0]);
$I->assertEquals($testPostData['excerpt'], $I->grabDataFromResponseByJsonPath('$.excerpt')[0]);
$I->assertEquals($testPostData['owned_by_creator'], $I->grabDataFromResponseByJsonPath('$.owned_by_creator')[0]);
$I->canSeeResponseJsonMatchesJsonPath('$.created_at');
// Db record
$I->seeInDatabase('topic', $testPostData);
示例10: ApiTester
<?php
$I = new ApiTester($scenario);
$I->wantTo('update an existing intervention via PUT');
$I->haveHttpHeader('Content-Type', 'application/json;charset=utf-8');
// no whitespaces in content hash!
$I->haveHttpHeader('X-Hash', '8fa6f078389516253c2ca6ebdf4b37209721bd64eab99242ef51a9368b957d9e');
$I->haveHttpHeader('X-PublicKey', '248512b6a66f365a4e42f10ed0c854844767b8ca8eb0f74589953991e9f233b6');
// no whitespaces in json
$I->sendPUT('asset/4b67517f4462a/52fddba460044/532c5b53aab95', '{"Date":"2014-01-01","EmployeeID":"4d64045c4a525","AssetID_Visit":"4b67517f4462a","AssetStatusID":1,"FaildPart":"Cable Red","FailurCategID":2,"FailureCauseID":1,"Interv_desc":"blub","Comments":"yes","RespEng":"4c8fcac9f06fa","TotalWork":1,"TotalCosts":2}');
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();
$I->seeResponseContainsJson(array("error" => false));
$I->seeResponseContainsJson(array("message" => "Intervention updated"));
$I->seeInDatabase('intervention', array("IntervID" => "532c5b53aab95", "AssetID_Visit" => "4b67517f4462a", "Date" => "2014-01-01", "EmployeeID" => "4d64045c4a525", "RespEng" => "4c8fcac9f06fa"));