public function updateMetaInvalid(ApiTester $I) { $I->createAndLoginUser(); $I->createProjectAndSetHeader(); $I->createTable($I->getTableShortData()); $decision = $I->makeDecision($I->getResponseFields()->data->_id, ['bool' => true, 'numeric' => 123, 'string' => 'Yes']); $data = array_fill(0, 20, 'test'); $data[str_repeat('2', 101)] = 'ok'; $data['invalid#'] = 'ok'; $data['stringLength'] = str_repeat('1', 501); $data['array'] = []; $data[] = [['array']]; $I->sendPUT("api/v1/admin/decisions/{$decision->_id}/meta", ['meta' => $data]); $I->seeResponseCodeIs(422); $I->canSeeResponseJsonMatchesJsonPath('$.data.meta_keys_amount'); $I->canSeeResponseJsonMatchesJsonPath('$.data.key_20'); $I->canSeeResponseJsonMatchesJsonPath('$.data.key_21'); $I->canSeeResponseJsonMatchesJsonPath('$.data.key_22_value'); $I->canSeeResponseJsonMatchesJsonPath('$.data.key_23_value'); $I->canSeeResponseJsonMatchesJsonPath('$.data.key_24_value'); $I->sendPUT("api/v1/admin/decisions/{$decision->_id}/meta", $data); $I->seeResponseCodeIs(422); $I->canSeeResponseJsonMatchesJsonPath('$.data.meta'); $I->sendPUT("api/v1/admin/decisions/{$decision->_id}/meta", []); $I->seeResponseCodeIs(422); $I->canSeeResponseJsonMatchesJsonPath('$.data.meta'); }
<?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);