Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 5 additions & 26 deletions tests/phpunit/includes/abstract-testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,16 +584,10 @@ public function wp_die_handler( $message, $title, $args ) {
* @since 3.7.0
*/
public function expectDeprecated() {
if ( method_exists( $this, 'getAnnotations' ) ) {
// PHPUnit < 9.5.0.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm less concerned about this change than the removal of the aliases. However, I am wondering if this is worth leaving because someone could be using PHPUnit 9.4, 9.3, etc. Removing this would not be in the spirit of "PHPUnit 9 as the only version currently in use".

$annotations = $this->getAnnotations();
} else {
// PHPUnit >= 9.5.0.
$annotations = \PHPUnit\Util\Test::parseTestMethodAnnotations(
static::class,
$this->getName( false )
);
}
$annotations = \PHPUnit\Util\Test::parseTestMethodAnnotations(
static::class,
$this->getName( false )
);

foreach ( array( 'class', 'method' ) as $depth ) {
if ( ! empty( $annotations[ $depth ]['expectedDeprecated'] ) ) {
Expand Down Expand Up @@ -1372,21 +1366,6 @@ public function go_to( $url ) {
$GLOBALS['wp']->main( $parts['query'] );
}

/**
* Allows tests to be skipped on single or multisite installs by using @group annotations.
*
* This is a custom extension of the PHPUnit requirements handling.
*
* @since 3.5.0
* @deprecated 5.9.0 This method has not been functional since PHPUnit 7.0.
*/
protected function checkRequirements() {
// 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();
}
}

/**
* Skips the current test if there is an open Trac ticket associated with it.
*
Expand Down Expand Up @@ -1454,7 +1433,7 @@ public static function forceTicket( $ticket ) {
*/
public function prepareTemplate( Text_Template $template ) {
$template->setVar( array( 'constants' => '' ) );
$template->setVar( array( 'wp_constants' => PHPUnit_Util_GlobalState::getConstantsAsString() ) );
$template->setVar( array( 'wp_constants' => PHPUnit\Util\GlobalState::getConstantsAsString() ) );
parent::prepareTemplate( $template );
}

Expand Down
11 changes: 3 additions & 8 deletions tests/phpunit/includes/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@

$phpunit_version = tests_get_phpunit_version();

if ( version_compare( $phpunit_version, '5.7.21', '<' ) ) {
if ( version_compare( $phpunit_version, '9.0', '<' ) ) {
printf(
"Error: Looks like you're using PHPUnit %s. WordPress requires at least PHPUnit 5.7.21." . PHP_EOL,
"Error: Looks like you're using PHPUnit %s. WordPress requires PHPUnit 9.x." . PHP_EOL,
$phpunit_version
);
echo 'Please use the latest PHPUnit version supported for the PHP version you are running the tests on.' . PHP_EOL;
echo 'Please use the latest PHPUnit 9.x release supported for the PHP version you are running the tests on.' . PHP_EOL;
exit( 1 );
Comment thread
johnbillion marked this conversation as resolved.
}

Expand Down Expand Up @@ -308,11 +308,6 @@ function wp_tests_options( $value ) {
// Delete any default posts & related data.
_delete_all_posts();

// Load class aliases for compatibility with PHPUnit 6+.
if ( version_compare( tests_get_phpunit_version(), '6.0', '>=' ) ) {
require __DIR__ . '/phpunit6/compat.php';
}

require __DIR__ . '/phpunit-adapter-testcase.php';
require __DIR__ . '/abstract-testcase.php';
require __DIR__ . '/testcase.php';
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/includes/exceptions.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class WP_Tests_Exception extends PHPUnit_Framework_Exception {
class WP_Tests_Exception extends PHPUnit\Framework\Exception {

}

Expand Down
12 changes: 4 additions & 8 deletions tests/phpunit/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@
/**
* Retrieves PHPUnit runner version.
*
* @return double The version number.
* @return string The version number.
*/
function tests_get_phpunit_version() {
Comment thread
johnbillion marked this conversation as resolved.
if ( class_exists( 'PHPUnit\Runner\Version' ) ) {
$version = PHPUnit\Runner\Version::id();
} elseif ( class_exists( 'PHPUnit_Runner_Version' ) ) {
$version = PHPUnit_Runner_Version::id();
} else {
$version = 0;
if ( ! class_exists( 'PHPUnit\\Runner\\Version' ) ) {
return '0';
}

return $version;
return PHPUnit\Runner\Version::id();
}

/**
Expand Down
47 changes: 0 additions & 47 deletions tests/phpunit/includes/phpunit6/compat.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/phpunit/tests/admin/wpPrivacyRequestsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function tear_down() {
*
* @since 5.1.0
*
* @return PHPUnit_Framework_MockObject_MockObject|WP_Privacy_Requests_Table Mocked class instance.
* @return PHPUnit\Framework\MockObject\MockObject|WP_Privacy_Requests_Table Mocked class instance.
*/
public function get_mocked_class_instance() {
$args = array(
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/tests/includes/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function test_assertSameSets( $expected, $actual, $exception ) {
if ( $exception ) {
try {
$this->assertSameSets( $expected, $actual );
} catch ( PHPUnit_Framework_ExpectationFailedException $ex ) {
} catch ( PHPUnit\Framework\ExpectationFailedException $ex ) {
return;
}

Expand Down Expand Up @@ -211,7 +211,7 @@ public function test_assertSameSetsWithIndex( $expected, $actual, $exception ) {
if ( $exception ) {
try {
$this->assertSameSetsWithIndex( $expected, $actual );
} catch ( PHPUnit_Framework_ExpectationFailedException $ex ) {
} catch ( PHPUnit\Framework\ExpectationFailedException $ex ) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/widgets/wpWidgetMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function clean_up_global_scope() {
* @param string $name Name for the widget displayed on the configuration page.
* @param array $widget_options Optional. Widget options.
* @param array $control_options Optional. Widget control options.
* @return PHPUnit_Framework_MockObject_MockObject|WP_Widget_Media Mocked instance.
* @return PHPUnit\Framework\MockObject\MockObject|WP_Widget_Media Mocked instance.
*/
private function get_mocked_class_instance( $id_base = 'mocked', $name = 'Mocked', $widget_options = array(), $control_options = array() ) {
$original_class_name = 'WP_Widget_Media';
Expand Down
Loading