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

Release version 2.0.0 #133

Merged
merged 71 commits into from
Jun 6, 2023
Merged

Release version 2.0.0 #133

merged 71 commits into from
Jun 6, 2023

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Jun 6, 2023

Functional

  • 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.
  • Update the VERSION constant in the phpunitpolyfills-autoload.php file. - PR Changelog and readme updates for the 2.0.0 release #132
  • Composer: check if any dependencies/version constraints need updating. - N/A

Release

  • Add changelog for the release - PR Changelog and readme updates for the 2.0.0 release #132
    Verify that a release link at the bottom of the CHANGELOG.md file has been added.
  • Merge this PR.
  • Make sure all CI builds are green.
  • Tag the release (careful, GH defaults to 2.x!).
  • Create a release from the tag (careful, GH defaults to 2.x!) & 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.

Sorry, something went wrong.

jrfnl and others added 30 commits March 31, 2023 01:51
Remove the `AssertNumericType` polyfill and all references to it.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Remove the `ExpectException` polyfill and all references to it.

Verified

This commit was signed with the committer’s verified signature.
aduh95 Antoine du Hamel
Remove the `AssertFileDirectory` polyfill and all references to it.

Verified

This commit was signed with the committer’s verified signature.
targos Michaël Zasso
Adjust CI, README and `composer.json` for the drop of support for PHPUnit 4.x.

Remove miscellaneous references to PHPUnit 4.x.

Verified

This commit was signed with the committer’s verified signature.
targos Michaël Zasso
Drop support for PHPUnit < 5.7 and PHP < 5.6

Verified

This commit was signed with the committer’s verified signature.
targos Michaël Zasso
... which is available since PHP 5.5 and can be used now support for PHP < 5.6 has been dropped.
PHPUnit 10.0 makes all assertion and exception methods `final`, so the PHPUnit Polyfills should follow suit.

There is one trait which I've exempted from this: `AssertClosedResource`, as when the methods in that trait (and the empty version of that trait) are made `final`, we'll run into trouble on PHPUnit < 9.x.

