From 2985e902d4f117ad9162fdc8317644787376295a Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 12 Aug 2021 10:32:24 +0000 Subject: [PATCH] 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 [https://github.com/sebastianbergmann/phpunit/commit/932238a6a3018cdfac6c2a7d8f1d5d49e65f5dc0 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 --- tests/phpunit/includes/abstract-testcase.php | 49 ++------------------ 1 file changed, 4 insertions(+), 45 deletions(-) diff --git a/tests/phpunit/includes/abstract-testcase.php b/tests/phpunit/includes/abstract-testcase.php index a169754c69..3a9031d11b 100644 --- a/tests/phpunit/includes/abstract-testcase.php +++ b/tests/phpunit/includes/abstract-testcase.php @@ -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.