rezzza / json-api-behat-extension
v8.1.1
2022-01-18 13:55 UTC
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
- symfony/dependency-injection: ^4.4.12 | ~5.0
- symfony/property-access: ^4.4.12 | ~5.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.1.1
- rezzza/rest-api-behat-extension: v8.1.1
This package is not auto-updated.
Last update: 2022-02-01 12:44:39 UTC
README
目前仅支持JSON API来分析响应,但你可以使用REST部分对任何类型的API执行请求。
警告
从版本 7.0
开始,命名空间从 Rezzza
更改为 Ubirak
。
安装
将软件包作为开发依赖项要求
composer require --dev ubirak/rest-api-behat-extension
不要忘记在你的 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
然后你需要在你的composer中引入你想要使用的HTTP客户端和消息工厂。
示例
composer require --dev guzzlehttp/psr7 php-http/curl-client
使用方法
你可以直接使用 JsonContext
或 RestApiContext
,通过在您的 behat.yml
中加载它们,或者通过将它们添加到您自己的上下文构造中,使用 RestApiBrowser
和 JsonInspector
。
<?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; } }