elbformat/sulu-behat-bundle

上下文和辅助工具,用于将 behat 测试集成到您的 sulu 应用程序中

安装量: 1,380

依赖者: 0

推荐者: 0

安全性: 0

星级: 2

关注者: 2

分支: 1

开放性问题: 11

类型:symfony-bundle


README

添加上下文和辅助工具,以便轻松设置 sulu 应用程序中的 behat 测试。它使用了 symfony-behat-bundle

安装

  1. 通过 composer 添加包
composer require elbformat/sulu-behat-bundle
  1. config/bundles.php 中激活包
Elbformat\SymfonyBehatBundle\ElbformatSymfonyBehatBundle::class => ['test' => true],
Elbformat\SuluBehatBundle\ElbformatSuluBehatBundle::class => ['test' => true],
  1. 配置 behat 扩展

将扩展添加到您的 behat.yml。使用 context 参数,您可以决定 sulu 内核是否在 websiteadmin(默认)上下文中运行。建议使用标签将功能分类到不同的测试套件中。同时确保 symfony 扩展 已启用并配置。

注意: FriendsOfBehat\SymfonyExtension 必须放在 之前SuluExtension

然后您可以按需添加上下文。

default:
  suites:
    default:
      filters:
        tags: '~@admin'
      contexts:
        - Elbformat\SymfonyBehatBundle\Context\CommandContext:
        - Elbformat\SymfonyBehatBundle\Context\LoggingContext:
        - Elbformat\SuluBehatBundle\Context\BrowserContext:
        - Elbformat\SuluBehatBundle\Context\DateContext:
        - Elbformat\SuluBehatBundle\Context\SuluPageContext:
        - Elbformat\SuluBehatBundle\Context\SuluSnippetContext:
        - Elbformat\SuluBehatBundle\Context\SuluMediaContext:
        # Only enable, when you have the according bundle installed
        #- Elbformat\SuluBehatBundle\Context\SuluArticleContext:
        #- Elbformat\SuluBehatBundle\Context\SuluFormContext:
  extensions:
    FriendsOfBehat\SymfonyExtension: ~
    Elbformat\SuluBehatBundle\SuluExtension:
      context: website
admin:
  suites:
    default:
      filters:
        tags: '@admin'
  extensions:
    FriendsOfBehat\SymfonyExtension:
      bootstrap: 'tests/bootstrap.php'
    Elbformat\SuluBehatBundle\SuluExtension:
      context: admin

运行测试

确保您已为测试环境配置了数据库。建议在 .env.test 中配置额外的数据库用于测试,以避免意外删除真实内容。配置后,应在运行任何测试之前初始化它一次。

bin/console -e test sulu:build prod

然后您可以在默认的 admin 配置下运行测试。

vendor/bin/behat
vendor/bin/behat --profile admin

示例

首先,您应该查看 symfony 示例。更多与 sulu 相关的示例可以在 features/ 文件夹 中找到。

推荐包

某些上下文只能在安装相应的包时启用。

接下来是什么?

下一个版本可能的改进包括

  • SuluCommunityContext for SuluCommunityBundle
  • 更多具有更多内容类型的示例