本文整理汇总了PHP中ApiTester::assertResponseDataFields方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiTester::assertResponseDataFields方法的具体用法?PHP ApiTester::assertResponseDataFields怎么用?PHP ApiTester::assertResponseDataFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiTester
的用法示例。
在下文中一共展示了ApiTester::assertResponseDataFields方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createUpdateInvalid
public function createUpdateInvalid(ApiTester $I)
{
$I->createAndLoginClient();
$faker = $I->getFaker();
/** Normal user for Test Duplicate Username */
$I->sendPOST('api/v1/users/', ['email' => $faker->email, 'password' => $I->getPassword(), 'username' => 'duplicate', 'active' => true]);
$I->assertResponseDataFields(['active' => false], 201);
$invalidData = ['email' => ['', null, 'test', '<script></script>', '"alert12"', "test@i,ua"], 'username' => ['', null, '1', str_repeat('2', 33), 'duplicate'], 'password' => ['', null, '1fa', 'withoutdigit']];
foreach ($invalidData as $key => $data) {
$normalUserData = ['email' => $faker->email, 'password' => $I->getPassword(), 'username' => $faker->firstName];
foreach ($data as $item) {
$normalUserData[$key] = $item;
$I->sendPOST('api/v1/users/', $normalUserData);
$I->seeResponseCodeIs(422);
$I->seeResponseContains('"error":"validation"');
$I->seeResponseContains($key);
}
}
$I->createAndLoginUser(true);
foreach ($invalidData as $key => $data) {
foreach ($data as $item) {
$I->sendPUT('api/v1/users/current', [$key => $item]);
$I->seeResponseCodeIs(422);
$I->seeResponseContains('"error":"validation"');
$I->seeResponseContains($key);
}
}
# change password
$data = [['password' => $I->getPassword()], ['password' => $I->getPassword(), 'current_password' => 'invalid password']];
foreach ($data as $item) {
$I->sendPUT('api/v1/users/current', $item);
$I->seeResponseCodeIs(422);
$I->seeResponseContains('current_password');
}
}
示例2: update
public function update(ApiTester $I)
{
$user = $I->createAndLoginUser();
$I->createProjectAndSetHeader();
$I->createTable();
$I->sendGET('api/v1/admin/tables');
$I->assertListTable();
$id = $I->getResponseFields()->data[0]->_id;
$data = $I->getTableData();
$data['title'] = 'Updated title';
$data['description'] = 'Updated description';
$data['fields'] = [["key" => 'test_key', "title" => 'Test key', "source" => "request", "type" => 'string', 'preset' => null]];
$data['variants'] = [['default_decision' => 'Decline', 'rules' => [['_id' => $I->getMongoId(), 'than' => 'Approve', 'description' => 'New rule', 'conditions' => [['_id' => $I->getMongoId(), 'field_key' => 'test_key', 'condition' => '$eq', 'value' => 'test']]]]]];
$I->sendPUT('api/v1/admin/tables/' . $id, $data);
$I->assertTable();
$I->assertResponseDataFields($data);
$I->sendGET('api/v1/admin/changelog/tables');
$I->assertResponseDataFields(['author' => $user->username]);
}
示例3: updateMetaOk
public function updateMetaOk(ApiTester $I)
{
$I->createAndLoginUser();
$I->createProjectAndSetHeader();
$I->createTable($I->getTableShortData());
$decision = $I->makeDecision($I->getResponseFields()->data->_id, ['bool' => true, 'numeric' => 123, 'string' => 'Yes']);
$data = ['ok' => '0981723qweasdzxcTYUGHJBNBNM!@#$%^&*()_+{}|":>?<~`', 'json' => '{"type":{"num":123}}'];
$I->sendPUT("api/v1/admin/decisions/{$decision->_id}/meta", ['meta' => $data]);
$I->assertTableDecisionsForAdmin();
$I->assertResponseDataFields(['meta' => $data]);
$data = ['updated' => '0981723qweasdzxcTYUGHJBNBNM!@#$%^&*()_+{}|":>?<~`'];
$I->sendPUT("api/v1/admin/decisions/{$decision->_id}/meta", ['meta' => $data]);
$I->assertTableDecisionsForAdmin();
$I->assertResponseDataFields(['meta' => $data]);
$I->cantSeeResponseJsonMatchesJsonPath('$.data.meta.ok');
$I->cantSeeResponseJsonMatchesJsonPath('$.data.meta.json');
}