diff --git a/README.md b/README.md index fc14f9f78..e4f61bf4d 100644 --- a/README.md +++ b/README.md @@ -30,3 +30,13 @@ If you are not using `wp-env`, you need to add the tables to the database of you ```shell wp db query < schema.sql ``` + +### Tests + +You can run tests in `wp-env` with the following command: + +> Note that `wp-env` must be running. + +```shell +composer dev:test +``` diff --git a/bin/run-tests.sh b/bin/run-tests.sh new file mode 100755 index 000000000..4c63cd959 --- /dev/null +++ b/bin/run-tests.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# This is only for use in development environments, it's not used in CI. +# You can call this with: composer dev:test + +set -ex + +wp-env run tests-cli --env-cwd=wp-content/plugins/wporg-gp-translation-events sh -c 'wp db query < schema.sql' +wp-env run tests-cli --env-cwd=wp-content/plugins/wporg-gp-translation-events ./vendor/bin/phpunit . diff --git a/composer.json b/composer.json index 66a9e4408..5e5155971 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,7 @@ "dev:start": "wp-env start --debug && wp-env run cli wp rewrite structure '/%postname%/'", "dev:debug": "wp-env start --xdebug", "dev:stop": "wp-env stop", - "dev:db:schema": "wp-env run cli sh -c 'wp db query < /var/www/html/wp-content/plugins/wporg-gp-translation-events/schema.sql'" + "dev:db:schema": "wp-env run cli --env-cwd=wp-content/plugins/wporg-gp-translation-events sh -c 'wp db query < schema.sql'", + "dev:test": "bin/run-tests.sh" } }