Skip to content

Commit

Permalink
Make it possible to run tests in PHP 8 (#1760)
Browse files Browse the repository at this point in the history
* Add npm command to run tests in wp-env

* Add a base env:tests-cmd script

* Run composer install before running tests

* Upgrade phpunit to 8.5 (latest 8.* minor release)

* Void return type must now be specified in certain test methods

See 'Return Type of Template Methods' at https://phpunit.de/announcements/phpunit-8.html

* Remove calls to deprecated assertInternalType()

See sebastianbergmann/phpunit#3368

* Don't generate test cache file

* Don't use depreacated canonicalize parameter of assertEquals()

* Using assertContains() with string haystacks is deprecated

* Upgrade phpunit to 9.6 (latest 9.* minor release)

* assertObjectHasAttribute() is deprecated in favour of assertObjectHasProperty()

* assertRegExp() is deprecated in favour of assertMatchesRegularExpression()

* Remove commented out code

* Only run tests against nightly once

* In GitHub actions, test under PHP 8.3 instead of 7.4

* Document jobs

* In GitHub actions, also test under PHP 7.4

* Add some PHPUnit workflows with PHP 7.4

* Expand GitHub workflows matrix, instead of specifying each job

---------

Co-authored-by: Jesús Amieiro Becerra <1667814+amieiro@users.noreply.github.com>
  • Loading branch information
psrpinto and amieiro committed Jan 11, 2024
1 parent d7e6277 commit 33ba504
Show file tree
Hide file tree
Showing 30 changed files with 658 additions and 649 deletions.
16 changes: 4 additions & 12 deletions .github/workflows/phpunit.yml
Expand Up @@ -37,27 +37,19 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
php: [ '7.4' ]
php: [ '7.4', '8.3' ]
wordpress: [ 'latest', 'nightly' ]
multisite: [ false ]
multisite: [ false, true ]
coverage: [ false ]
experimental: [ false ]
include:
# - php: '8.0'
# os: ubuntu-latest
# experimental: true
# Run coverage only on latest PHP.
- os: ubuntu-latest
php: '7.4'
php: '8.3'
wordpress: 'latest'
multisite: false
coverage: true
experimental: false
- os: ubuntu-latest
php: '7.4'
wordpress: 'latest'
multisite: true
coverage: false
experimental: false

steps:
- name: Check out Git repository
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -22,7 +22,7 @@
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
"gettext/languages": "^2.6",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"phpunit/phpunit": "^7",
"phpunit/phpunit": "^9.6.15",
"wp-coding-standards/wpcs": "^2.2",
"yoast/phpunit-polyfills": "^2.0"
},
Expand Down

0 comments on commit 33ba504

Please sign in to comment.