Note to self: [PHPCSExtra](https://github.com/PHPCSStandards/PHPCSExtra) 1.1.0 is expected to include a sniff which can enforce this. Once that release is available, that sniff should be added to the PHPCS ruleset to safeguard this.
PHPUnit 10 | Make all assertion/exception methods `final`

Verified

This commit was signed with the committer’s verified signature.
tpoisseau tpoisseau
This can (should) be sorted out via a local dev `phpunit.xml` overload file, not via a Composer script.
Composer: remove `coverage-local` script
Remove the `ExpectPHPException` polyfill and all references to it as support for expecting PHP native and user added deprecations, notices, warnings and errors has been dropped in PHPUnit 10.0.

PHP native Exceptions can still be tested using the `expectException()` method with the name of the PHP native Exception.

Refs:
* https://phpunit.de/announcements/phpunit-10.html
* https://github.com/sebastianbergmann/phpunit/blob/main/ChangeLog-10.0.md#1000---2023-02-03
* sebastianbergmann/phpunit#3775
* sebastianbergmann/phpunit#5062
* sebastianbergmann/phpunit@a2c784c
…eption-polyfill

PHPUnit 10 | Remove support for expecting PHP notices/exceptions
…sertStringEqualsStringIgnoringLineEndings() et al methods

PHPUnit 10.0.0 introduces the new `Assert::assertStringEqualsStringIgnoringLineEndings()` and `Assert::assertStringContainsStringIgnoringLineEndings()` methods.

This commit:
* Adds two traits with the same name.
    One to polyfill the methods when not available in PHPUnit.
    The other - an empty trait - to allow for `use`-ing the trait in PHPUnit versions in which the methods are already natively available.
* Logic to the custom autoloader which will load the correct trait depending on the PHPUnit version used.
* An availability test and limited functional test for the functionality polyfilled.

Note: the function name for the `private` `normalizeLineEndings()` method is a little convoluted - `normalizeLineEndingsForIgnoringLineEndingsAssertions()`.
This is intentional to prevent potential naming collisions with pre-existing end-user defined methods for the same, which may exist in other traits used in tests, which would be hard to solve due to the method only existing in the non-empty trait.

Includes:
* Adding the new polyfill to the existing `TestCases` classes.

Refs:
* sebastianbergmann/phpunit#4641
* sebastianbergmann/phpunit#4670 (and follow up commits)
* sebastianbergmann/phpunit#5279

Co-authored-by: Sergei Predvoditelev <sergey.predvoditelev@gmail.com>
Co-authored-by: Sebastian Bergmann <sb@sebastian-bergmann.de>
…inglineendingstrait

PHPUnit 10 | AssertIgnoringLineEndings trait: polyfill the Assert::assertStringEqualsStringIgnoringLineEndings() et al methods
…method

PHPUnit 10.0.0 introduces the new `Assert::assertIsList()` method.

This commit:
* Adds two traits with the same name.
    One to polyfill the methods when not available in PHPUnit.
    The other - an empty trait - to allow for `use`-ing the trait in PHPUnit versions in which the methods are already natively available.
* Logic to the custom autoloader which will load the correct trait depending on the PHPUnit version used.
* Functional tests for the functionality polyfilled.

Note: the methods use `static::` to call the PHPUnit native functionality. This allows for existing method overloads in a child class of the PHPUnit native `TestCase` to be respected.

Includes:
* Adding the new polyfill to the existing `TestCases` classes and adding a test for the polyfill availability to the `TestCaseTestTrait`.

Refs:
* sebastianbergmann/phpunit#4818
* sebastianbergmann/phpunit@71f5074
* sebastianbergmann/phpunit@e04a947
* sebastianbergmann/phpunit@2bc1aea

Co-authored-by: Jaroslav Hanslík <kukulich@kukulich.cz>
Co-authored-by: Sebastian Bergmann <sb@sebastian-bergmann.de>
…ttrait

PHPUnit 10 | AssertIsList trait: polyfill the Assert::assertIsList() method
The configuration file specification has undergone changes in PHPUnit 9.3 and 10.0.

Most notably:
* In PHPUnit 9.3, the manner of specifying the code coverage configuration has changed.
* In PHPUnit 10.0, a significant number of attributes of the `<phpunit>` element were removed or renamed.

While the `--migrate-configuration` command can upgrade a configuration for the changes in the format made in PHPUnit 9.3, some of the changes in the configuration format in PHPUnit 10 don't have one-on-one replacements and/or are not taken into account.

With that in mind, I deem it more appropriate to have a dedicated PHPUnit configuration file for PHPUnit 10 to ensure the test run will behave as intended.

This commit adds this dedicated configuration file for PHPUnit 10+.

Includes:
* Ignoring the new file for package archives.
* Allowing for a local override file.
* Adding scripts to the `composer.json` file to run the tests using this new configuration file.
* Updating the GH Actions `test` workflow to trigger the tests on PHPUnit 10 with this configuration file.

Take note that the `cacheDirectory` option has been set to the same value as PHPUnit natively already used in PHPUnit 8 and 9, even though this is a different value as is used by default in PHPUnit 10.

Ref:
* https://github.com/sebastianbergmann/phpunit/blob/main/ChangeLog-10.0.md#1000---2023-02-03
…fig-for-phpunit-10

Tests: add separate configuration file for PHPUnit 10
PR 102 removed support for the `ExpectException` polyfill.

These test fixtures belonged with that polyfill and were missed in the removal. They are now unused and should be removed.
…-after-102

Tests: remove some unused fixtures
... where appropriate.

This largely reverts commit 83ba7e3.
jrfnl and others added 27 commits May 1, 2023 01:09
The Dependabot PRs can have a tendency to stay open for a long time, while for the GH Actions and Composer dependency related ones I keep an eye on all used action runner releases anyway.

However, I don't "watch" all Yoast repos, so adding this configuration will ensure that I get notified about Dependabot PRs for this repo (and can merge it if appropriate or close it otherwise).
... to cover handling of custom error messages.
…add-extra-test

AssertIgnoringLineEndings: add extra test
Somewhere in the Remark toolchain something has changed which means that it now throws warnings about the cell padding for aligned tables.

As those aligned tables are by design (for readability during maintenance of the markdown), this commit is set up to removes those warnings and to enforce aligned tables.

Failing build: https://github.com/Yoast/PHPUnit-Polyfills/actions/runs/4977022049/jobs/8905635380

Refs:
* https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-table-pipe-alignment
* https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-table-cell-padding
This table wasn't aligned (yet) due to its size. Fixed now.
GH Actions: fix failing remark build
Looks like the `remark-lint` project has released a new version fixing the bug causing the failing build earlier this week.

This commit reverts the rule change from PR 124.

Refs:
* https://github.com/remarkjs/remark-lint/releases/tag/9.1.2
* remarkjs/remark-lint@639271a
GH Actions: tweaks for the markdown QA check
AssertIsListTest: minor tweaks for cross-version error message recognition
The initial PHPUnit Polyfills 2.0.0 release will not contain a PHPUnit 10 compatible TestListener implementation.

This allows the tests to pass on PHPUnit 10 for now until that has been resolved.

Refs:
* #95 (comment)
* #128
As the PHPUnit Polyfills, as of now, will officially support PHPUnit 10.x, with the exception of the TestListeners, the GH Actions workflow should be updated to reflect this.

This commit:
* Add builds for PHP 8.1 and 8.2 against low PHPUnit 10 versions.
    The "high" versions are automatically sorted via the matrix `auto` setting in combination with the Composer PHPUnit version requirements being widened.
* Add an extra experimental build against PHP 8.3 to ensure both PHPUnit 9.x as well as PHPUnit 10.x is tested with PHP 8.3.
* Update the experimental build against "future" PHPUnit to point to the `main` branch of PHPUnit.

Additionally, it updates the step which ran a "trial" build against PHPUnit 10 by splitting it into two steps: one with and one without coverage. Both are still allowed to fail when running the experimental build against PHPUnit `dev-main`.
As this package is used in the CI pipeline for other packages, it is important for this package to be ready for new PHP releases _early_, so failing the test suite on deprecations/notices and warnings is appropriate.

Apparently PHPUnit 10.0 already included a `failOnWarning` option, while PHPUnit 10.1 brings additional `failOnNotice` and `failOnDeprecation` options.

Unfortunately, these options are problematic for cross-version PHPUnit usage for the following reasons:
1. They do not translate to the same behaviour between PHPUnit < 10 and PHPUnit 10.x.
    In PHPUnit 9.x, the `convertDeprecationsToExceptions` and sister-options would only act on PHP native deprecations/notices/warnings and would cause a failed build with a non-zero exit code when set to `true` and any PHP deprecations/notices/warnings would be found.
    In PHPUnit 10.x, the `failOnWarning` and sister-options act on **_all_** deprecations/notices/warnings, not just the PHP native ones, and cause a failed build with a non-zero exit code when set to `true`.
    In practice, this means that when the `failOn*` options are used, PHPUnit native deprecations/notices/warnings will now also fail a build, which was not the case in PHPUnit < 10.
2. As the XML file is validated against the XSD file, this means that you cannot add the `failOnNotice`/`failOnDeprecation` options in a configuration file which will be used on PHPUnit 10.0 as that would fail the XSD validation, leading to a PHPUnit warning which would fail the build.
3. Along the same lines, as the `include`/`exclude` elements within the `coverage` element are deprecated as of PHPUnit 10.1, in favour of using `source` with `include`/`exclude`, a configuration which validates on PHPUnit 10.0 will not validate correctly on PHPUnit 10.1 leading to a deprecation notice, which would fail the build when `failOnDeprecation` is on.
... etc...

This basically means that if you want PHPUnit to fail a build on PHP native deprecations/notices/warnings (which you should want for open source projects, most definitely open source projects in the PHP tool chain), you will now no longer be allowed to have **_any_** PHPUnit deprecations/notices/warnings as those will now also fail the build.

It also means that a new release of PHPUnit can randomly start failing builds if a change was made in PHPUnit which causes a new deprecation/notice/warning to be thrown.

All in all, not pretty and it makes things a heck of a lot less stable, but it is what it is for now, so we better deal with it.

So, to get round this and to have the most optimal configuration for PHPUnit 10.x possible at this time....
1. The `failOnWarning` option is added to the `phpunit10.xml.dist` file as it is already available in PHPUnit 10.0.
2. A new "Migrate configuration" step needs to be added to the GH Actions test workflow.
    This step will migrate the `phpunit10.xml.dist` file, which is compatible with PHPUnit 10.0, to a version which is compatible with whichever PHPUnit 10.x version the tests are being run on.
    This step will fail when there is nothing to migrate, so it needs a `continue-on-error` to ignore that failure.
    Note: the migration step will also fail when the original XML file doesn't validate against the original XSD, which is why the base configuration needs to be for PHPUnit 10.0.
3. As for the `failOnNotice`/`failOnDeprecation` options: those cannot be added to the config for the above mentioned reasons (failure to validate against the PHPUnit 10.0 XSD), but they also cannot be added to the "default" command used for running the tests on PHPUnit 10 as a run against PHPUnit 10.0 would then fail with an "Unknown option ...." error.
    In other words, the only realistic way to add these, for now, is to add them to the command on the fly for those test runs where PHPUnit 10.1 or higher will be used.

Refs:
* sebastianbergmann/phpunit 5196
* sebastianbergmann/phpunit@fb6673f
…and-ci

Composer: allow PHPUnit 10.x + update CI to match
... as those won't work until a release has been tagged and cause release PR builds to fail.
…compare-links

RemarkLint: ignore version release compare links
Includes:
* Adding a warning about the TestListener polyfill not (yet) being compatible with PHPUnit 10.
* Adding links to the documentation of some assertions, which are documented in the PHPUnit 10 documentation, but were previously undocumented.
* Updating all links to the PHPUnit documentation to point to the PHPUnit 10 docs instead of the PHPUnit 9 docs.
Includes updating the `VERSION` constant in the `Autoload` class.

Includes minor punctuation fixes to older changelog entries.
Changelog and readme updates for the 2.0.0 release
@jrfnl jrfnl added this to the 2.0.0 milestone Jun 6, 2023
@jrfnl jrfnl merged commit c758753 into main Jun 6, 2023
@jrfnl
Copy link
Collaborator Author

jrfnl commented Jun 6, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant