Skip to content

Commit 6f58f17

Browse files
committed
Try checking for an existing compat file.
1 parent 7a22391 commit 6f58f17

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

tests/phpunit/bootstrap.php

+8-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
2121
$test_root = '../../../../../../../tests/phpunit';
2222
}
2323

24-
// WordPress versions before 4.8 will be incompatible with newer PHPUnit versions.
25-
if ( version_compare( getenv( 'WP_VERSION' ), '4.8', '<' ) && class_exists( 'PHPUnit\Runner\Version' ) ) {
26-
require_once dirname( __FILE__ ) . '/phpunit6-compat.php';
27-
}
28-
2924
if ( file_exists( $test_root . '/includes/functions.php' ) ) {
3025
require_once $test_root . '/includes/functions.php';
3126
function _manually_load_plugin() {
@@ -35,4 +30,12 @@ function _manually_load_plugin() {
3530
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
3631
}
3732

33+
// Core started including their own phpunit6-compat, so we should use that if we can.
34+
if ( ! file_exists( $test_root . '/includes/phpunit6-compat.php' ) ) {
35+
// WordPress versions before 4.8 will be incompatible with newer PHPUnit versions.
36+
if ( version_compare( getenv( 'WP_VERSION' ), '4.8', '<' ) && class_exists( 'PHPUnit\Runner\Version' ) ) {
37+
require_once dirname( __FILE__ ) . '/phpunit6-compat.php';
38+
}
39+
}
40+
3841
require $test_root . '/includes/bootstrap.php';

tests/phpunit/phpunit6-compat.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<?php
2-
if (
3-
class_exists( 'PHPUnit\Runner\Version' ) &&
4-
version_compare( PHPUnit\Runner\Version::id(), '6.0', '>=' ) &&
5-
! class_exists( 'PHPUnit_Framework_TestCase' ) ) {
2+
if ( class_exists( 'PHPUnit\Runner\Version' ) && version_compare( PHPUnit\Runner\Version::id(), '6.0', '>=' ) ) {
63
class_alias( 'PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase' );
74
class_alias( 'PHPUnit\Framework\Exception', 'PHPUnit_Framework_Exception' );
85
class_alias( 'PHPUnit\Framework\ExpectationFailedException', 'PHPUnit_Framework_ExpectationFailedException' );

0 commit comments

Comments
 (0)