codeception/module-rest
REST module for Codeception that simplifies testing REST/JSON APIs: send HTTP requests, set headers/auth, validate response codes, formats, and payloads, and assert JSON/XML content. Integrates with other Codeception modules for end-to-end API tests.
Full Changelog: https://github.com/Codeception/module-rest/compare/3.4.2...3.4.3
Full Changelog: https://github.com/Codeception/module-rest/compare/3.4.1...3.4.2
Full Changelog: https://github.com/Codeception/module-rest/compare/3.4.0...3.4.1
Full Changelog: https://github.com/Codeception/module-rest/compare/3.3.2...3.4.0
_failed._failed.Full Changelog: https://github.com/Codeception/module-rest/compare/1.4.2...2.0.0
Added seeResponseIsJson() to send*AsJson actions
Step descorator AsJson was introduced to simplify sending and parsing JSON requests and responses.
Add it to suite configuration:
actor: ApiTester
step_decorators:
- \Codeception\Step\AsJson
or if you use API template:
suites:
api:
actor: ApiTester
step_decorators:
- \Codeception\Step\AsJson
Rebuild actions:
./vendor/bin/codecept build
And you get new actions:
sendPostAsJsonsendGetAsJson... basically all send* methods will receive AsJson pair which sends request in JSON and returns parsed response:
<?php
$user = $I->sendPostAsJson('user', ['id' => 1]);
codecept_debug($user['id'])
$I->assertEquals(1, $user['id'])
send* actions were updated to return a response:
$response = $I->sendGet('/users');
$response = $I->sendPost('/users', ['name' => 'jon']);
$response = $I->sendPut('/users/1', ['name' => 'jon']);
$response = $I->sendPatch('/users/1', ['name' => 'jon']);
$response = $I->sendDelete('/users/1');
$response = $I->send('PATCH','/users/1', ['name' => 'jon']);
Revert change implemented in 1.3.0
Append query params to URL for HEAD requests
How can I help you explore Laravel packages today?