kix/behat-sf2-service-generator
最新稳定版本:0.1.0
Composer 安装命令:
composer require kix/behat-sf2-service-generator
包简介
Behat Symfony2 service generator
README 文档
README
This is a Behat extension that catches calls to undefined Symfony services and runs PHPSpec to describe them.
Installation
Just run this:
composer require kix/behat-sf2-service-generator "~0.1"
And then enable the extension in your behat.yml:
default:
# ...
extensions:
Kix\Symfony2ServiceExtension\Symfony2ServiceExtension: ~
Now, when you try to access a non-existent service, you'll be asked if you want to generate a class for it. A YAML config will be dumped on the console for your convinience, too. Here's a quick peek at what it looks like.
Feature: Generating Symfony services
Scenario: Creating a service when a ServiceNotFoundException is caught
When I run behat
And my step tries to get a service that doesn't exist
Then a shiny notification is displayed asking if I want to generate it
<?php
class FeatureContext implements Context, SnippetAcceptingContext
{
// Note I'm using Symfony2Extension here:
use \Behat\Symfony2Extension\Context\KernelDictionary;
/**
* Initializes context.
*
* Every scenario gets its own context instance.
* You can also pass arbitrary arguments to the
* context constructor through behat.yml.
*/
public function __construct()
{
}
/**
* @When I run behat
*/
public function iRunBehat()
{
// do nothing
}
/**
* @When my step tries to get a service that doesn't exist
*/
public function myStepTriesToGetAServiceThatDoesnTExist()
{
$this->getContainer()->get('my_bundle.kitten_provider');
}
}
And boom:
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-11-20