Skip to content

Commit

Permalink
Run tests in wp-env
Browse files Browse the repository at this point in the history
  • Loading branch information
psrpinto committed Feb 13, 2024
1 parent 5f8463e commit 4af299e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
9 changes: 9 additions & 0 deletions bin/run-tests.sh
Original file line number Diff line number Diff line change
@@ -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 .
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

0 comments on commit 4af299e

Please sign in to comment.