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

PHP 8.0, 8.1, PHPUnit 9 support #2332

Closed
wants to merge 1 commit into from
Closed

Conversation

27pchrisl
Copy link
Contributor

@27pchrisl 27pchrisl commented Oct 11, 2021

Description of changes:

This PR adds support for running tests against PHP 8.0 and 8.1, and upgrades to PHPUnit 9 (for supported PHP versions).

The changes implement polyfills for older PHPUnit versions to add missing 9.x methods, and restores older methods that newer PHPUnit versions removed. This is implemented through the PHPUnitCompatTrait, dynamically selected in bootstrap.php.

As PHPUnit 9 added the void return type to setUp, tearDown, setUpBeforeClass and tearDownAfterClass, the polyfills provide _-prefixed versions of these methods to support all PHP versions (eg _setUp).

The only actual failing src code in 8.0/8.1 was the same as fixed in #2331. All other changes are only to the test suite. I'm commenting below on notable changes.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

colors="true">

<php>
<!-- Specify the path to your CloudFront private key -->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was removed in favour of a change to the suite that enables this to run without any configuration

@@ -23,7 +23,11 @@ class DateTimeResult extends \DateTime implements \JsonSerializable
*/
public static function fromEpoch($unixTimestamp)
{
return new self(gmdate('c', $unixTimestamp));
if (!is_numeric($unixTimestamp)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same change as in #2331

@@ -1,65 +1,64 @@
<?php
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes here use a private key fixture

@@ -90,7 +90,7 @@ public function testCorrectlyOutputsHost(
});

$handler = $list->resolve();
$handler($command, new Request('POST', $endpoint));
$handler($command, new Request('POST', $endpoint))->wait(false);
Copy link
Contributor Author

@27pchrisl 27pchrisl Oct 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes an issue that only showed itself in Guzzle or PHP 8.x

{
}

public function setUp(): void
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHPUnit 9 added the void return type here, needing the polyfilled behaviour to compile on earlier PHP versions


if (!class_exists('\PHPUnit\Framework\Constraint\RegularExpression')) {
if ( ! defined('PHPUNIT_COMPOSER_INSTALL')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To support the @runInSeparateProcess annotation

@stobrien89
Copy link
Member

stobrien89 commented Apr 5, 2022

Hi @27pchrisl,

Going to close this in favor of #2403. We want to get it merged relatively soon.

@stobrien89 stobrien89 closed this Apr 5, 2022
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

2 participants