chapabu / codeception-module-drupal
Codeception 的一个模块,它将 Drupal API 暴露给测试套件。
Requires
Requires (Dev)
- mikey179/vfsstream: 1.4.*
- phpspec/prophecy: ~1.3@dev
- satooshi/php-coveralls: dev-master
- squizlabs/php_codesniffer: 2.1.0
Suggests
- chriscohen/codeception-drupal-content-types: A Codeception module to provide Drupal content types support.
- chriscohen/codeception-drupal-pages: A Codeception module to provide standard Drupal page objects.
- pfaocle/codeception-module-drupal-user-registry: A Codeception module for managing test users.
This package is not auto-updated.
Last update: 2024-09-28 18:10:30 UTC
README
本模块旨在允许测试在测试期间使用 Drupal API。这允许您对 Drupal 网站进行更好的功能测试。
它还使得使用 Drupal 进行测试驱动开发变得容易得多,因为您可以通过 UI 创建的项进行断言。
安装
$ composer require chapabu/codeception-module-drupal --dev
用法
在您的 *.suite.yml 文件中,将 Drupal 添加到已启用的模块列表中。
示例配置
这将假设您的 Drupal 安装在 drupal 子目录下运行测试。
class_name: AcceptanceTester modules: enabled: \Codeception\Module\Drupal7\Drupal7: root: 'drupal' relative: yes
选项
root
接受: string 默认: 当前工作目录
这定义了与 codecept.yml 文件相关的 Drupal 根目录。如果没有传入,则默认为当前工作目录。
relative
接受: yes 或 no 默认: no
这允许您指定 drupal 根目录的路径是否相对于 codeception.yml 文件。接受 yes 或 no。
贡献
编码规范
请确保所有代码尽可能遵循 PSR-2 标准(除 Codeception 方法外,如 _initialize 不遵循此规范)
测试不需要严格遵循 PSR-2,但应遵循当前测试中规定的标准(即测试方法命名不遵循 PSR-2,但在这种情况下更有用)。
测试
所有贡献都应附带相关的单元测试,如套件中的其他测试。例如,请查看 tests 目录。
运行测试 - Linux/OSX
要设置测试,请运行 $ composer testinit,然后运行 $ vendor/bin/codecept run 或如果您已在系统范围内安装了 Codeception,则简单运行 $ codecept run。
testinit.sh 脚本假设您已全局安装了 Drush。这将使用 root 用户名和一个空密码通过 MySQL 数据库安装 Drupal。如果您需要修改此文件,请随意修改,但请确保不要将其提交回去。
运行测试 - Windows
如果您想在 Windows 上进行贡献,只需使用命令行运行 testinit.sh 脚本中包含的命令即可。
许可协议
该项目采用 MIT 许可证 (MIT)。