Skip to content

Commit

Permalink
Add WP PHPUnit integration tests (#269)
Browse files Browse the repository at this point in the history
* Downgrade PHPUnit to 9

* Add render integration test

* Fix indentation changes in BlockBindingsTest

* Use field IDs and helper methods to check render result

* Fix typo

* Fix bootstrap file phpcs error

* Add GitHub workflow for integration tests

* Re-add PHP stubs

* Fix register_block_configuration() to persist block configurations

* Add WP_PHPUnit stubs for psalm

* Minor variable rename

* Fix missing `run` step in integration test YML

* Fix function name in integration tests

---------

Co-authored-by: Max Schmeling <[email protected]>
  • Loading branch information
alecgeatches and maxschmeling authored Jan 8, 2025
1 parent a571052 commit 96eee5f
Show file tree
Hide file tree
Showing 13 changed files with 864 additions and 339 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Integration Tests

on:
# Run on all pull requests.
pull_request:
push:
branches:
- trunk

# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

jobs:
test:
name: WordPress Integration Tests
runs-on: ubuntu-24.04

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Use desired version of NodeJS
uses: actions/[email protected]
with:
node-version: 20
cache: npm

- name: Npm install
run: npm ci

- name: Start up WordPress environment
run: npm run dev:build

- name: Run Integration tests
run: npm run test:integration
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ vendor/

# PHPUnit
.phpunit.cache/
.phpunit.result.cache

# Editors
.idea/*
Expand Down
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@
"require-dev": {
"automattic/vipwpcs": "^3.0",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"phpunit/phpunit": "^10",
"phpunit/phpunit": "^9",
"slevomat/coding-standard": "^8.15",
"php-stubs/wordpress-stubs": "^6.6",
"psalm/phar": "^5.26",
"mockery/mockery": "^1.6",
"php-stubs/wordpress-globals": "^0.2.0"
"wp-phpunit/wp-phpunit": "^6.7",
"yoast/phpunit-polyfills": "^2.0",
"php-stubs/wordpress-globals": "^0.2.0",
"php-stubs/wordpress-tests-stubs": "^6.7"
},
"config": {
"allow-plugins": {
Expand Down
Loading

0 comments on commit 96eee5f

Please sign in to comment.