macpaw/behat-messenger-context

用于测试 Symfony Messenger 组件的 Behat 上下文

安装次数: 100,555

依赖项: 0

建议者: 0

安全: 0

星标: 16

关注者: 8

分支: 2

公开问题: 0

类型:symfony-bundle

v3.0.1 2024-01-11 15:21 UTC

This package is auto-updated.

Last update: 2024-09-11 16:42:04 UTC


README

安装

步骤 1: 下载 Bundle

打开命令行控制台,进入您的项目目录并执行

使用 Symfony Flex 的应用程序进行中

$ composer require --dev macpaw/behat-messenger-context

不使用 Symfony Flex 的应用程序

打开命令行控制台,进入您的项目目录并执行以下命令以下载此 Bundle 的最新稳定版本

$ composer require --dev macpaw/behat-messenger-context

此命令要求您全局安装 Composer,如 Composer 文档中的安装章节中所述。

然后,通过将 Bundle 添加到项目中 app/AppKernel.php 文件中注册的 Bundle 列表中启用该 Bundle

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            BehatMessengerContext\BehatMessengerContextBundle::class => ['test' => true],
        );

        // ...
    }

    // ...
}

步骤 2: 配置 Messenger

config/packages/dev/messenger.yaml 复制并粘贴到 config/packages/test/。这为我们提供了只在测试环境中使用的 Messenger 配置。取消注释代码,并将同步替换为内存。为两种传输都这样做。

framework:
    messenger:
        transports:
            async: 'in-memory://'
            async_priority_high: 'in-memory://'
            ...
...

步骤 3: 配置 Behat

转到 behat.yml

...
  contexts:
    - BehatMessengerContext\Context\MessengerContext
...