Skip to content

Commit fc596dd

Browse files
authored
Updates PHP unit tests matrix and dev dependencies for PHP8.2 compatibility. (#2624)
2 parents 0f6298c + 07d3fe4 commit fc596dd

File tree

11 files changed

+766
-640
lines changed

11 files changed

+766
-640
lines changed

.github/workflows/php-coding-standards.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
- name: Prepare PHP
2929
uses: woocommerce/grow/prepare-php@actions-v1
3030
with:
31+
# TODO: Update to PHP8.2 once WPCS (3.0) and woocommerce-sniffs (> 0.1.3) are updated to latest versions.
32+
php-version: 8.0
3133
tools: cs2pr
3234

3335
- name: Log PHPCS information
@@ -37,4 +39,4 @@ jobs:
3739
run: vendor/bin/phpcs -q -n --report=checkstyle | cs2pr
3840

3941
- name: PHP Syntax checker
40-
uses: StephaneBour/actions-php-lint@7.2
42+
uses: StephaneBour/actions-php-lint@8.0

.github/workflows/php-unit-tests.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,8 @@ jobs:
3030
WP_TESTS_DIR: "/tmp/wordpress/tests/phpunit"
3131
strategy:
3232
matrix:
33-
php: [7.4]
34-
wp-version: [5.8, 5.9, latest]
35-
include:
36-
- php: 8.0
37-
wp-version: latest
33+
php: [7.4, 8.0, 8.1, 8.2]
34+
wp-version: [latest]
3835

3936
steps:
4037
- name: Checkout repository
@@ -51,9 +48,5 @@ jobs:
5148
- name: Install WP tests
5249
run: ./bin/install-wp-tests.sh wordpress_test root root localhost ${{ matrix.wp-version }}
5350

54-
- name: PHP8, PHPUnit9 with WordPress v5.9+
55-
if: matrix.php >= 8
56-
run: composer require phpunit/phpunit "^8" --dev --update-with-all-dependencies
57-
5851
- name: Run PHP unit tests
5952
run: composer test-unit

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,8 @@ codeception.yml
3737
php.ini
3838
wp-config.php
3939

40+
#PHP Unit
41+
.phpunit.result.cache
42+
4043
# IDE files
41-
.vscode/*
44+
.vscode/*

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,27 @@ If you have a WooCommerce.com account, you can [start a chat or open a ticket on
1616
### Logging
1717
The plugin offers logging that can help debug various problems. You can enable debug mode in the main plugin settings panel under the `Enable debug mode` section.
1818
By default plugin omits headers in the requests to make the logs more readable. If debugging with headers is necessary you can enable the headers in the logs by setting `wc_facebook_request_headers_in_debug_log` option to true.
19-
## Development
19+
## Development
2020
### Developing
2121
- Clone this repository into the `wp-content/plugins/` folder your WooCommerce development environment.
22-
- Install dependencies:
22+
- Install dependencies:
2323
- `npm install`
2424
- `composer install`
2525
- Build assets:
2626
- `npm start` to build a development version
2727
- Linting:
2828
- `npm run lint:php` to run PHPCS linter on all PHP files
29+
- Testing:
30+
- `./bin/install-wp-tests.sh <test-db-name> <db-user> <db-password> [db-host]` to set up testing environment
31+
- `npm run test:php` to run PHP unit tests on all PHP files
2932

3033
#### Production build
3134

3235
- `npm run build` : Builds a production version.
3336

3437
### Releasing
35-
Refer to the [wiki for details of how to build and release the plugin](https://github.com/woocommerce/facebook-for-woocommerce/wiki/Build-&-Release).
38+
Refer to the [wiki for details of how to build and release the plugin](https://github.com/woocommerce/facebook-for-woocommerce/wiki/Build-&-Release).
39+
40+
### PHPCS Linting and PHP 8.1+
41+
42+
We currently do not support PHPCS on PHP 8.1+ versions. Please run PHPCS checks on PHP 8.0 or lower versions. Refer [#2624 PR](https://github.com/woocommerce/facebook-for-woocommerce/pull/2624/) for additional context.

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
}
1111
],
1212
"require": {
13-
"php": ">=7.2",
13+
"php": ">=7.4",
1414
"woocommerce/action-scheduler-job-framework": "2.0.0",
1515
"composer/installers": "~1.0"
1616
},
1717
"require-dev": {
1818
"dealerdirect/phpcodesniffer-composer-installer": "^v0.7",
19-
"phpunit/phpunit": "^7.5",
19+
"phpunit/phpunit": "^9.6",
2020
"wp-coding-standards/wpcs": "^2.3",
21-
"yoast/phpunit-polyfills": "^1.0",
21+
"yoast/phpunit-polyfills": "^2.0",
2222
"wp-cli/i18n-command": "^2.2",
2323
"woocommerce/woocommerce-sniffs": "^0.1.3"
2424
},
@@ -34,7 +34,7 @@
3434
},
3535
"config": {
3636
"platform": {
37-
"php": "7.2"
37+
"php": "7.4"
3838
},
3939
"allow-plugins": {
4040
"dealerdirect/phpcodesniffer-composer-installer": true,

0 commit comments

Comments
 (0)