From 6a59cc25a6d8266e812b5cb68ab62913b4c6a5ac Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Wed, 14 Oct 2020 20:20:30 +0200 Subject: [PATCH] Update 10-APITesting.md See https://github.com/Codeception/module-rest/pull/28 --- docs/10-APITesting.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/10-APITesting.md b/docs/10-APITesting.md index 6c20af202..dc0887ebd 100644 --- a/docs/10-APITesting.md +++ b/docs/10-APITesting.md @@ -82,7 +82,7 @@ class CreateUserCest { $I->amHttpAuthenticated('service_user', '123456'); $I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded'); - $I->sendPOST('/users', [ + $I->sendPost('/users', [ 'name' => 'davert', 'email' => 'davert@codeception.com' ]); @@ -131,26 +131,26 @@ $I->haveHttpHeader('content-type', 'application/json'); {% endhighlight %} -When headers are set, you can send a request. To obtain data use `sendGET`: +When headers are set, you can send a request. To obtain data use `sendGet`: {% highlight php %} sendGET('/posts', [ 'status' => 'pending' ]); +$I->sendGet('/posts', [ 'status' => 'pending' ]); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); {% endhighlight %} -> `sendGET` won't return any value. However, you can access data from a response and perform assertions using other available methods of REST module. +> `sendGet` won't return any value. However, you can access data from a response and perform assertions using other available methods of REST module. To create or update data you can use other common methods: -* `sendPOST` -* `sendPUT` -* `sendDELETE` -* `sendPATCH` +* `sendPost` +* `sendPut` +* `sendDelete` +* `sendPatch` ### JSON Structure Validation @@ -159,7 +159,7 @@ If we expect a JSON response to be received we can check its structure with [JSO {% highlight php %} sendGET('/users'); +$I->sendGet('/users'); $I->seeResponseCodeIs(HttpCode::OK); // 200 $I->seeResponseIsJson(); $I->seeResponseJsonMatchesJsonPath('$[0].user.login'); @@ -173,7 +173,7 @@ You can do that by using with a [seeResponseMatchesJsonType](http://codeception. {% highlight php %} sendGET('/users/1'); +$I->sendGet('/users/1'); $I->seeResponseCodeIs(HttpCode::OK); // 200 $I->seeResponseIsJson(); $I->seeResponseMatchesJsonType([ @@ -198,7 +198,7 @@ When you need to obtain a value from a response and use it in next requests you grabDataFromResponseByJsonPath('$.id'); -$I->sendGET('/pet/' . $id); +$I->sendGet('/pet/' . $id); {% endhighlight %} @@ -252,7 +252,7 @@ There is `seeXmlResponseIncludes` method to match inclusion of XML parts in resp {% highlight php %} sendGET('/users.xml'); +$I->sendGet('/users.xml'); $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); // 200 $I->seeResponseIsXml(); $I->seeXmlResponseMatchesXpath('//user/login'); @@ -390,4 +390,4 @@ Codeception has two modules that will help you to test various web services. The * **Next Chapter: [Codecoverage >](/docs/11-Codecoverage)** -* **Previous Chapter: [< Data](/docs/09-Data)** \ No newline at end of file +* **Previous Chapter: [< Data](/docs/09-Data)**