Skip to content

Commit 2985e90

Browse files
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 [sebastianbergmann/phpunit@932238a 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
1 parent 8df5834 commit 2985e90

File tree

1 file changed

+4
-45
lines changed

1 file changed

+4
-45
lines changed

tests/phpunit/includes/abstract-testcase.php

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -888,53 +888,13 @@ public function go_to( $url ) {
888888
*
889889
* This is a custom extension of the PHPUnit requirements handling.
890890
*
891-
* Contains legacy code for skipping tests that are associated with an open Trac ticket.
892-
* Core tests no longer support this behaviour.
893-
*
894891
* @since 3.5.0
892+
* @deprecated 5.9.0 This method has not been functional since PHPUnit 7.0.
895893
*/
896894
protected function checkRequirements() {
897-
parent::checkRequirements();
898-
899-
$annotations = $this->getAnnotations();
900-
901-
$groups = array();
902-
if ( ! empty( $annotations['class']['group'] ) ) {
903-
$groups = array_merge( $groups, $annotations['class']['group'] );
904-
}
905-
if ( ! empty( $annotations['method']['group'] ) ) {
906-
$groups = array_merge( $groups, $annotations['method']['group'] );
907-
}
908-
909-
if ( ! empty( $groups ) ) {
910-
if ( in_array( 'ms-required', $groups, true ) ) {
911-
$this->skipWithoutMultisite();
912-
}
913-
914-
if ( in_array( 'ms-excluded', $groups, true ) ) {
915-
$this->skipWithMultisite();
916-
}
917-
}
918-
919-
// Core tests no longer check against open Trac tickets,
920-
// but others using WP_UnitTestCase may do so.
921-
if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) {
922-
return;
923-
}
924-
925-
if ( WP_TESTS_FORCE_KNOWN_BUGS ) {
926-
return;
927-
}
928-
$tickets = PHPUnit_Util_Test::getTickets( get_class( $this ), $this->getName( false ) );
929-
foreach ( $tickets as $ticket ) {
930-
if ( is_numeric( $ticket ) ) {
931-
$this->knownWPBug( $ticket );
932-
} elseif ( 0 === strpos( $ticket, 'Plugin' ) ) {
933-
$ticket = substr( $ticket, 6 );
934-
if ( $ticket && is_numeric( $ticket ) ) {
935-
$this->knownPluginBug( $ticket );
936-
}
937-
}
895+
// For PHPUnit 5/6, as we're overloading a public PHPUnit native method in those versions.
896+
if ( is_callable( 'PHPUnit\Framework\TestCase', 'checkRequirements' ) ) {
897+
parent::checkRequirements();
938898
}
939899
}
940900

@@ -958,7 +918,6 @@ public function knownWPBug( $ticket_id ) {
958918
* Skips the current test if there is an open Unit Test Trac ticket associated with it.
959919
*
960920
* @since 3.5.0
961-
*
962921
* @deprecated No longer used since the Unit Test Trac was merged into the Core Trac.
963922
*
964923
* @param int $ticket_id Ticket number.

0 commit comments

Comments
 (0)