wpdesk / wp-codeception
Library for WP Desk Codeception tests.
Requires
- php: >=7.4|^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.12.0
- 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-feature/languages
- 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-11-29 14:22:28 UTC
README
Library for Codeception tests.
PHP Documentation
https://wpdesk.gitlab.io/wp-codeception/index.html
Installation
composer require --dev wpdesk/wp-codeception
Usage
Create codeception tests
composer create-codeception-tests
This command creates all folders and files required by codeception.
Additionally creates example test with WP Desk plugin activation: tests/codeception/tests/acceptance/ActivationCest.php
Required changes:
- change value of
WPDESK_PLUGIN_SLUG
variable in file:tests/codeception/bootstrap.sh
Run tests
Run all tests:
composer run-codeception-tests
Run single test (whole class):
composer run-codeception-tests ClassNameCest
(example: composer run-codeception-tests WooCommerceCest
)
Run single test (single method):
composer run-codeception-tests ClassNameCest:methodName
(example: composer run-codeception-tests WooCommerceCest:makeOrder
)
Run all tests and do not shutdown docker-compose:
composer run-codeception-tests all fast
Run single test (whole class) and do not shutdown docker-compose:
composer run-codeception-tests ClassNameCest fast
(example: composer run-codeception-tests WooCommerceCest fast
)
Run single test (single method) and do not shutdown docker-compose:
composer run-codeception-tests ClassNameCest:methodName fast
(example: composer run-codeception-tests WooCommerceCest:makeOrder fast
)
Pass WooCommerce version to tests:
composer run-codeception-tests all slow 3.7.0-beta.1
or composer run-codeception-tests all fast 3.7.0-beta.1
or composer run-codeception-tests ClassNameCest fast 3.7.0-beta.1
Run local tests - without docker
Requirements
mysql
Create database
wptest
.Create user
mysql
with passwordmysql
.
apache
Virtual host
wptests
with root folder/tmp/wptests
chromedriver
On mac:
brew install chromedriver
If tests not working copy chromedriver to /usr/local/bin
selenium-server
On mac:
brew install selenium-server-standalone
and start selenium server.
hosts
Add to
/etc/hosts
:127.0.0.1 wptests mysqltests chrome
Run
composer run-local-codeception-tests
Writing tests
Acceptance tests: https://codeception.com/docs/03-AcceptanceTests
Recommended test format - Cest: https://codeception.com/docs/07-AdvancedUsage
Wordpress and codeception: https://codeception.com/for/wordpress
WebDriver (actions): https://codeception.com/docs/modules/WebDriver
Extending wp-codeception library
We have custom Tester Actions in TesterWordpressActions and TesterWooCommerceActions traits. All actions should be added there.
TesterWordpressActions and TesterWooCommerceActions traits are used in generated by codeception AcceptanceTester class.
Other WP Desk plugins
When plugin uses other plugins and that plugins are in WordPress repository we can install them from repository in bootstrap.sh.
When we want to use plugin from wpdesk gitlab we can use prepare.sh script. There are example usage in flexible-shipping-pro plugin. Check flexible-shipping-pro/tests/codeception/prepare.sh.dist file.
Tips
If there is unexpected alert open: {Alert text : }
add to acceptance.suite.yml in WPWebDriver
config section:
capabilities:
unexpectedAlertBehaviour: "accept"
Development
After git checkout run commands:
vendor/bin/codecept bootstrap tests/codeception
vendor/bin/codecept build