diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e53bc08..7b09fe1 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,25 +9,29 @@ updates: - package-ecosystem: "github-actions" directory: "/" schedule: - interval: "weekly" + interval: "cron" + cronjob: "15 22 5,20 * *" # At 22:15, every 5th and 20th day of the month. open-pull-requests-limit: 5 commit-message: prefix: "GH Actions:" labels: - "yoastcs/qa" - reviewers: - - "jrfnl" + groups: + action-runners: + applies-to: version-updates + update-types: + - "minor" + - "patch" # Maintain dependencies for Composer. - package-ecosystem: "composer" directory: "/" schedule: - interval: "weekly" + interval: "cron" + cronjob: "15 22 5,20 * *" # At 22:15, every 5th and 20th day of the month. open-pull-requests-limit: 5 # Set to 0 to (temporarily) disable. versioning-strategy: "increase-if-necessary" commit-message: prefix: "Composer:" labels: - "yoastcs/qa" - reviewers: - - "jrfnl" diff --git a/.github/release-checklist.md b/.github/release-checklist.md new file mode 100644 index 0000000..2eeb051 --- /dev/null +++ b/.github/release-checklist.md @@ -0,0 +1,30 @@ +Release checklist +=========================================================== + +## Pre-release + +- [ ] Composer: check if any dependencies/version constraints need updating - PR #xxx +- [ ] Add changelog for the release - PR #xxx + :pencil2: Verify that a release link at the bottom of the `CHANGELOG.md` file has been added. + +## Release + +- [ ] Create PR to merge the `develop` branch into `main`. +- [ ] Merge that PR +- [ ] Make sure all CI builds are green. +- [ ] Create a release from the tag (careful, GH defaults to `develop`!) & copy & paste the changelog to it. + Make sure to copy the links to the issues and the links to the GH usernames from the bottom of the changelog! +- [ ] Close the milestone. +- [ ] Open a new milestone for the next release. +- [ ] If any open PRs/issues which were milestoned for the release did not make it into the release, update their milestone. + +## Announce + +- [ ] Tweet about the release. + + +--- + +Additional actions to take, not part of the release checklist: +- [ ] Post a link to the release in the Yoast Slack. +- [ ] Update the test dependencies in Yoast packages. diff --git a/.github/workflows/cs.yml b/.github/workflows/cs.yml index 184d2d5..d5740a5 100644 --- a/.github/workflows/cs.yml +++ b/.github/workflows/cs.yml @@ -8,25 +8,33 @@ on: workflow_dispatch: jobs: + actionlint: + name: 'Lint GH Action workflows' + uses: Yoast/.github/.github/workflows/reusable-actionlint.yml@c14f66005ab514663a48d00712db67617c98728c # v1.0.0 + checkcs: name: 'Basic CS and QA checks' runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false - name: Install PHP - uses: shivammathur/setup-php@v2 + uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0 with: - php-version: '7.4' + php-version: 'latest' coverage: none tools: cs2pr + env: + fail-fast: true # Install dependencies and handle caching in one go. - # @link https://github.com/marketplace/actions/install-composer-dependencies + # @link https://github.com/marketplace/actions/install-php-dependencies-with-composer - name: Install Composer dependencies - uses: "ramsey/composer-install@v2" + uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # 3.1.1 with: # Bust the cache at least once a month - output format: YYYY-MM. custom-cache-suffix: $(date -u "+%Y-%m") diff --git a/.github/workflows/merge-conflict-check.yml b/.github/workflows/merge-conflict-check.yml new file mode 100644 index 0000000..1870754 --- /dev/null +++ b/.github/workflows/merge-conflict-check.yml @@ -0,0 +1,21 @@ +name: Check PRs for merge conflicts + +on: + # Check for new conflicts due to merges. + push: + branches: + - main + - develop + # Check conflicts in new PRs and for resolved conflicts due to an open PR being updated. + pull_request_target: + types: + - opened + - synchronize + - reopened + +jobs: + check-prs: + if: github.repository_owner == 'Yoast' + + name: Check PRs for merge conflicts + uses: Yoast/.github/.github/workflows/reusable-merge-conflict-check.yml@c14f66005ab514663a48d00712db67617c98728c # v1.0.0 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fc8e702..4b95606 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,45 +19,46 @@ jobs: strategy: matrix: - php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.3'] + php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.6'] coverage: [false] # Run code coverage only on high/low PHP. include: - php: 5.6 coverage: true - - php: 8.2 + - php: 8.5 coverage: true - continue-on-error: ${{ matrix.php == '8.3' }} + continue-on-error: ${{ matrix.php == '8.6' }} name: "Tests: PHP ${{ matrix.php }}" steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + with: + persist-credentials: false - name: Install PHP - uses: shivammathur/setup-php@v2 + uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0 with: php-version: ${{ matrix.php }} - ini-values: error_reporting=E_ALL, display_errors=On + ini-values: zend.assertions=1, assert.exception=1, error_reporting=-1, display_errors=On, display_startup_errors=On coverage: ${{ matrix.coverage == true && 'xdebug' || 'none' }} + env: + fail-fast: true - # Install dependencies and handle caching in one go. - # @link https://github.com/marketplace/actions/install-composer-dependencies - - name: Install Composer dependencies - normal - if: matrix.php != '8.3' - uses: "ramsey/composer-install@v2" - with: - # Bust the cache at least once a month - output format: YYYY-MM. - custom-cache-suffix: $(date -u "+%Y-%m") + # YoastCS 3.0 has a PHP 7.2 minimum which conflicts with the requirements of this package. + - name: 'Composer: remove YoastCS' + run: composer remove --dev yoast/yoastcs --no-update --no-interaction - - name: Install Composer dependencies - ignore PHP restrictions - if: matrix.php == '8.3' - uses: "ramsey/composer-install@v2" + # Install dependencies and handle caching in one go. + # @link https://github.com/marketplace/actions/install-php-dependencies-with-composer + - name: Install Composer dependencies + uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # 3.1.1 with: - composer-options: --ignore-platform-req=php+ + # For PHP "nightly", we need to install with ignore platform reqs as not all dependencies may allow it yet. + composer-options: ${{ matrix.php == '8.6' && '--ignore-platform-req=php+' || '' }} # Bust the cache at least once a month - output format: YYYY-MM. custom-cache-suffix: $(date -u "+%Y-%m") @@ -72,34 +73,23 @@ jobs: if: ${{ matrix.coverage == true }} run: composer coverage - # PHP Coveralls doesn't fully support PHP 8.x yet, so switch the PHP version. - - name: Switch to PHP 7.4 - if: ${{ success() && matrix.coverage == true && startsWith( matrix.php, '8' ) }} - uses: shivammathur/setup-php@v2 - with: - php-version: 7.4 - coverage: none - - # Global install is used to prevent a conflict with the local composer.lock in PHP 8.0+. - - name: Install Coveralls - if: ${{ success() && matrix.coverage == true }} - run: composer global require php-coveralls/php-coveralls:"^2.5.3" --no-interaction - - name: Upload coverage results to Coveralls if: ${{ success() && matrix.coverage == true }} - env: - COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} - COVERALLS_PARALLEL: true - COVERALLS_FLAG_NAME: php-${{ matrix.php }} - run: php-coveralls -v -x build/logs/clover.xml + uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7 + with: + format: clover + file: build/logs/clover.xml + flag-name: php-${{ matrix.php }} + parallel: true coveralls-finish: needs: test runs-on: ubuntu-latest + name: Coveralls Finish + steps: - name: Coveralls Finished - uses: coverallsapp/github-action@v2 + uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7 with: - github-token: ${{ secrets.COVERALLS_TOKEN }} parallel-finished: true diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index ff1e0a9..112b5d0 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -1,27 +1,27 @@ - Check the code of WP Test Utils. + Check the code of WP Test Utils. - + - . + . - - + + - - + + - - + + - - + + @@ -41,16 +41,33 @@ - - + + + + + + + + + + + + + + + + + + - - - - + + + *\.php + - + - - + + - - + + + /tests/*\.php + + + + + + + @@ -78,7 +103,7 @@ - + @@ -92,11 +117,6 @@ ############################################################################# --> - - - /src/*/bootstrap*\.php$ - - /src/BrainMonkey/bootstrap\.php$ @@ -116,9 +136,16 @@ /src/Helpers/*\.php$ - + + + + + /tests/*/Fixtures/*\.php$ + + + - /tests/*\.php$ + /tests/*/Fixtures/*\.php$ diff --git a/CHANGELOG.md b/CHANGELOG.md index d8d9b0b..335ace3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,11 +9,24 @@ This projects adheres to [Keep a CHANGELOG](http://keepachangelog.com/) and uses _Nothing yet._ +## [1.2.1] - 2026-02-05 + +### Changed +* The [PHPUnit Polyfills] dependency has been updated to require [version `^1.1.5`](https://github.com/Yoast/PHPUnit-Polyfills/releases/tag/1.1.5) (was `^1.1.0`). PRs [#75], [#101] +* The [BrainMonkey] dependency has been updated to require [version `^2.7.0`](https://github.com/Brain-WP/BrainMonkey/releases/tag/2.7.0) (was `^2.6.1`). PRs [#79], [#102] +* Verified PHP 8.4 and 8.5 compatibility. +* General housekeeping. + +[#75]: https://github.com/Yoast/wp-test-utils/pull/75 +[#79]: https://github.com/Yoast/wp-test-utils/pull/79 +[#101]: https://github.com/Yoast/wp-test-utils/pull/101 +[#102]: https://github.com/Yoast/wp-test-utils/pull/102 + + ## [1.2.0] - 2023-09-27 ### Added - -* Support for the new PHPUnit `assertObjectHasProperty()` and `assertObjectNotHasProperty()` assertions, as polyfilled via the PHPUnit Polyfills in all test cases. PR [#64] +* Support for the new PHPUnit `assertObjectHasProperty()` and `assertObjectNotHasProperty()` assertions, as polyfilled via the [PHPUnit Polyfills] in all test cases. PR [#64] This means that the `assertObjectHasProperty()` and `assertObjectNotHasProperty()` assertions can now safely be used in all tests in classes which extend one of the WP Test Utils TestCases. ### Changed diff --git a/README.md b/README.md index 0bf1acc..bdae241 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ WP Test Utils ===================================================== -[![Version](https://poser.pugx.org/yoast/wp-test-utils/version)](https://packagist.org/packages/yoast/wp-test-utils) +[![Version](https://img.shields.io/packagist/v/yoast/wp-test-utils)](https://packagist.org/packages/yoast/wp-test-utils) [![CS Build Status](https://github.com/Yoast/wp-test-utils/actions/workflows/cs.yml/badge.svg)](https://github.com/Yoast/wp-test-utils/actions/workflows/cs.yml) [![Test Build Status](https://github.com/Yoast/wp-test-utils/actions/workflows/test.yml/badge.svg)](https://github.com/Yoast/wp-test-utils/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/Yoast/wp-test-utils/badge.svg?branch=develop)](https://coveralls.io/github/Yoast/wp-test-utils?branch=develop) [![Minimum PHP Version](https://img.shields.io/packagist/php-v/yoast/wp-test-utils.svg?maxAge=3600)](https://packagist.org/packages/yoast/wp-test-utils) -[![License: BSD3](https://poser.pugx.org/yoast/wp-test-utils/license)](https://github.com/Yoast/wp-test-utils/blob/main/LICENSE) +[![License: BSD3](https://img.shields.io/packagist/l/yoast/wp-test-utils)](https://github.com/Yoast/wp-test-utils/blob/main/LICENSE) This library contains a set of utilities for running automated tests for WordPress plugins and themes. @@ -35,9 +35,9 @@ Requirements * PHP 5.6 or higher. The following packages will be automatically required via Composer: -* [PHPUnit Polyfills] 1.1.0 or higher. +* [PHPUnit Polyfills] 1.1.5 or higher. * [PHPUnit] 5.7 - 9.x. -* [BrainMonkey] 2.6.1 or higher. +* [BrainMonkey] 2.7.0 or higher. Installation diff --git a/composer.json b/composer.json index b15ffa3..5f73896 100644 --- a/composer.json +++ b/composer.json @@ -24,15 +24,18 @@ "homepage": "https://github.com/Yoast/wp-test-utils/", "support": { "issues": "https://github.com/Yoast/wp-test-utils/issues", - "source": "https://github.com/Yoast/wp-test-utils" + "source": "https://github.com/Yoast/wp-test-utils", + "security": "https://github.com/Yoast/wp-test-utils/security/policy" }, "require": { "php": ">=5.6", - "brain/monkey": "^2.6.1", - "yoast/phpunit-polyfills": "^1.1.0" + "brain/monkey": "^2.7.0", + "yoast/phpunit-polyfills": "^1.1.5" }, "require-dev": { - "yoast/yoastcs": "^2.3.1" + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "yoast/yoastcs": "^3.3.0" }, "minimum-stability": "dev", "prefer-stable": true, @@ -53,7 +56,8 @@ "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true - } + }, + "lock": false }, "extra": { "branch-alias": { diff --git a/src/BrainMonkey/TestCase.php b/src/BrainMonkey/TestCase.php index e1d67cf..983e851 100644 --- a/src/BrainMonkey/TestCase.php +++ b/src/BrainMonkey/TestCase.php @@ -81,10 +81,10 @@ public function stubTranslationFunctions() { [ '__' => null, '_x' => null, - '_n' => static function( $single, $plural, $number ) { + '_n' => static function ( $single, $plural, $number ) { return ( $number === 1 ) ? $single : $plural; }, - '_nx' => static function( $single, $plural, $number ) { + '_nx' => static function ( $single, $plural, $number ) { return ( $number === 1 ) ? $single : $plural; }, 'translate' => null, @@ -198,7 +198,7 @@ public static function makeDoubleForUnavailableClass( $class_name ) { * * @see TestCase::makeDoubleForUnavailableClass() * - * @param string[] $class_names List of class names to be "faked". + * @param array $class_names List of class names to be "faked". * * @return void */ diff --git a/src/BrainMonkey/YoastTestCase.php b/src/BrainMonkey/YoastTestCase.php index 113a332..167b0f7 100644 --- a/src/BrainMonkey/YoastTestCase.php +++ b/src/BrainMonkey/YoastTestCase.php @@ -24,7 +24,7 @@ protected function set_up() { Monkey\Functions\stubs( [ // Passing "null" makes the function return it's first argument. - 'get_bloginfo' => static function( $show ) { + 'get_bloginfo' => static function ( $show ) { switch ( $show ) { case 'charset': return 'UTF-8'; @@ -34,14 +34,14 @@ protected function set_up() { return $show; }, - 'is_multisite' => static function() { + 'is_multisite' => static function () { if ( \defined( 'WP_TESTS_MULTISITE' ) ) { return (bool) \WP_TESTS_MULTISITE; } return false; }, - 'mysql2date' => static function( $format, $date ) { + 'mysql2date' => static function ( $format, $date ) { return $date; }, 'number_format_i18n' => null, @@ -51,7 +51,7 @@ protected function set_up() { 'wp_parse_args' => static function ( $args, $defaults ) { return \array_merge( $defaults, $args ); }, - 'wp_strip_all_tags' => static function( $text, $remove_breaks = false ) { + 'wp_strip_all_tags' => static function ( $text, $remove_breaks = false ) { $text = \preg_replace( '@<(script|style)[^>]*?>.*?@si', '', $text ); $text = \strip_tags( $text ); @@ -62,7 +62,7 @@ protected function set_up() { return \trim( $text ); }, 'wp_slash' => null, - 'wp_unslash' => static function( $value ) { + 'wp_unslash' => static function ( $value ) { return \is_string( $value ) ? \stripslashes( $value ) : $value; }, ] diff --git a/src/BrainMonkey/bootstrap.php b/src/BrainMonkey/bootstrap.php index 96c41f2..56d3063 100644 --- a/src/BrainMonkey/bootstrap.php +++ b/src/BrainMonkey/bootstrap.php @@ -39,7 +39,7 @@ * * @see TestCase::makeDoubleForUnavailableClass() * - * @param string[] $class_names List of class names to be "faked". + * @param array $class_names List of class names to be "faked". * * @return void */ diff --git a/src/WPIntegration/TestCaseNoPolyfills.php b/src/WPIntegration/TestCaseNoPolyfills.php index 5a2499f..b17be10 100644 --- a/src/WPIntegration/TestCaseNoPolyfills.php +++ b/src/WPIntegration/TestCaseNoPolyfills.php @@ -26,5 +26,4 @@ abstract class TestCase extends WP_UnitTestCase { use ExpectOutputHelper; - } diff --git a/src/WPIntegration/bootstrap-functions.php b/src/WPIntegration/bootstrap-functions.php index f934a6a..282dd32 100644 --- a/src/WPIntegration/bootstrap-functions.php +++ b/src/WPIntegration/bootstrap-functions.php @@ -42,7 +42,7 @@ function get_path_to_wp_test_dir() { * * @return string The file path with normalized slashes. */ - $normalize_path = static function( $path ) { + $normalize_path = static function ( $path ) { return \str_replace( '\\', '/', $path ); };