teaandcode/behat-guzzle-extension
Composer 安装命令:
composer require teaandcode/behat-guzzle-extension
包简介
Behat API extension using Guzzle Service Descriptions to functionally test API endpoints
README 文档
README
Guzzle extension for Behat is an integration layer between Behat 3.0+ and Guzzle 3.5+ and it provides:
- Additional services for Behat (
Guzzle). Behat\GuzzleExtension\Context\GuzzleAwareContextwhich providesGuzzleinstance for your contexts.- Base
Behat\GuzzleExtension\Context\GuzzleContextcontext which provides base step definitions and hooks for your contexts or subcontexts. Or it could be even used as context on its own.
Installation
Add to your project with Composer (dev)
php composer.phar require --dev teaandcode/behat-guzzle-extension
Configuration
The extension is designed to require very little configuration, the only two
fields it requires is a base_url and a service_descriptions file location.
The base_url is the root url containing either a host name or IP address of
the API you're writing tests for, just make sure it's a fully qualified URL
(the trailing slash is not required) e.g. http://127.0.0.1
The service_descriptions file location is required as the extension is
designed to make use of a Guzzle service descriptions file, this means that all
the endpoints and associated fields you want to test should be listed as JSON in
the file for the extension to work.
Follow the link provided here if you want to know more about how to use the Guzzle service descriptions file or take a look at the example Guzzle service descriptions file excerpt below.
Example configuration in behat.yml
default: extensions: Behat\GuzzleExtension: base_url: http://127.0.0.1 service_descriptions: %paths.base%/app/config/service.json suites: default: contexts: - Behat\GuzzleExtension\Context\GuzzleContext: users: test.user.1: B8E...1AF test.user.2: A6B...8E6
Example Guzzle service descriptions file
{
"name": "Travis API",
"operations": {
"GetReposBuilds": {
"httpMethod": "GET",
"uri": "repos/{slug}/builds",
"summary": "Gets the last build for repo",
"parameters": {
"slug": {
"location": "uri",
"description": "Repo slug from GitHub",
"required": true
},
"number": {
"location": "query"
}
}
}
}
}
Further configuration
As you might have seen in the example configuration above, it is possible to pass a list of usernames or e-mail addresses that can be associated with an HTTP header Authorization Bearer token, which means that you're able to test secure parts of your API. Just specify the GuzzleContext as shown above in the behat.yml file and provide and array of users utilising the username/e-mail address ad the key with the bearer token as the value.
Predefined steps
TO DO: In the meantime checkout the repo.feature file in the features directory and the docblocks above each of the methods in the GuzzleContext.php file in the src/Behat/GuzzleExtension/Context directory.
To do
- Add documentation
- Add language support
Copyright
Copyright (c) 2015 Dave Nash (knasher). See LICENSE for details.
Contributors
- Dave Nash knasher [lead developer]
- Other [awesome developers] (https://github.com/teaandcode/behat-guzzle-extension/graphs/contributors)
teaandcode/behat-guzzle-extension 适用场景与选型建议
teaandcode/behat-guzzle-extension 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17.72k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2015 年 02 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「curl」 「api」 「Behat」 「test」 「web」 「Guzzle」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 teaandcode/behat-guzzle-extension 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 teaandcode/behat-guzzle-extension 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 teaandcode/behat-guzzle-extension 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Behat Context for testing Symfony Api
A Behat Extension that allows custom bootstrapping
Environment processor and contexts autoloader
cURL and cURL based Soap-Client for PHP
Provides access to magento2 object manager from behat and allows to change magento config settings temporarly
Simple cURL wrapper
统计信息
- 总下载量: 17.72k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-16