Skip to content

Commit

Permalink
Merge b7e1f7b into f955f6a
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Sep 27, 2023
2 parents f955f6a + b7e1f7b commit 122b995
Show file tree
Hide file tree
Showing 16 changed files with 316 additions and 143 deletions.
14 changes: 7 additions & 7 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
# https://www.reddit.com/r/PHP/comments/2jzp6k/i_dont_need_your_tests_in_my_production
# https://blog.madewithlove.be/post/gitattributes/
#
/.gitattributes export-ignore
/.gitignore export-ignore
/.cache/ export-ignore
/.github/ export-ignore
/.phpcs.xml.dist export-ignore
/phpunit.xml.dist export-ignore
/tests/ export-ignore
/.cache/ export-ignore
/.github/ export-ignore
/tests/ export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.phpcs.xml.dist export-ignore
phpunit.xml.dist export-ignore

#
# Auto detect text files and perform LF normalization
Expand Down
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ updates:
prefix: "GH Actions:"
labels:
- "yoastcs/qa"
reviewers:
- "jrfnl"

# Maintain dependencies for Composer.
- package-ecosystem: "composer"
Expand All @@ -27,3 +29,5 @@ updates:
prefix: "Composer:"
labels:
- "yoastcs/qa"
reviewers:
- "jrfnl"
8 changes: 4 additions & 4 deletions .github/workflows/cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

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

- name: Install PHP
uses: shivammathur/setup-php@v2
Expand All @@ -28,8 +28,8 @@ jobs:
- name: Install Composer dependencies
uses: "ramsey/composer-install@v2"
with:
# Bust the cache at least once a month - output format: YYYY-MM-DD.
custom-cache-suffix: $(date -u -d "-0 month -$(($(date +%d)-1)) days" "+%F")
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

# Validate the composer.json file.
# @link https://getcomposer.org/doc/03-cli.md#validate
Expand All @@ -39,7 +39,7 @@ jobs:
# Check the code-style consistency of the PHP files.
- name: Check PHP code style
id: phpcs
run: composer check-cs -- --report-full --report-checkstyle=./phpcs-report.xml
run: composer check-cs -- --no-cache --report-full --report-checkstyle=./phpcs-report.xml

- name: Show PHPCS results in PR
if: ${{ always() && steps.phpcs.outcome == 'failure' }}
Expand Down
75 changes: 68 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
name: Test

on:
# Run on all pushes and on all pull requests.
# Run on pushes to `main` and `develop` and on all pull requests.
push:
branches:
- main
- develop
paths-ignore:
- '**.md'
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:
Expand All @@ -14,31 +19,87 @@ jobs:

strategy:
matrix:
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.3']
coverage: [false]

# Run code coverage only on high/low PHP.
include:
- php: 5.6
coverage: true
- php: 8.2
coverage: true

continue-on-error: ${{ matrix.php == '8.3' }}

name: "Tests: PHP ${{ matrix.php }}"

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

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: error_reporting=E_ALL, display_errors=On
coverage: none
coverage: ${{ matrix.coverage == true && 'xdebug' || 'none' }}

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: 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-DD.
custom-cache-suffix: $(date -u -d "-0 month -$(($(date +%d)-1)) days" "+%F")
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

- name: Install Composer dependencies - ignore PHP restrictions
if: matrix.php == '8.3'
uses: "ramsey/composer-install@v2"
with:
composer-options: --ignore-platform-req=php+
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

- name: Lint PHP files against parse errors
run: composer lint

- name: Run the unit tests
if: ${{ matrix.coverage == false }}
run: composer test

- name: Run the unit tests with code coverage
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

coveralls-finish:
needs: test
runs-on: ubuntu-latest

steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.COVERALLS_TOKEN }}
parallel-finished: true
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,24 @@ This projects adheres to [Keep a CHANGELOG](http://keepachangelog.com/) and uses

_Nothing yet._

## [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]
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
* `Yoast\WPTestUtils\BrainMonkey\YoastTestCase`: the parameter names used in a few of the stubs for WP Core functions have been updated to stay in line with the names used in WP Core. PR [#53]
* The [PHPUnit Polyfills] dependency has been updated to require [version `^1.1.0`](https://github.com/Yoast/PHPUnit-Polyfills/releases/tag/1.1.0) (was `^1.0.5`). PRs [#52], [#64]
* Verified PHP 8.3 compatibility.
* General housekeeping.

[#52]: https://github.com/Yoast/wp-test-utils/pull/52
[#53]: https://github.com/Yoast/wp-test-utils/pull/53
[#64]: https://github.com/Yoast/wp-test-utils/pull/64


## [1.1.1] - 2022-11-17

### Fixed
Expand Down Expand Up @@ -68,7 +86,6 @@ See the [Make Core dev-note](https://make.wordpress.org/core/2021/09/27/changes-
### Fixes
* The [PHPUnit Polyfills] dependency introduced three new polyfills in the `1.0.0` version. These are now supported in all test cases. [#17]


Thanks [Pierre Gordon] and [Pascal Birchler] for making feature suggestions for this version.

[#16]: https://github.com/Yoast/wp-test-utils/pull/16
Expand Down Expand Up @@ -118,6 +135,7 @@ Initial release.


[Unreleased]: https://github.com/Yoast/wp-test-utils/compare/main...HEAD
[1.2.0]: https://github.com/Yoast/wp-test-utils/compare/1.1.1...1.2.0
[1.1.1]: https://github.com/Yoast/wp-test-utils/compare/1.1.0...1.1.1
[1.1.0]: https://github.com/Yoast/wp-test-utils/compare/1.0.0...1.1.0
[1.0.0]: https://github.com/Yoast/wp-test-utils/compare/0.2.2...1.0.0
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ WP Test Utils
[![Version](https://poser.pugx.org/yoast/wp-test-utils/version)](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)

Expand Down Expand Up @@ -33,7 +35,7 @@ Requirements
* PHP 5.6 or higher.

The following packages will be automatically required via Composer:
* [PHPUnit Polyfills] 1.0.4 or higher.
* [PHPUnit Polyfills] 1.1.0 or higher.
* [PHPUnit] 5.7 - 9.x.
* [BrainMonkey] 2.6.1 or higher.

Expand Down Expand Up @@ -172,6 +174,8 @@ To tell PHPUnit to use this bootstrap file, use `--bootstrap tests/bootstrap.php

#### Helpers to create test doubles for unavailable classes

> :bulb: The problem this feature solves has been fixed in Mockery 1.6.0, so if you use Mockery 1.6.0 or higher for test runs against PHP 8.2 or higher, you should no longer need this solution.
##### Why you may need to create test doubles for unavailable classes

Typically a mock for an unavailable class is created using `Mockery::mock()` or `Mockery::mock( 'Unavailable' )`.
Expand Down

0 comments on commit 122b995

Please sign in to comment.