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

Updates PHP unit tests matrix and dev dependencies for PHP8.2 compatibility. #2624

Merged
merged 12 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
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
4 changes: 3 additions & 1 deletion .github/workflows/php-coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
- name: Prepare PHP
uses: woocommerce/grow/prepare-php@actions-v1
with:
# TODO: Update to PHP8.2 once WPCS (3.0) and woocommerce-sniffs (> 0.1.3) are updated to latest versions.
php-version: 8.0
krutidugade marked this conversation as resolved.
Show resolved Hide resolved
tools: cs2pr

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

- name: PHP Syntax checker
uses: StephaneBour/actions-php-lint@7.2
uses: StephaneBour/actions-php-lint@8.0
krutidugade marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 2 additions & 9 deletions .github/workflows/php-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ jobs:
WP_TESTS_DIR: "/tmp/wordpress/tests/phpunit"
strategy:
matrix:
php: [7.4]
wp-version: [5.8, 5.9, latest]
include:
- php: 8.0
wp-version: latest
php: [7.4, 8.0, 8.1, 8.2]
wp-version: [latest]

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

- name: PHP8, PHPUnit9 with WordPress v5.9+
if: matrix.php >= 8
run: composer require phpunit/phpunit "^8" --dev --update-with-all-dependencies

- name: Run PHP unit tests
run: composer test-unit
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@ codeception.yml
php.ini
wp-config.php

#PHP Unit
.phpunit.result.cache

# IDE files
.vscode/*
krutidugade marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,29 @@ If you have a WooCommerce.com account, you can [start a chat or open a ticket on
### Logging
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.
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.
## Development
## Development
### Developing
- Clone this repository into the `wp-content/plugins/` folder your WooCommerce development environment.
- Install dependencies:
- Install dependencies:
- `npm install`
- `composer install`
- Build assets:
- `npm start` to build a development version
- Linting:
- `npm run lint:php` to run PHPCS linter on all PHP files
- Testing:
- `./bin/install-wp-tests.sh <test-db-name> <db-user> <db-password> [db-host]` to set up testing environment
- `npm run test:php` to run PHP unit tests on all PHP files

#### Production build

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

### Releasing
Refer to the [wiki for details of how to build and release the plugin](https://github.com/woocommerce/facebook-for-woocommerce/wiki/Build-&-Release).
Refer to the [wiki for details of how to build and release the plugin](https://github.com/woocommerce/facebook-for-woocommerce/wiki/Build-&-Release).

### PHPCS Linting and PHP 8.1+

We currently do not support PHPCS on PHP 8.1+ versions. Please run PHPCS checks on PHP 8.0 or lower versions.

Alternately, you can run PHPCS checks on PHP8.1+ versions by appending `?? ''` code within `trim()` at Line 280 of file /vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php and Line 194 of file /vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/I18nSniff.php
krutidugade marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
}
],
"require": {
"php": ">=7.2",
"php": ">=7.4",
"woocommerce/action-scheduler-job-framework": "2.0.0",
"composer/installers": "~1.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^v0.7",
"phpunit/phpunit": "^7.5",
"phpunit/phpunit": "^9.6",
"wp-coding-standards/wpcs": "^2.3",
"yoast/phpunit-polyfills": "^1.0",
"yoast/phpunit-polyfills": "^2.0",
"wp-cli/i18n-command": "^2.2",
"woocommerce/woocommerce-sniffs": "^0.1.3"
},
Expand All @@ -34,7 +34,7 @@
},
"config": {
"platform": {
"php": "7.2"
"php": "7.4"
},
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
Expand Down
Loading