filipgolonka / symfony-behat-debug-bundle
0.3
2017-11-28 13:01 UTC
Requires
- phpspec/phpspec: ^2.2|^3.0|^4.0
- symfony/config: ^2.3|^3.0
- symfony/dependency-injection: ^2.3|^3.0
- symfony/http-kernel: ^2.3|^3.0
This package is not auto-updated.
Last update: 2024-09-14 19:36:41 UTC
README
在 Symfony 和 PhpSpec 之间建立桥梁,为 Symfony DI 容器添加 PhpSpec 格式化器。
使用方法
- 将包添加到应用程序依赖中
composer require --dev filipgolonka/symfony-behat-debug-bundle
- 在您的
AppKernel
中启用包
// app/AppKernel.php
class AppKernel extends Kernel
{
public function registerBundles()
{
if ($this->getEnvironment == 'test') {
$bundles = array(
// ...
new FilipGolonka\SymfonyBehatDebugBundle\FilipGolonkaSymfonyBehatDebugBundle(),
);
// ...
}
}
}
- 将服务配置文件导入到您的应用程序中
// app/config/services.yml
imports:
- { resource: "@FilipGolonkaSymfonyBehatDebugBundle/Resources/config/services.yml" }
- 只需在您的 behat 上下文中使用它即可
<?php
namespace AppBundle;
use Behat\Symfony2Extension\Context\KernelAwareContext;
use Behat\Symfony2Extension\Context\KernelDictionary;
class DataContext implements KernelAwareContext
{
use KernelDictionary;
/**
* @Then test difference formatting
*/
public function testDifferenceFormatting()
{
$expectedContent = ['foo' => 'bar'];
$actualContent = ['baz' => 'bat'];
if ($expectedContent != $actualContent) {
throw new \Exception(
$this->getContainer()->get('behat_debug.formatter')->format(
$this->getContainer()->get('behat_debug.differ')->compare($expectedContent, $actualContent)
)
);
}
}
}