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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test environment to PHPUnit 10 #212

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"require-dev": {
"phpstan/phpstan": "1.9.2 || 1.4.10",
"phpunit/phpunit": "^9.5 || ^7.5",
"phpunit/phpunit": "^10 || ^9.5 || ^7.5",
"psr/container": "^2 || ^1"
},
"autoload": {
Expand Down
9 changes: 4 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- PHPUnit configuration file with new format for PHPUnit 9.5+ -->
<!-- PHPUnit configuration file with new format for current PHPUnit -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResult="false"
colors="true"
convertDeprecationsToExceptions="true">
colors="true">
Comment on lines -9 to +8
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can approve this pull request, but I think we should mention that we might loose future visibility of deprecation notices. I looked a bit further into this.

In the changelog for PHPUnit 10 it says the following:

Removed the convertDeprecationsToExceptions attribute on the XML configuration element as well as the feature it used to control

So it seems we can't use convertDeprecationsToExceptions anymore, but there is a new option called displayDetailsOnTestsThatTriggerDeprecations. Not sure if this will have the same effect tho.

One solution to this could be to add another phpunit.xml specifically for PHPUnit 9 (PHP >= 7.3), but this feels kind of dirty, what do you think?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Agree that we'd want to keep this functionality, fortunately looks like this might be re-introduced in PHPUnit 10.1 again via sebastianbergmann/phpunit#5196

We can keep this open until the upstream ticket is resolved, looks like we'll need to use separate XML configurations for PHPUnit 10, PHPUnit 9 and older in either case to support the current range of PHP versions. Not a fan of this, but fine, if that's what it takes.

<testsuites>
<testsuite name="Framework X test suite">
<directory>./tests/</directory>
Expand All @@ -21,7 +20,7 @@
<php>
<ini name="error_reporting" value="-1" />
<!-- Evaluate assertions, requires running with "php -d zend.assertions=1 vendor/bin/phpunit" -->
<!-- <ini name="zend.assertions=1" value="1" /> -->
<!-- <ini name="zend.assertions" value="1" /> -->
<ini name="assert.active" value="1" />
<ini name="assert.exception" value="1" />
<ini name="assert.bail" value="0" />
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml.legacy
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- PHPUnit configuration file with old PHPUnit 7 format for PHP < 7.3 -->
<!-- PHPUnit configuration file with old format for legacy PHPUnit -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
Expand All @@ -19,7 +19,7 @@
<php>
<ini name="error_reporting" value="-1" />
<!-- Evaluate assertions, requires running with "php -d zend.assertions=1 vendor/bin/phpunit" -->
<!-- <ini name="zend.assertions=1" value="1" /> -->
<!-- <ini name="zend.assertions" value="1" /> -->
<ini name="assert.active" value="1" />
<ini name="assert.exception" value="1" />
<ini name="assert.bail" value="0" />
Expand Down
2 changes: 1 addition & 1 deletion tests/AppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1902,7 +1902,7 @@ public function testHandleRequestWithMatchingRouteReturnsInternalServerErrorResp
$this->assertStringMatchesFormat("%a<p>Expected request handler to return <code>Psr\Http\Message\ResponseInterface</code> but got uncaught <code>BadMethodCallException</code> with message <code>Request handler class UnknownClass not found</code> in <code title=\"See %s\">Container.php:%d</code>.</p>\n%a", (string) $response->getBody());
}

public function provideInvalidClasses(): \Generator
public static function provideInvalidClasses(): \Generator
{
yield [
InvalidConstructorPrivate::class,
Expand Down
2 changes: 1 addition & 1 deletion tests/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ public function __invoke(): ResponseInterface
}

/** @return list<list<\stdClass|string|null>> */
public function provideMixedValue(): array
public static function provideMixedValue(): array
{
return [
[
Expand Down
4 changes: 2 additions & 2 deletions tests/ErrorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ public function testRequestProxyUnsupportedReturnsError400(): void
}

/** @return list<list<string>> */
public function provideExceptionMessage(): array
public static function provideExceptionMessage(): array
{
return [
[
Expand Down Expand Up @@ -459,7 +459,7 @@ public function testErrorInvalidExceptionReturnsError500(string $in, string $exp
}

/** @return list<list<mixed>> */
public function provideInvalidReturnValue(): array
public static function provideInvalidReturnValue(): array
{
return [
[
Expand Down
2 changes: 1 addition & 1 deletion tests/Io/HtmlHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function testEscapeHtml(string $in, string $expected): void
}

/** @return list<list<string>> */
public function provideNames(): array
public static function provideNames(): array
{
return [
[
Expand Down