| layout | doc |
|---|---|
| title | Codeception - Documentation |
Module for testing REST WebService.
This module can be used either with frameworks or PHPBrowser. It tries to guess the framework is is attached to.
Whether framework is used it operates via standard framework modules. Otherwise sends raw HTTP requests to url via PHPBrowser.
- url optional - the url of api
- headers - array of headers going to be sent.
- params - array of sent data
- response - last response (string)
Adds HTTP authentication via username/password.
- param $username
- param $password
Checks weather last response do not contain text.
- param $text
Opposite to seeResponseContainsJson
- param array $json
Returns data from the current JSON response using specified path so that it can be used in next scenario steps
Example:
{% highlight php %}
grabDataFromJsonResponse('user.user_id'); $I->sendPUT('/user', array('id' => $user_id, 'name' => 'davert')); ?>{% endhighlight %}
-
param string $path
-
available since version 1.1.2
-
return string
-
author tiger.seo@gmail.com
Returns current response so that it can be used in next scenario steps.
Example:
{% highlight php %}
grabResponse(); $I->sendPUT('/user', array('id' => $user_id, 'name' => 'davert')); ?>{% endhighlight %}
- version 1.1
- return string
Sets HTTP header
- param $name
- param $value
Checks response code.
- param $num
Checks weather the last response contains text.
- param $text
Checks weather the last JSON response contains provided array. The response is converted to array with json_decode($response, true) Thus, JSON is represented by associative array. This method matches that response array contains provided array.
Examples:
{% highlight php %}
seeResponseContainsJson(array('name' => 'john')); // response {user: john, profile: { email: john@gmail.com }} $I->seeResponseContainsJson(array('email' => 'john@gmail.com')); ?>{% endhighlight %}
This method recursively checks if one array can be found inside of another.
- param array $json
Checks if response is exactly the same as provided.
- param $response
Checks weather last response was valid JSON. This is done with json_last_error function.
Sends DELETE request to given uri.
- param $url
- param array $params
- param array $files
Sends a GET request to given uri.
- param $url
- param array $params
Sends a POST request to given uri.
Parameters and files (as array of filenames) can be provided.
- param $url
- param array $params
- param array $files
Sends PUT request to given uri.
- param $url
- param array $params
- param array $files