Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ tests
.phpunit.result.cache
.typos.toml
.wp-env.json
.wp-env.tests.json
.wp-env.override.json
.wp-env.tests.override.json
behat.yml
codecov.yml
composer.lock
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/.nvmrc export-ignore
/.typos.toml export-ignore
/.wp-env.json export-ignore
/.wp-env.tests.json export-ignore
/composer.lock export-ignore
/package.json export-ignore
/package-lock.json export-ignore
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/php-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- '.github/workflows/php-test.yml'
- '**.php'
- '.wp-env.json'
- '.wp-env.tests.json'
- '**/package.json'
- 'package-lock.json'
- 'phpcs-rulesets/*.xml'
Expand All @@ -26,6 +27,7 @@ on:
- '.github/workflows/php-test.yml'
- '**.php'
- '.wp-env.json'
- '.wp-env.tests.json'
- '**/package.json'
- 'package-lock.json'
- 'phpcs-rulesets/*.xml'
Expand Down Expand Up @@ -91,9 +93,9 @@ jobs:
- name: Start WordPress
run: |
if [[ ${{ matrix.coverage == true }} == true ]]; then
npm run wp-env start -- --xdebug=coverage
npm run wp-env start -- --config=.wp-env.tests.json --xdebug=coverage
else
npm run wp-env start
npm run wp-env start -- --config=.wp-env.tests.json
fi

- name: Run tests
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ temp/
############

.wp-env.override.json
.wp-env.tests.override.json
13 changes: 5 additions & 8 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"core": null,
"plugins": [ "." ],
"env": {
"tests": {
"phpVersion": "7.4"
}
}
}
"$schema": "https://schemas.wp.org/trunk/wp-env.json",
"core": null,
"plugins": [ "." ],
"testsEnvironment": false
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.wp-env.json uses tab indentation, but .editorconfig specifies indent_style = space and indent_size = 2 for *.json. Please reformat this JSON to match the repository’s formatting rules to avoid churn in future diffs.

Suggested change
"$schema": "https://schemas.wp.org/trunk/wp-env.json",
"core": null,
"plugins": [ "." ],
"testsEnvironment": false
"$schema": "https://schemas.wp.org/trunk/wp-env.json",
"core": null,
"plugins": [ "." ],
"testsEnvironment": false

Copilot uses AI. Check for mistakes.
}
8 changes: 8 additions & 0 deletions .wp-env.tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://schemas.wp.org/trunk/wp-env.json",
"core": null,
"plugins": [ "." ],
"testsEnvironment": false,
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new .wp-env.tests.json still sets testsEnvironment: false, but the wp-env warning (and issue linked in the PR) indicates testsEnvironment itself is deprecated. If this flag isn’t required for the separate tests config, drop it to avoid relying on an option slated for removal.

Suggested change
"testsEnvironment": false,

Copilot uses AI. Check for mistakes.
"phpVersion": "7.4",
"port": 8889
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.wp-env.tests.json uses tab indentation, but .editorconfig enforces 2-space indentation for *.json. Please reformat this file accordingly to keep JSON formatting consistent across the repo.

Suggested change
"$schema": "https://schemas.wp.org/trunk/wp-env.json",
"core": null,
"plugins": [ "." ],
"testsEnvironment": false,
"phpVersion": "7.4",
"port": 8889
"$schema": "https://schemas.wp.org/trunk/wp-env.json",
"core": null,
"plugins": [ "." ],
"testsEnvironment": false,
"phpVersion": "7.4",
"port": 8889

Copilot uses AI. Check for mistakes.
}
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,23 @@ npm install

