ubirak / rest-api-behat-extension
Rest Api Extension for Behat
Installs: 288 573
Dependents: 4
Suggesters: 0
Security: 0
Stars: 38
Watchers: 10
Forks: 24
Open Issues: 7
Type:behat-extension
Requires
- php: >=7.2
- atoum/atoum: ^4
- behat/behat: ^3.8
- justinrainbow/json-schema: >=5.2.10 <6.0
- mtdowling/jmespath.php: ^2.3
- php-http/client-common: ^2.3
- php-http/discovery: ^1.13
- php-http/message: ^1.11
- psr/http-message: ^1.0
- symfony/config: ^4.4.12 | ~5.0 | ~6.0 | ~7.0
- symfony/dependency-injection: ^4.4.12 | ~5.0 | ~6.0 | ~7.0
- symfony/property-access: ^4.4.12 | ~5.0 | ~6.0 | ~7.0
- tolerance/tolerance: ^0.4.2
Requires (Dev)
- guzzlehttp/psr7: ^1.3
- php-http/guzzle7-adapter: ^0.1.1
- php-http/mock-client: ^1.0
- silex/silex: ~2.0
- symfony/process: ~4.0
Replaces
- rezzza/json-api-behat-extension: v8.3.0
- rezzza/rest-api-behat-extension: v8.3.0
This package is not auto-updated.
Last update: 2024-11-22 18:04:49 UTC
README
- Branch behat2 : Behat 2.x
- Branch master : Behat 3.x
For now only JSON api is supported to analyze response, but you could use REST part to perform request on any type of api.
Warning
From version 7.0
, namespace vendor changed from Rezzza
to Ubirak
.
Install
Require the package as a development dependency :
composer require --dev ubirak/rest-api-behat-extension
Don't forget to load the extension and the context if needed in your behat.yml
:
default: extensions: Ubirak\RestApiBehatExtension\Extension: rest: base_url: http://localhost:8888 store_response: true suites: default: contexts: - Ubirak\RestApiBehatExtension\RestApiContext - Ubirak\RestApiBehatExtension\Json\JsonContext
Then you will need to require in your composer the http client you want to use, and the message factory.
Example:
composer require --dev guzzlehttp/psr7 php-http/curl-client
Usage
You can use directly the JsonContext
or RestApiContext
by loading them in your behat.yml or use the RestApiBrowser
and JsonInspector
by adding them in the construct of your own context.
<?php /**/ use Ubirak\RestApiBehatExtension\Rest\RestApiBrowser; use Ubirak\RestApiBehatExtension\Json\JsonInspector; class FeatureContext implements Context { private $restApiBrowser; private $jsonInspector; public function __construct(RestApiBrowser $restApiBrowser, JsonInspector $jsonInspector) { $this->restApiBrowser = $restApiBrowser; $this->jsonInspector = $jsonInspector; } }