| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [View Raw Code] [Original HTTPS Page] |
| layout | doc |
|---|---|
| title | REST Module - Codeception - Documentation |
For additional reference, please review the source
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.
This module requires PHPBrowser or any of Framework modules enabled.
modules:
enabled: [PhpBrowser, REST]
config:
PHPBrowser:
url: http://serviceapp/
REST:
url: 'http://serviceapp/api/v1/'
Adds Bearer authentication via access token.
s Digest authentication via username/password.
ram $username ram $password
Adds HTTP authentication via username/password.
Checks over the given HTTP header and (optionally) its value, asserting that are not there
Checks that response code is not equal to provided value.
Checks whether last response do not contain text.
Opposite to seeResponseContainsJson
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 the value of the specified header name
param $name
param Boolean $first Whether to return the first value or all header values
return string|array The first header value if $first is true, an array of values otherwise
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
Checks over the given HTTP header and (optionally) its value, asserting that are there
Checks that http response header is received only once. HTTP RFC2616 allows multiple response headers with the same name. You can check that you didn't accidentally sent the same header twice.
{% highlight php %}
seeHttpHeaderOnce('Cache-Control'); ?>>{% endhighlight %}
Checks response code equals to provided value.
Checks whether the last response contains text.
Checks whether 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.
Checks if response is exactly the same as provided.
Checks whether last response was valid JSON. This is done with json_last_error function.
Checks whether last response was valid XML. This is done with libxml_get_last_error function.
Sends DELETE request to given uri.
Sends a GET request to given uri.
Sends a HEAD request to given uri.
Sends LINK request to given uri.
@link http://tools.ietf.org/html/rfc2068#section-19.6.2.4
@author samva.ua@gmail.com
Sends an OPTIONS request to given uri.
Sends PATCH request to given uri.
Sends a POST request to given uri.
Parameters and files (as array of filenames) can be provided.
Sends PUT request to given uri.
Sends UNLINK request to given uri.
| Back | FazBrowse Home | New Git URL |