With the above commands, you can use the plugin in any development environment as you like. The recommended way is to use the built-in development environment, which is based on the [`@wordpress/env` package](https://www.npmjs.com/package/@wordpress/env), as that will allow you to use the preconfigured commands to e.g. run unit tests, linting etc. You will need to have Docker installed to use this environment.

You can start the built-in environment as follows:
Start the **development** site:

```
npm run wp-env start
```

If you want to stop the environment again, you can use:
Start the **tests** stack:

```
npm run wp-env:start:tests
```

Stop each stack when finished:

```
npm run wp-env stop
npm run wp-env:stop:tests
```

For further information on contributing, please see the [contributing guide](/CONTRIBUTING.md).
Expand Down
8 changes: 4 additions & 4 deletions docs/running-unit-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Follow these instructions to configure and run tests:

1. You would need npm installed in your computer.
2. Ensure that you have installed all npm dependencies with `npm ci`.
3. You need to have Docker installed and running wp-env environment `npm run wp-env start`.
3. You need Docker installed. Start the tests wp-env stack with `npm run wp-env:start:tests`.
4. Run tests with npm command `npm run test-php`.

The full test suite is run against PRs as a GitHub action ([example](https://github.com/WordPress/plugin-check/actions/runs/9660204610)) so tests can be run against all supported environments. Passing tests is a requirement for merging PRs. Being able to run them locally is meant to help developers while working on or debugging tests, prior to submitting their code for review.
Expand All @@ -18,8 +18,8 @@ The full test suite is run against PRs as a GitHub action ([example](https://git
We have this structure for the tests folder:

- `tests/phpunit` Unit tests for the plugin.
- `tests/phpunit/tests/` All PHPUnit tests that run as part of the suite.
- `tests/phpunit/testdata/` Example classes or plugins that can be used in tests.
- `tests/phpunit/utils/` Shared helpers that can be used across different test classes.
- `tests/phpunit/tests/` All PHPUnit tests that run as part of the suite.
- `tests/phpunit/testdata/` Example classes or plugins that can be used in tests.
- `tests/phpunit/utils/` Shared helpers that can be used across different test classes.

Ensure that you create your check and unit test at same time.
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@
},
"scripts": {
"wp-env": "wp-env",
"wp-env:start:tests": "wp-env start --config=.wp-env.tests.json",
"wp-env:stop:tests": "wp-env stop --config=.wp-env.tests.json",
"lint-js": "wp-scripts lint-js",
"format-js": "npm run lint-js -- --fix",
"lint-gherkin": "gherkin-lint",
"phpstan": "wp-env run tests-cli --env-cwd=wp-content/plugins/$(basename \"$(pwd)\")/ composer run-script phpstan",
"lint-php": "wp-env run tests-cli --env-cwd=wp-content/plugins/$(basename \"$(pwd)\")/ composer run-script lint",
"format-php": "wp-env run tests-cli --env-cwd=wp-content/plugins/$(basename \"$(pwd)\")/ composer run-script format",
"test-php": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename \"$(pwd)\") vendor/bin/phpunit -c phpunit.xml.dist",
"test-php-coverage": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename \"$(pwd)\") vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover build/logs/php-coverage.xml",
"test-php-multisite": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename \"$(pwd)\") vendor/bin/phpunit -c tests/phpunit/multisite.xml",
"test-php-multisite-coverage": "wp-env run tests-cli --env-cwd=/var/www/html/wp-content/plugins/$(basename \"$(pwd)\") vendor/bin/phpunit -c tests/phpunit/multisite.xml --coverage-clover build/logs/php-coverage-multisite.xml"
"phpstan": "wp-env --config=.wp-env.tests.json run cli --env-cwd=wp-content/plugins/$(basename \"$(pwd)\")/ composer run-script phpstan",
"lint-php": "wp-env --config=.wp-env.tests.json run cli --env-cwd=wp-content/plugins/$(basename \"$(pwd)\")/ composer run-script lint",
"format-php": "wp-env --config=.wp-env.tests.json run cli --env-cwd=wp-content/plugins/$(basename \"$(pwd)\")/ composer run-script format",
"test-php": "wp-env --config=.wp-env.tests.json run cli --env-cwd=/var/www/html/wp-content/plugins/$(basename \"$(pwd)\") vendor/bin/phpunit -c phpunit.xml.dist",
"test-php-coverage": "wp-env --config=.wp-env.tests.json run cli --env-cwd=/var/www/html/wp-content/plugins/$(basename \"$(pwd)\") vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover build/logs/php-coverage.xml",
"test-php-multisite": "wp-env --config=.wp-env.tests.json run cli --env-cwd=/var/www/html/wp-content/plugins/$(basename \"$(pwd)\") vendor/bin/phpunit -c tests/phpunit/multisite.xml",
"test-php-multisite-coverage": "wp-env --config=.wp-env.tests.json run cli --env-cwd=/var/www/html/wp-content/plugins/$(basename \"$(pwd)\") vendor/bin/phpunit -c tests/phpunit/multisite.xml --coverage-clover build/logs/php-coverage-multisite.xml"
}
}
Loading