wpdesk / wp-codeception
WP Desk Codeception 测试库。
Requires
- php: >=7.2|^8
- composer-plugin-api: ^1.1|^2
- ext-json: *
- albertofem/rsync-lib: ^1.0
- codeception/module-asserts: ^1.3.1
- codeception/module-cli: ^1.1.1
- codeception/module-db: ^1.2
- codeception/module-filesystem: ^1.0.3
- codeception/module-phpbrowser: ^1.0.3
- codeception/module-rest: ^1.4.2
- codeception/module-webdriver: ^1.4.1
- codeception/util-universalframework: ^1.0
- lucatume/codeception-steppify: ^1.0.6
- lucatume/wp-browser: <3.5
- symfony/yaml: ^5
- vlucas/phpdotenv: ^4
- wp-cli/admin-command: ^2.0.2
- wp-cli/wp-cli-bundle: ^2.7.1
Requires (Dev)
- 10up/wp_mock: *
- dev-master
- 2.11.13
- 2.11.12
- 2.11.11
- 2.11.10
- 2.11.9
- 2.11.8
- 2.11.7
- 2.11.6
- 2.11.5
- 2.11.5-beta2
- 2.11.5-beta1
- 2.11.4
- 2.11.3
- 2.11.2
- 2.11.1
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.6
- 2.8.6-beta3
- 2.8.6-beta2
- 2.8.6-beta1
- 2.8.5
- 2.8.4
- 2.8.3
- 2.8.2
- 2.8.1
- 2.8.0
- 2.8.0-beta.1
- 2.7.10
- 2.7.9
- 2.7.8
- 2.7.7
- 2.7.7-beta1
- 2.7.6
- 2.7.5
- 2.7.4
- 2.7.4-beta1
- 2.7.3
- 2.7.2
- 2.7.1
- 2.7.0-beta2
- 2.7.0-beta1
- 2.6.6
- 2.6.5
- 2.6.4
- 2.6.3
- 2.6.3-beta1
- 2.6.2
- 2.6.2-beta2
- 2.6.2-beta1
- 2.6.1
- 2.6.0
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5.0
- 2.5.0-beta5
- 2.5.0-beta4
- 2.5.0-beta3
- 2.5.0-beta2
- 2.5.0-beta1
- 2.4.5
- 2.4.4
- 2.4.3
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.3.0-beta2
- 2.3.0-beta1
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.1
- 2.0.0
- 2.0.0-beta27
- 2.0.0-beta26
- 2.0.0-beta25
- 2.0.0-beta24
- 2.0.0-beta23
- 2.0.0-beta22
- 2.0.0-beta21
- 2.0.0-beta20
- 2.0.0-beta19
- 2.0.0-beta18
- 2.0.0-beta17
- 2.0.0-beta16
- 2.0.0-beta15
- 2.0.0-beta14
- 2.0.0-beta13
- 2.0.0-beta12
- 2.0.0-beta11
- 2.0.0-beta10
- 2.0.0-beta9
- 2.0.0-beta8
- 2.0.0-beta7
- 2.0.0-beta6
- 2.0.0-beta5
- 2.0.0-beta4
- 2.0.0-beta3
- 2.0.0-beta2
- 2.0.0-beta1
- 1.11.0
- 1.10.5
- 1.10.4
- 1.10.3
- 1.10.2
- 1.10.1
- 1.10.0
- 1.10.0-beta1
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.0
- 1.7.0-beta4
- 1.7.0-beta3
- 1.7.0-beta2
- 1.7.0-beta1
- 1.6.6
- 1.6.5
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.25
- 1.5.24
- 1.5.24-beta4
- 1.5.24-beta3
- 1.5.24-beta2
- 1.5.24-beta1
- 1.5.23
- 1.5.22
- 1.5.21
- 1.5.20
- 1.5.19
- 1.5.18
- 1.5.17
- 1.5.16
- 1.5.16-beta1
- 1.5.15
- 1.5.14
- 1.5.13
- 1.5.12
- 1.5.11
- 1.5.10
- 1.5.9
- 1.5.8
- 1.5.7
- 1.5.6
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.5.0-beta2
- 1.5.0-beta1
- 1.4.19
- 1.4.19-beta7
- 1.4.19-beta6
- 1.4.19-beta5
- 1.4.19-beta4
- 1.4.19-beta3
- 1.4.19-beta2
- 1.4.19-beta1
- 1.4.18
- 1.4.18-beta1
- 1.4.17
- 1.4.17-beta1
- 1.4.16
- 1.4.15
- 1.4.15-beta1
- 1.4.11
- 1.4.11-beta1
- 1.4.10
- 1.4.10-beta1
- 1.4.9
- 1.4.8
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.0
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.13
- 1.1.12
- 1.1.10
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0
- dev-bugfix/add-shipping-method
- dev-feature/checkout-block
- dev-feat/skip-wp-content
- dev-fix/make-order-double-test
- dev-fix/checkout-block
- dev-update-theme-reference
- dev-feature/checkout-block-trait
- dev-feature/ci-test
- dev-feature/spped-up-local-tests
- dev-bugfix/return-value
- dev-feature/php-versions
- dev-feature/fast
- dev-feature/local-testing
- dev-feature/composer-2
- dev-feature/apigen
- dev-feature/cache-wordpress
- dev-feature/more-waits
- dev-feature/empty-cart
This package is auto-updated.
Last update: 2024-08-26 18:44:52 UTC
README
Codeception 测试库。
PHP 文档
https://wpdesk.gitlab.io/wp-codeception/index.html
安装
composer require --dev wpdesk/wp-codeception
用法
创建 codeception 测试
composer create-codeception-tests
此命令将创建 codeception 所需的所有文件夹和文件。
此外,还将创建带有 WP Desk 插件激活的示例测试:tests/codeception/tests/acceptance/ActivationCest.php
所需更改
- 在文件
tests/codeception/bootstrap.sh
中更改WPDESK_PLUGIN_SLUG
变量的值
运行测试
运行所有测试: composer run-codeception-tests
运行单个测试(整个类): composer run-codeception-tests ClassNameCest
(例如:composer run-codeception-tests WooCommerceCest
)
运行单个测试(单个方法): composer run-codeception-tests ClassNameCest:methodName
(例如:composer run-codeception-tests WooCommerceCest:makeOrder
)
运行所有测试,不关闭 docker-compose: composer run-codeception-tests all fast
运行单个测试(整个类)并不要关闭 docker-compose: composer run-codeception-tests ClassNameCest fast
(例如:composer run-codeception-tests WooCommerceCest fast
)
运行单个测试(单个方法)并不要关闭 docker-compose: composer run-codeception-tests ClassNameCest:methodName fast
(例如:composer run-codeception-tests WooCommerceCest:makeOrder fast
)
将 WooCommerce 版本传递给测试: composer run-codeception-tests all slow 3.7.0-beta.1
或 composer run-codeception-tests all fast 3.7.0-beta.1
或 composer run-codeception-tests ClassNameCest fast 3.7.0-beta.1
运行本地测试 - 不使用 docker
要求
mysql
创建数据库
wptest
。创建用户
mysql
,密码为mysql
。
apache
虚拟主机
wptests
,根目录为/tmp/wptests
chromedriver
在 mac 上:
brew install chromedriver
如果测试不正常,请将 chromedriver 复制到 /usr/local/bin
selenium-server
在 mac 上:
brew install selenium-server-standalone
并启动 selenium 服务器。
hosts
添加到
/etc/hosts
:127.0.0.1 wptests mysqltests chrome
运行
composer run-local-codeception-tests
编写测试
验收测试: https://codeception.com/docs/03-AcceptanceTests
推荐测试格式 - Cest: https://codeception.com/docs/07-AdvancedUsage
WordPress 和 codeception: https://codeception.com/for/wordpress
WebDriver(动作): https://codeception.com/docs/modules/WebDriver
扩展 wp-codeception 库
我们在 TesterWordpressActions 和 TesterWooCommerceActions 特性中拥有自定义的 Tester Actions。所有动作都应该添加到那里。
TesterWordpressActions 和 TesterWooCommerceActions 特性用于由 codeception 生成的 AcceptanceTester 类。
其他 WP Desk 插件
当插件使用其他插件并且这些插件在 WordPress 存储库中时,我们可以在 bootstrap.sh 中从存储库中安装它们。
当我们想要使用来自 wpdesk gitlab 的插件时,我们可以使用 prepare.sh 脚本。flexible-shipping-pro 插件中有示例用法。检查 flexible-shipping-pro/tests/codeception/prepare.sh.dist 文件。
提示
如果出现 unexpected alert open: {Alert text : }
,请将以下内容添加到 acceptance.suite.yml 中的 WPWebDriver
配置部分
capabilities:
unexpectedAlertBehaviour: "accept"
开发
在执行git checkout后运行的命令
运行 vendor/bin/codecept bootstrap tests/codeception
运行 vendor/bin/codecept build