public function readList(ApiTester $I) { $I->createAndLoginUser(); $I->createProjectAndSetHeader(); $tableData = $I->getTableShortData(); $tableData['title'] = 'Search'; $tableData['description'] = 'Concrete'; $table1 = $I->createTable($tableData); $tableData['title'] = 'Search'; $tableData['description'] = 'Another'; $table2 = $I->createTable($tableData); $tableData['title'] = 'caps'; $tableData['description'] = 'EXAMPLE'; $table3 = $I->createTable($tableData); $tableData['title'] = 'mank@34ind'; $tableData['description'] = 'example'; $table4 = $I->createTable($tableData); $I->sendGET('api/v1/admin/tables'); $I->assertListTable(); foreach ($I->getResponseFields()->data as $item) { $I->sendGET('api/v1/admin/tables/' . $item->_id); $I->assertTable(); } $queries = ['title=arc' => ['amount' => 2, 'ids' => [$table1->_id, $table2->_id]], 'title=@34' => ['amount' => 1, 'ids' => [$table4->_id]], 'description=EXA' => ['amount' => 2, 'ids' => [$table3->_id, $table4->_id]]]; foreach ($queries as $query => $data) { $I->sendGET("api/v1/admin/tables?{$query}"); $I->assertListTable(); $response = $I->getResponseFields()->data; $I->assertEquals($data['amount'], count($response), "Wrong amount of the tables for query {$query}"); for ($i = 0; $i < count($response); ++$i) { $id = $response[$i]->_id; $I->assertTrue(in_array($id, $data['ids']), "Id '{$id}' should not be in response for query {$query}"); unset($data['ids'][$i]); } $I->assertTrue(0 == count($data['ids']), "Next ids should be in response: " . implode(',', $data['ids']) . ". Query: {$query}"); } $I->logout(); $I->sendGET('api/v1/admin/tables'); $I->seeResponseCodeIs(401); }
public function accessForCheck(ApiTester $I) { $first_user = $I->createUser(true, '', false); $second_user = $I->createUser(true); $I->loginUser($first_user); $I->createProjectAndSetHeader(); $consumer = $I->createConsumer(); $table = $I->createTable(); $table_id = $table->_id; $data = ['borrowers_phone_verification' => 'Positive', 'contact_person_phone_verification' => 'Positive', 'internal_credit_history' => 'Positive', 'employment' => true, 'property' => true, 'matching_rules_type' => 'decision']; $I->sendPOST("api/v1/tables/{$table_id}/decisions", $data); $I->canSeeResponseCodeIs(403); $I->seeResponseContains("Project owner is not activated, try again later"); $I->sendPOST('api/v1/projects/users', ['user_id' => $second_user->_id, 'role' => 'manager', 'scope' => ['tables_view', 'decisions_make']]); $I->loginUser($second_user); $I->sendPOST("api/v1/tables/{$table_id}/decisions", $data); $I->canSeeResponseCodeIs(403); $I->seeResponseContains("Project owner is not activated, try again later"); $I->loginConsumer($consumer); $I->sendPOST("api/v1/tables/{$table_id}/decisions", $data); $I->canSeeResponseCodeIs(403); $I->seeResponseContains("Project owner is not activated, try again later"); $I->logout(); $I->loginClient($I->getCurrentClient()); $I->sendPOST('api/v1/users/verify/email', ['token' => $first_user->sandbox->token_email->token]); $I->seeResponseCodeIs(200); $I->loginUser($first_user); $I->makeDecision($table_id); $I->loginConsumer($consumer); $I->makeDecision($table_id); $I->loginUser($second_user); $I->makeDecision($table_id); }