-
Notifications
You must be signed in to change notification settings - Fork 162
Complete PHPUnit infrastructure for out-of-the-box local and CI testing, including initial tests #29
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
Merged
Merged
Complete PHPUnit infrastructure for out-of-the-box local and CI testing, including initial tests #29
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d2e9cb3
Scaffold PHPUnit infrastructure using wp-env.
49f14d2
Complete basic PHPUnit test infrastructure.
35b7dc3
Add tests for load.php functions and enhance setting sanitization.
44cdea3
Add php-test GitHub action.
5a8a5c2
Make PHPUnit bootstrap script more flexible and ensure Composer depen…
d98b4ea
Merge branch 'trunk' into add/phpunit-infrastructure
6fad3e4
Outline requirement for Node.js and Docker for running development co…
24d3be8
Remove unnecessary upper boundary for NPM version.
d971249
Include link to wp-env package.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| name: Unit Testing | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - trunk | ||
| # Only run if PHP-related files changed. | ||
| paths: | ||
| - '.github/workflows/php-test.yml' | ||
| - '**.php' | ||
| - 'phpunit.xml.dist' | ||
| - 'tests/multisite.xml' | ||
| - 'composer.json' | ||
| - 'composer.lock' | ||
| pull_request: | ||
| branches: | ||
| - trunk | ||
| # Only run if PHP-related files changed. | ||
| paths: | ||
| - '.github/workflows/php-test.yml' | ||
| - '**.php' | ||
| - 'phpunit.xml.dist' | ||
| - 'tests/multisite.xml' | ||
| - 'composer.json' | ||
| - 'composer.lock' | ||
| types: | ||
| - opened | ||
| - reopened | ||
| - synchronize | ||
|
|
||
| jobs: | ||
| php-test: | ||
| name: PHP | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| steps: | ||
| - uses: styfle/cancel-workflow-action@0.8.0 | ||
| - uses: actions/checkout@v2 | ||
| - name: Read .nvmrc | ||
| run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)" | ||
| id: nvm | ||
| - name: Setup Node.js (.nvmrc) | ||
| uses: actions/setup-node@v1 | ||
| with: | ||
| node-version: '${{ steps.nvm.outputs.NVMRC }}' | ||
| cache: npm | ||
| - name: npm install | ||
| run: npm ci | ||
| - name: Install WordPress | ||
| run: npm run wp-env start | ||
| - name: Running single site unit tests | ||
| run: npm run test-php | ||
| - name: Running multisite unit tests | ||
| run: npm run test-php-multisite |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 14 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "core": null, | ||
| "plugins": [ "." ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,32 @@ | ||
| { | ||
| "name": "wordpress/performance", | ||
| "type": "wordpress-plugin", | ||
| "license": "GPL-2.0-or-later", | ||
| "description": "Performance plugin from the WordPress Performance Group, which is a collection of standalone performance modules.", | ||
| "homepage": "https://wordpress.org/plugins/performance-lab/", | ||
| "keywords": [ | ||
| "performance", | ||
| "wordpress" | ||
| ], | ||
| "support": { | ||
| "issues": "https://github.com/WordPress/performance/issues" | ||
| }, | ||
| "require-dev": { | ||
| "dealerdirect/phpcodesniffer-composer-installer": "^0.7", | ||
| "phpcompatibility/php-compatibility": "^9.3", | ||
| "phpunit/phpunit": "^8.5", | ||
| "squizlabs/php_codesniffer": "^3.5", | ||
| "wp-coding-standards/wpcs": "^2.2", | ||
| "wp-phpunit/wp-phpunit": "^5.8" | ||
| }, | ||
| "require": { | ||
| "composer/installers": "~1.0" | ||
| }, | ||
| "scripts": { | ||
| "format": "phpcbf --standard=phpcs.xml.dist --report-summary --report-source", | ||
| "lint": "phpcs --standard=phpcs.xml.dist", | ||
| "test": "phpunit" | ||
| } | ||
| "name": "wordpress/performance", | ||
| "type": "wordpress-plugin", | ||
| "license": "GPL-2.0-or-later", | ||
| "description": "Performance plugin from the WordPress Performance Group, which is a collection of standalone performance modules.", | ||
| "homepage": "https://wordpress.org/plugins/performance-lab/", | ||
| "keywords": [ | ||
| "performance", | ||
| "wordpress" | ||
| ], | ||
| "support": { | ||
| "issues": "https://github.com/WordPress/performance/issues" | ||
| }, | ||
| "require-dev": { | ||
| "dealerdirect/phpcodesniffer-composer-installer": "^0.7", | ||
| "phpcompatibility/php-compatibility": "^9.3", | ||
| "phpunit/phpunit": "^8.5", | ||
| "squizlabs/php_codesniffer": "^3.5", | ||
| "wp-coding-standards/wpcs": "^2.2", | ||
| "wp-phpunit/wp-phpunit": "^5.8", | ||
| "yoast/phpunit-polyfills": "^1.0" | ||
| }, | ||
| "require": { | ||
| "composer/installers": "~1.0" | ||
| }, | ||
| "scripts": { | ||
| "format": "phpcbf --standard=phpcs.xml.dist --report-summary --report-source", | ||
| "lint": "phpcs --standard=phpcs.xml.dist", | ||
| "test": "phpunit -c phpunit.xml.dist --verbose", | ||
| "test-multisite": "WP_MULTISITE=1 phpunit -c tests/multisite.xml --verbose" | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it makes sense to mention we need to have Docker up and running before running the
wp-envcommands. And/or link to the handbook (https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to that, for someone without Docker this
npm run wp-env startand everything after fails.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point, I added a note about both Node.js and Docker being required.