[wp-trac] [WordPress Trac] #46149: PHPUnit 8.x support
WordPress Trac
noreply at wordpress.org
Tue May 5 10:59:27 UTC 2020
#46149: PHPUnit 8.x support
------------------------------+-----------------------------
Reporter: SergeyBiryukov | Owner: netweb
Type: task (blessed) | Status: assigned
Priority: normal | Milestone: Future Release
Component: Build/Test Tools | Version:
Severity: normal | Resolution:
Keywords: needs-patch | Focuses:
------------------------------+-----------------------------
Old description:
> Background: #43218
>
> PHPUnit 8.0.0 is scheduled for February 2019. The
> [https://github.com/sebastianbergmann/phpunit/blob/master/ChangeLog-8.0.md
> changelog] includes some backwards compatibility breaks.
>
> From the [https://phpunit.de/announcements/phpunit-7.html PHPUnit 7
> announcement] (February 2, 2018):
> > **Looking Forward**
> >
> > The following methods do not have a return value and should therefore
> have a `void` return type declaration:
> >
> > * `PHPUnit\Framework\TestCase::setUpBeforeClass()`
> > * `PHPUnit\Framework\TestCase::setUp()`
> > * `PHPUnit\Framework\TestCase::assertPreConditions()`
> > * `PHPUnit\Framework\TestCase::assertPostConditions()`
> > * `PHPUnit\Framework\TestCase::tearDown()`
> > * `PHPUnit\Framework\TestCase::tearDownAfterClass()`
> > * `PHPUnit\Framework\TestCase::onNotSuccessfulTest()`
> >
> > These methods will have a `void` return type declaration in PHPUnit 8.
> Please declare your methods that overwrite the above mentioned methods
> `void` now so you are not affected by this backward compatibility break.
>
> This is now [https://github.com/sebastianbergmann/phpunit/issues/3288
> implemented in PHPUnit 8], so our method signatures are no longer
> compatible and cause fatal errors:
> > `Fatal error: Declaration of WP_UnitTestCase_Base::setUpBeforeClass()
> must be compatible with PHPUnit\Framework\TestCase::setUpBeforeClass():
> void in tests/phpunit/includes/abstract-testcase.php on line 1110`
>
> We could look into using different signatures for different PHPUnit
> versions in the same way as in [44701]. However, given the large number
> of tests extending the `::setUp()` and `::tearDown()` methods, it's
> probably easier to address this when we
> [https://make.wordpress.org/core/2018/12/08/updating-the-minimum-php-
> version/ bump the required PHP version to 7].
New description:
Background: #43218
PHPUnit 8.0.0 is scheduled for February 2019. The
[https://github.com/sebastianbergmann/phpunit/blob/master/ChangeLog-8.0.md
changelog] includes some backwards compatibility breaks.
From the [https://phpunit.de/announcements/phpunit-7.html PHPUnit 7
announcement] (February 2, 2018):
> **Looking Forward**
>
> The following methods do not have a return value and should therefore
have a `void` return type declaration:
>
> * `PHPUnit\Framework\TestCase::setUpBeforeClass()`
> * `PHPUnit\Framework\TestCase::setUp()`
> * `PHPUnit\Framework\TestCase::assertPreConditions()`
> * `PHPUnit\Framework\TestCase::assertPostConditions()`
> * `PHPUnit\Framework\TestCase::tearDown()`
> * `PHPUnit\Framework\TestCase::tearDownAfterClass()`
> * `PHPUnit\Framework\TestCase::onNotSuccessfulTest()`
>
> These methods will have a `void` return type declaration in PHPUnit 8.
Please declare your methods that overwrite the above mentioned methods
`void` now so you are not affected by this backward compatibility break.
This is now [https://github.com/sebastianbergmann/phpunit/issues/3288
implemented in PHPUnit 8], so our method signatures are no longer
compatible and cause fatal errors:
> `Fatal error: Declaration of WP_UnitTestCase_Base::setUpBeforeClass()
must be compatible with PHPUnit\Framework\TestCase::setUpBeforeClass():
void in tests/phpunit/includes/abstract-testcase.php on line 1110`
We could look into using different signatures for different PHPUnit
versions in the same way as in [44701]. However, given the large number of
tests extending the `::setUp()` and `::tearDown()` methods, it's probably
easier to address this when we [https://make.wordpress.org/core/2018/12/08
/updating-the-minimum-php-version/ bump the required PHP version to 7.1].
--
Comment (by SergeyBiryukov):
Replying to [comment:11 SergeyBiryukov]:
> Note that this still depends on bumping the required PHP version to 7.
Just to clarify, bumping the required version to PHP 7.0 is apparently not
enough, as the `void` return type declarations
[https://www.php.net/manual/en/migration71.new-features.php only appeared
in PHP 7.1]. So to support PHPUnit 8.x, we'd need PHP 7.1 as the minimum
required version.
Updating the ticket description accordingly.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46149#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list