Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHPUnit tests for mu-plugins #204

Open
wants to merge 26 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0ab1c75
Add a CDNise mu-plugin.
dd32 Mar 1, 2022
68d17c7
Fix whitespace.
dd32 Mar 1, 2022
f198491
Use `parse_str()` instead of `preg_match()`.
dd32 Mar 1, 2022
12f0349
Remove the blocked handles, as the production CDN now serves appropri…
dd32 May 12, 2022
51fd6af
Load the CDN plugin.
dd32 May 12, 2022
1659734
Reformat coding style.
dd32 May 12, 2022
eb981f3
Change the resource matching to be based on domain, rather than subst…
dd32 May 12, 2022
43f6929
Switch to stripping the hostname / sub-site off rather than explicit …
dd32 May 12, 2022
7482031
Add PHPUnit bootstrapping
dd32 May 12, 2022
cd84e89
Install deps correctly.
dd32 May 12, 2022
dfd4901
Fix composer deps
dd32 May 12, 2022
90880be
Setup wp-env too
dd32 May 12, 2022
a1663b7
Fix typo in loader
dd32 May 12, 2022
63e1570
Merge branch 'add/cdn-plugin' into try/cdn-tests
dd32 May 12, 2022
8881d87
Update to gutenberg bootstrap
dd32 May 12, 2022
02c87a1
Add phpunit deps
dd32 May 12, 2022
631d34e
Set the WP_RUN_CORE_TESTS constant so that we can test the wp_environ…
dd32 May 12, 2022
bd11c69
Add tests for the CDN plugin
dd32 May 12, 2022
f9d18c2
Force phpunits config file not to be forced to local environment, to …
dd32 May 12, 2022
06519d4
Add more unit tests
dd32 May 12, 2022
9897577
Attempt to work around phpunit-wp-config.php permissions
dd32 May 12, 2022
e3ba1d5
Revert "Attempt to work around phpunit-wp-config.php permissions"
dd32 May 12, 2022
6b4cc86
Attempt to workaround wp-env permissions and limitations.
dd32 May 12, 2022
47a2afc
Simplify the phpunit bootstrapping
dd32 May 12, 2022
3a81eff
Move @wordpress/env to a devDep
dd32 May 12, 2022
f925a31
Revert composer/installers change.
dd32 May 16, 2022
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
29 changes: 29 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
branches: [ trunk, add/cdn-plugin, try/cdn-tests ]
pull_request:
branches: [ trunk ]

workflow_dispatch:

jobs:
run-tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install dependencies
run: |
npm install
composer install
npm run wp-env start
npm run build

- name: Run PHP unit tests
run: |
# Delete the default wp-env forced environment type
sed "/WP_ENVIRONMENT_TYPE/d" -i `npm run wp-env install-path 2>/dev/null | tail -n1`/tests-WordPress/phpunit-wp-config.php
npm run test:php
15 changes: 15 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"core": "WordPress/WordPress#master",
"mappings": {
"wp-content/mu-plugins": "./mu-plugins"
},
"env": {
"tests": {
"mappings": {
"vendor": "./vendor",
"phpunit": "./phpunit",
"phpunit.xml.dist": "./phpunit.xml.dist"
}
}
}
}
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
"composer/installers": "~1.0"
},
"require-dev": {
"wporg/wporg-repo-tools": "dev-trunk"
"phpunit/phpunit": "^9.5",
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm unsure if this is actually needed here, I suspect it's not, as it would only be needed if you're running phpunit outside of wp-env.

The below wp-phpunit & yoast deps are however required.

"wporg/wporg-repo-tools": "dev-trunk",
"wp-phpunit/wp-phpunit": "^5.9",
"yoast/phpunit-polyfills": "^1.0"
},
"config": {
"allow-plugins": {
Expand Down
Loading