Skip to content

Commit f014fb2

Browse files
authored
Merge pull request #50 from Yoast/develop
Release version 1.0.1
2 parents 5d257d5 + c7bffa8 commit f014fb2

File tree

5 files changed

+88
-8
lines changed

5 files changed

+88
-8
lines changed

.github/RELEASE-CHECKLIST.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Template to use for release PRs from `develop` to `main`
2+
===========================================================
3+
4+
Title: Release version x.x.x
5+
6+
### Functional:
7+
- [ ] Confirm that the most recent PHPUnit changelogs have been checked and that the library is still feature complete for those versions supported within the PHPUnit version constraints.
8+
- [ ] Update the `VERSION` constant in the `phpunitpolyfills-autoload.php` file.
9+
- [ ] Composer: check if any dependencies/version constraints need updating.
10+
11+
### Release:
12+
- [ ] Add changelog for the release - PR #xxx
13+
Verify that a release link at the bottom of the `CHANGELOG.md` file has been added.
14+
- [ ] Merge this PR.
15+
- [ ] Make sure all CI builds are green.
16+
- [ ] Tag the release (careful, GH defaults to `develop`!).
17+
- [ ] Create a release from the tag (careful, GH defaults to `develop`!) & copy & paste the changelog to it.
18+
Make sure to copy the links to the issues and the links to the GH usernames from the bottom of the changelog!
19+
- [ ] Close the milestone.
20+
- [ ] Open a new milestone for the next release.
21+
- [ ] If any open PRs/issues which were milestoned for the release did not make it into the release, update their milestone.
22+
23+
### Announce:
24+
- [ ] Tweet about the release.
25+
26+
27+
---
28+
29+
Additional actions to take, not part of the release checklist:
30+
- [ ] Post a link to the release in the Yoast Slack.
31+
- [ ] Update the dependency version constraints for WP Test Utils.

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ jobs:
7171
uses: shivammathur/setup-php@v2
7272
with:
7373
php-version: ${{ matrix.php }}
74+
ini-values: error_reporting=E_ALL, display_errors=On
7475
coverage: none
7576

7677
- name: 'Composer: set PHPUnit version for tests'

CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,27 @@ This projects adheres to [Keep a CHANGELOG](http://keepachangelog.com/) and uses
99

1010
_Nothing yet._
1111

12+
## [1.0.1] - 2021-08-09
13+
14+
### Added
15+
* The `Yoast\PHPUnitPolyfills\Autoload` class now contains a `VERSION` constant. Issue [#46], PR [#47], props [Pascal Birchler] for the suggestion.
16+
This version constant can be used by (complex) test setups to verify that the PHPUnit Polyfills which will be loaded, comply with the version requirements for the test suite.
17+
18+
### Changed
19+
* Minor documentation updates. [#43]
20+
21+
[#43]: https://github.com/Yoast/PHPUnit-Polyfills/pull/43
22+
[#46]: https://github.com/Yoast/PHPUnit-Polyfills/issues/46
23+
[#47]: https://github.com/Yoast/PHPUnit-Polyfills/pull/47
24+
25+
1226
## [1.0.0] - 2021-06-21
1327

1428
### Added
1529
* `Yoast\PHPUnitPolyfills\Polyfills\AssertClosedResource` trait to polyfill the `Assert::assertIsClosedResource()` and `Assert::assertIsNotClosedResource()` methods as introduced in PHPUnit 9.3.0. PR [#27].
1630
* `Yoast\PHPUnitPolyfills\Polyfills\AssertObjectEquals` trait to polyfill the `Assert::assertObjectEquals()` method as introduced in PHPUnit 9.4.0. PR [#38].
1731
The behaviour of the polyfill closely matches the PHPUnit native implementation, but is not 100% the same.
18-
Most notably, the polyfill will check the type of the returned value from the comparator method instead of the enforcing a return type declaration of the comparator method.
32+
Most notably, the polyfill will check the type of the returned value from the comparator method instead of enforcing a return type declaration for the comparator method.
1933
* `Yoast\PHPUnitPolyfills\Polyfills\EqualToSpecializations` trait to polyfill the `Assert::equalToCanonicalizing()`, `Assert::equalToIgnoringCase()` and `Assert::equalToWithDelta()` methods as introduced in PHPUnit 9.0.0. PR [#28], props [Marc Siegrist].
2034
* Polyfills for the PHP native `Error` and `TypeError` classes as introduced in PHP 7.0. PR [#36].
2135
* README: FAQ section covering functionality removed from PHPUnit and usage with a Phar.
@@ -67,10 +81,12 @@ Initial release.
6781

6882

6983
[Unreleased]: https://github.com/Yoast/PHPUnit-Polyfills/compare/main...HEAD
84+
[1.0.1]: https://github.com/Yoast/PHPUnit-Polyfills/compare/1.0.0...1.0.1
7085
[1.0.0]: https://github.com/Yoast/PHPUnit-Polyfills/compare/0.2.0...1.0.0
7186
[0.2.0]: https://github.com/Yoast/PHPUnit-Polyfills/compare/0.1.0...0.2.0
7287
[0.1.0]: https://github.com/Yoast/PHPUnit-Polyfills/compare/e8f8b7a73737aa9a5974bd9c73d2bd8d09f69873...0.1.0
7388

7489
[Gary Jones]: https://github.com/GaryJones
7590
[Marc Siegrist]: https://github.com/mergeMarc
7691
[Mark Baker]: https://github.com/MarkBaker
92+
[Pascal Birchler]: https://github.com/swissspidy

README.md

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ For the polyfills to work, a test class is **required** to be a (grand-)child of
128128

129129
If your library still needs to support PHP < 5.6 and therefore needs PHPUnit 4 for testing, there are a few caveats when using the traits stand-alone as we then enter "double-polyfill" territory.
130130

131-
To prevent "conflicting method names" errors when a trait is `use`d multiple times in a class, the traits offered here do not attempt to solve this.
131+
To prevent _"conflicting method names"_ errors when a trait is `use`d multiple times in a class, the traits offered here do not attempt to solve this.
132132

133133
You will need to make sure to `use` any additional traits needed for the polyfills to work.
134134

@@ -433,27 +433,28 @@ if ( self::shouldClosedResourceAssertionBeSkipped( $actual ) === false ) {
433433
}
434434
```
435435

436-
> :point_right: While this polyfill is tested extensively, testing for these kind of bugs exhaustively is _hard_.
436+
> :point_right: While this polyfill is tested extensively, testing for these kind of bugs _exhaustively_ is _hard_.
437437
> Please [report any bugs](https://github.com/Yoast/PHPUnit-Polyfills/issues/new/choose) found and include a clear code sample to reproduce the issue.
438438
439439
#### PHPUnit < 9.4.0: `Yoast\PHPUnitPolyfills\Polyfills\AssertObjectEquals`
440440

441441
Polyfills the [`Assert::assertObjectEquals()`] method to verify two (value) objects are considered equal.
442442
This assertion expects an object to contain a comparator method in the object itself. This comparator method is subsequently called to verify the "equalness" of the objects.
443443

444-
The `assertObjectEquals() assertion was introduced in PHPUnit 9.4.0.
444+
The `assertObjectEquals()` assertion was introduced in PHPUnit 9.4.0.
445445

446-
> :info: Due to [limitations in how this assertion is implemented in PHPUnit] itself, it is currently not possible to create a single comparator method which will be compatible with both PHP < 7.0 and PHP 7.0 or higher.
446+
> :information_source: Due to [limitations in how this assertion is implemented in PHPUnit] itself, it is currently not possible to create a single comparator method which will be compatible with both PHP < 7.0 and PHP 7.0 or higher.
447447
>
448448
> In effect two declarations of the same object would be needed to be compatible with PHP < 7.0 and PHP 7.0 and higher and still allow for testing the object using the `assertObjectEquals()` assertion.
449449
>
450450
> Due to this limitation, it is recommended to only use this assertion if the minimum supported PHP version of a project is PHP 7.0 or higher; or if the project does not run its tests on PHPUnit >= 9.4.0.
451+
>
452+
> The implementation of this assertion in the Polyfills is PHP cross-version compatible.
451453
452454
[limitations in how this assertion is implemented in PHPUnit]: https://github.com/sebastianbergmann/phpunit/issues/4707
453455

454-
<!--
455-
COMMENT: No documentation available (yet) for this assertion on the PHPUnit site.
456-
-->
456+
[`Assert::assertObjectEquals()`]: https://phpunit.readthedocs.io/en/stable/assertions.html#assertobjectequals
457+
457458

458459
### Helper traits
459460

@@ -687,6 +688,30 @@ Yes, this package can also be used when running tests via a PHPUnit Phar file.
687688
In that case, make sure that the `phpunitpolyfills-autoload.php` file is explicitly `require`d in the test bootstrap file.
688689
(Not necessary when the Composer `vendor/autoload.php` file is used as, or `require`d in, the test bootstrap.)
689690

691+
### Q: How can I verify the version used of the PHPUnit Polyfills library ?
692+
693+
For complex test setups, like when the Polyfills are provided via a test suite dependency, or may already be loaded via an overarching project, it can be useful to be able to check that a version of the package is used which complies with the requirements for your test suite.
694+
695+
As of version 1.0.1, the PHPUnit Polyfills `Autoload` class contains a version number which can be used for this purpose.
696+
697+
Typically such a check would be done in the test suite bootstrap file and could look something like this:
698+
```php
699+
$versionRequirement = '1.0.1';
700+
if ( class_exists( '\Yoast\PHPUnitPolyfills\Autoload' ) === false ) {
701+
require_once `vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php`;
702+
} elseif ( defined( '\Yoast\PHPUnitPolyfills\Autoload::VERSION' ) === false
703+
|| version_compare( \Yoast\PHPUnitPolyfills\Autoload::VERSION, $versionRequirement, '<' )
704+
) {
705+
echo 'Error: Version mismatch detected for the PHPUnit Polyfills. Please ensure that PHPUnit Polyfills ',
706+
$versionRequirement, ' or higher is loaded.', PHP_EOL;
707+
exit(1);
708+
} else {
709+
echo 'Error: Please run `composer update` before running the tests.' . PHP_EOL;
710+
echo 'You can still use a PHPUnit phar to run them, but the dependencies do need to be installed.', PHP_EOL;
711+
exit(1);
712+
}
713+
```
714+
690715

691716
Contributing
692717
------------

phpunitpolyfills-autoload.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
*/
1212
class Autoload {
1313

14+
/**
15+
* Version number.
16+
*
17+
* @var string
18+
*/
19+
const VERSION = '1.0.1';
20+
1421
/**
1522
* Loads a class.
1623
*

0 commit comments

Comments
 (0)