spyl / cool-contexts
为 Behat 准备的一些酷炫场景
dev-master
2015-06-09 13:40 UTC
Requires
- behat/behat: ~3.0
- behat/mink: ~1.6@dev
- behat/mink-browserkit-driver: @dev
- behat/mink-extension: ~2.0
- behat/mink-selenium2-driver: @dev
- behat/symfony2-extension: ~2.0@dev
- coduo/php-matcher: 1.1.*
- doctrine/data-fixtures: ~1.0
- doctrine/inflector: ~1.0
- fzaninotto/faker: ~1.0
- guzzle/guzzle: ~3.7
- guzzlehttp/guzzle: ~4.0
- nelmio/alice: ~1.0
- phpunit/phpunit: 4.4.*@dev
- symfony/property-access: ~2.0
This package is auto-updated.
Last update: 2024-09-17 10:30:02 UTC
README
由于我在每个项目中都使用这些场景,我认为将它们放在一个单独的仓库中会很好...
这就是它们: CoolContexts !
它们与我的项目高度耦合,但你可以从中找到一些灵感。请善待它们,创造出酷炫的东西 ;-)
快速开始
使用 composer 安装 CoolContexts
composer require spyl/cool-contexts
场景
- DefaultContext:在 KernelAwareContext 的基础上添加一些辅助方法
- DoctrineFixturesContext:在测试套件之前和每个 @database 标签之后加载你的数据集
- WebApiContext:用于测试你的(REST)APIs的有用步骤
- CommandContext:用于测试你的命令的有用步骤 ;)
配置
编辑 behat.yml
default: # ... suites: api: # ... contexts: - Spyl\CoolContexts\WebApiContext - # ... commands: # ... contexts: - Spyl\CoolContexts\CommandContext
示例
# features/api/login.features Feature: Login Restful Api As an API client I want to be able to login So I can access the application Scenario: Anonymous API client wants to login Given I send a POST request to "/login_check" with body: """ { "username": "user", "password": "userpass" } """ Then the JSON response should match: """ { "token": @string@, "user": { "username": "user" } } """
# features/commands/instances.feature @database Scenario: Anonymous user wants to create an instance coucou.fr Given I run "instance:create coucou coucou.fr" Then the command exit code should be 0 And I should see "Instance coucou has been created !"
信息
如果你需要添加自定义步骤,你可以轻松地扩展它们,如果你认为你的更改对每个人都有用,请随时向我发送 PR!
由 @spyl94 用爱构建。