elbformat / sulu-behat-bundle
上下文和辅助工具,用于将 behat 测试集成到您的 sulu 应用程序中
v1.1.0
2023-11-22 06:34 UTC
Requires
- php: >=8.1
- ext-dom: *
- ext-json: *
- behat/behat: ^3.8
- elbformat/symfony-behat-bundle: ^1.5
- friends-of-behat/symfony-extension: ^2.2
- sulu/sulu: ^2.4
- symfony/event-dispatcher: 5.4.*
Requires (Dev)
- dvdoug/behat-code-coverage: ^5.2
- friendsofphp/php-cs-fixer: ^3.3
- handcraftedinthealps/elasticsearch-bundle: 5.2.6.9
- jackalope/jackalope: ^1.4
- jackalope/jackalope-doctrine-dbal: ^1.7
- phpunit/phpunit: ^9.5
- sulu/article-bundle: ^2.3
- sulu/sulu-form-bundle: ^2.4
- symfony/mailer: 5.4.*
- symfony/monolog-bridge: 5.4.*
- symfony/monolog-bundle: ^3.8
- symfony/runtime: 5.4.*
- vimeo/psalm: ^4.13
- dev-main
- v1.1.0
- v1.0.1
- v1.0.0
- dev-renovate/docker-login-action-digest
- dev-renovate/docker.elastic.co-elasticsearch-elasticsearch-7.x
- dev-renovate/docker.elastic.co-elasticsearch-elasticsearch-8.x
- dev-renovate/mariadb-11.x
- dev-renovate/docker-build-push-action-digest
- dev-renovate/major-symfony
- dev-renovate/codecov-3.x
- dev-v1.1-sf6
- dev-v1.1-sf6.2
- dev-renovate/vimeo-psalm-5.x
- dev-renovate/mariadb-10.x
- dev-renovate/hgiesenow-php-8.x
- dev-fix_non_existent_references
- dev-remove-final
- dev-bundle-setup
This package is auto-updated.
Last update: 2024-09-14 05:40:49 UTC
README
添加上下文和辅助工具,以便轻松设置 sulu 应用程序中的 behat 测试。它使用了 symfony-behat-bundle。
安装
- 通过 composer 添加包
composer require elbformat/sulu-behat-bundle
- 在
config/bundles.php
中激活包
Elbformat\SymfonyBehatBundle\ElbformatSymfonyBehatBundle::class => ['test' => true], Elbformat\SuluBehatBundle\ElbformatSuluBehatBundle::class => ['test' => true],
- 配置 behat 扩展
将扩展添加到您的 behat.yml
。使用 context
参数,您可以决定 sulu 内核是否在 website
或 admin
(默认)上下文中运行。建议使用标签将功能分类到不同的测试套件中。同时确保 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/ 文件夹 中找到。
推荐包
某些上下文只能在安装相应的包时启用。
- SuluArticleContext 需要 SuluArticleBundle
- SuluFormContext 需要 SuluFormBundle
接下来是什么?
下一个版本可能的改进包括
- SuluCommunityContext for SuluCommunityBundle
- 更多具有更多内容类型的示例