From 884de9fdf570873ceda8a680d9ca6eedaadc51f8 Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Wed, 11 Aug 2021 07:32:22 +0200
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.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.0.

WP Core doesn't 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 knowing the above.

So, I'm proposing to hard deprecate the method, effectively rendering it useless, except to prevent breaking test suites which still called the method.
---
 tests/phpunit/includes/abstract-testcase.php | 45 ++------------------
 1 file changed, 4 insertions(+), 41 deletions(-)

diff --git a/tests/phpunit/includes/abstract-testcase.php b/tests/phpunit/includes/abstract-testcase.php
index a169754c69..502abe881c 100644
--- a/tests/phpunit/includes/abstract-testcase.php
+++ b/tests/phpunit/includes/abstract-testcase.php
@@ -892,49 +892,12 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
 	 * Core tests no longer support this behaviour.
 	 *
 	 * @since 3.5.0
+	 * @deprecated 5.9.0 This function hasn't 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();
 		}
 	}
 
-- 
2.32.0.windows.2

