GeezerVison is showing github.com — updated docs for REST · quantk/codeception.github.com@ad30527
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: docs/02-GettingStarted.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -270,7 +270,7 @@ Learn more about the [Cest format](http://codeception.com/docs/07-AdvancedUsage# |
270 | 270 | It's hard to write a complete test at once. |
271 | 271 | You will need to try different commands with different arguments before you find a correct path. |
272 | 272 |
|
273 | | -Since Codeception 3.0 you can pause the execution at any point and enter an interactive shell where you will be able to try different commands in action. |
| 273 | +Execution can be paused at any point and enter an interactive shell where you will be able to try different commands in action. |
274 | 274 | All you need to do is **call `$I->pause()`** somewhere in your test, then run the test in [debug mode](#Debugging). |
275 | 275 |
|
276 | 276 | Interactive Pause requires [`hoa/console`](https://hoa-project.net/) which is not installed by default. To install it, run: |
|
Collapse file
Copy file name to clipboardExpand all lines: docs/03-AcceptanceTests.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -567,7 +567,7 @@ $I->seeNumberOfElements(['css' => 'button.link'], 5); // DISABLED, can wait only |
567 | 567 |
|
568 | 568 | When it's hard to define condition to wait for, we can retry a command few times until it succeeds. |
569 | 569 | For instance, if you try to click while it's animating you can try to do it few times until it freezes. |
570 | | -Since Codeception 3.0 each action and assertion have an alias prefixed with `retry` which allows to retry a flaky command. |
| 570 | +Each action and assertion have an alias prefixed with `retry` which allows to retry a flaky command. |
571 | 571 |
|
572 | 572 | {% highlight php %} |
573 | 573 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: docs/10-APITesting.md +20-3Lines changed: 20 additions & 3 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -88,7 +88,7 @@ class CreateUserCest |
88 | 88 | 'name' => 'davert', |
89 | 89 | |
90 | 90 | ]); |
91 | | - $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); // 200 |
| 91 | + $I->seeResponseCodeIsSuccessful(); |
92 | 92 | $I->seeResponseIsJson(); |
93 | 93 | $I->seeResponseContains('{"result":"ok"}'); |
94 | 94 |
|
@@ -97,9 +97,26 @@ class CreateUserCest |
97 | 97 |
|
98 | 98 | {% endhighlight %} |
99 | 99 |
|
100 | | -We can use HTTP code constants from `Codeception\Util\HttpCode` instead of numeric values to check response code in `seeResponseCodeIs` and `dontSeeResponseCodeIs` methods. |
| 100 | +> New in codeception/module-rest 1.4.1: |
101 | 101 |
|
102 | | -Let's see what the test consist of. |
| 102 | +If API endpoint accepts JSON you can use a `send` methods with `AsJson` suffix to convert data automatically: |
| 103 | + |
| 104 | +{% highlight php %} |
| 105 | +$users = $I->sendGetAsJson('/users'); |
| 106 | +$I->sendPutAsJson('/users/' . $users[0]['id'], ['name' => 'new name']); |
| 107 | +$I->sendDeleteAsJson('/users/' . $users[1]); |
| 108 | + |
| 109 | +{% endhighlight %} |
| 110 | + |
| 111 | +To enable steps with `AsJson` suffix enable `Codeception\Step\AsJson` step decorator in suite config: |
| 112 | + |
| 113 | +```yaml |
| 114 | +actor: ApiTester |
| 115 | +step_decorators: |
| 116 | + - \Codeception\Step\AsJson |
| 117 | +``` |
| 118 | + |
| 119 | +> `sendGetAsJson`, `sendPutAsJson`, and others, are implemented with a [Step Decorator](https://codeception.com/docs/08-Customization#Step-Decorators). It adds `application/json` Content-Type, checks JSON response and returns JSON response as associative array. |
103 | 120 |
|
104 | 121 | ### Authorization |
105 | 122 |
|
|