elbformat / ibexa-behat-bundle
上下文和助手,用于在您的ibexa dxp安装中集成behat测试。
v1.1.4
2024-02-16 08:59 UTC
Requires
- php: >=8.1
- elbformat/field-helper-bundle: ^1.2
- elbformat/symfony-behat-bundle: ^1.5
- ibexa/experience: ^3.3
Requires (Dev)
- dvdoug/behat-code-coverage: ^5.2
- netgen/tagsbundle: ^5.0
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-09-16 10:20:31 UTC
README
尽管已经存在一个官方的behat bundle用于ibexa,但这个bundle采用了完全不同的方法。它通过直接使用Symfony Kernel进行优化,以实现更快的执行速度,并且仅部分重置数据库。此外,它在行为方面有更严格的规定。最后但同样重要的是,它还支持创建页面构建器块。
安装
- 通过composer添加bundle
composer require elbformat/ibexa-behat-bundle
- 在
config/bundles.php
中激活bundle
Elbformat\SymfonyBehatBundle\ElbformatSymfonyBehatBundle::class => ['test' => true], Elbformat\IbexaBehatBundle\ElbformatIbexaBehatBundle::class => ['test' => true],
-
配置behat.yml 请参阅symfony-behat-bundle安装说明。
-
使用TestFilePathNormalizer 为了测试上传的图片,您需要一个可预测的文件名。在运行测试时,可以通过跳过末尾的随机哈希来实现。只需在您的
config/services_behat.yaml
中添加以下行即可
services: # Prevent random character in image urls for tests eZ\Publish\Core\IO\FilePathNormalizer\Flysystem: '@Elbformat\IbexaBehatBundle\IO\TestFilePathNormalizer'
运行测试
请确保您已为测试环境配置了数据库。建议在.env.test
中为测试配置一个额外的数据库,以避免意外删除真实内容。配置后,在运行任何测试之前,您应初始化它一次。
bin/console -e test do:da:cr bin/console -e test do:mi:mi -n bin/console -e test ib:mi:mi -n bin/console -e test ibexa:reindex
然后您可以简单地运行测试。
vendor/bin/behat
调整
当您有内部、固定的内容/位置ID > 1000时,您可能希望更改重置数据库的最小ID。为此,您可以在.env.behat
中添加一个环境变量BEHAT_CONTENT_MIN_ID=10000
。