Build/Test Tools: Hard deprecate WP_UnitTestCase_Base::checkRequirements().

The `WP_UnitTestCase_Base::checkRequirements()` method calls the `parent::checkRequirements()` method, but this method became `private` in PHPUnit 7.0 via commit  [932238a6a3 sebastianbergmann/phpunit@932238a].

Aside from that, the `TestCase::getAnnotations()` method which is called next is now also removed in PHPUnit 9.5.

WP core does not use the method anymore, and the method only remains to prevent potentially breaking external integration tests relying on the method. However, in effect, the method is not functional anymore in PHPUnit 7.0+.

Follow-up to [893/tests], [894/tests], [896/tests], [918/tests], [30526], [40520], [40564], [43005], [44701], [51559-51577].

Props jrf.
See #46149.

git-svn-id: https://develop.svn.wordpress.org/trunk@51605 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2021-08-12 10:32:24 +00:00
parent 8df58341a5
commit 2985e902d4

View File

@@ -888,53 +888,13 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
*
* This is a custom extension of the PHPUnit requirements handling.
*
* Contains legacy code for skipping tests that are associated with an open Trac ticket.
* Core tests no longer support this behaviour.
*
* @since 3.5.0
* @deprecated 5.9.0 This method has not been functional since PHPUnit 7.0.
*/
protected function checkRequirements() {
parent::checkRequirements();
$annotations = $this->getAnnotations();
$groups = array();
if ( ! empty( $annotations['class']['group'] ) ) {
$groups = array_merge( $groups, $annotations['class']['group'] );
}
if ( ! empty( $annotations['method']['group'] ) ) {
$groups = array_merge( $groups, $annotations['method']['group'] );
}
if ( ! empty( $groups ) ) {
if ( in_array( 'ms-required', $groups, true ) ) {
$this->skipWithoutMultisite();
}
if ( in_array( 'ms-excluded', $groups, true ) ) {
$this->skipWithMultisite();
}
}
// Core tests no longer check against open Trac tickets,
// but others using WP_UnitTestCase may do so.
if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) {
return;
}
if ( WP_TESTS_FORCE_KNOWN_BUGS ) {
return;
}
$tickets = PHPUnit_Util_Test::getTickets( get_class( $this ), $this->getName( false ) );
foreach ( $tickets as $ticket ) {
if ( is_numeric( $ticket ) ) {
$this->knownWPBug( $ticket );
} elseif ( 0 === strpos( $ticket, 'Plugin' ) ) {
$ticket = substr( $ticket, 6 );
if ( $ticket && is_numeric( $ticket ) ) {
$this->knownPluginBug( $ticket );
}
}
// For PHPUnit 5/6, as we're overloading a public PHPUnit native method in those versions.
if ( is_callable( 'PHPUnit\Framework\TestCase', 'checkRequirements' ) ) {
parent::checkRequirements();
}
}
@@ -958,7 +918,6 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
* Skips the current test if there is an open Unit Test Trac ticket associated with it.
*
* @since 3.5.0
*
* @deprecated No longer used since the Unit Test Trac was merged into the Core Trac.
*
* @param int $ticket_id Ticket number.