Skip to content

Commit 7a22391

Browse files
committed
Make sure PHPUnit_Framework_TestCase doesn't already exist.
1 parent 3d575e9 commit 7a22391

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

tests/phpunit/bootstrap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
$test_root = '../../../../../../../tests/phpunit';
2222
}
2323

24+
// WordPress versions before 4.8 will be incompatible with newer PHPUnit versions.
2425
if ( version_compare( getenv( 'WP_VERSION' ), '4.8', '<' ) && class_exists( 'PHPUnit\Runner\Version' ) ) {
2526
require_once dirname( __FILE__ ) . '/phpunit6-compat.php';
2627
}

tests/phpunit/phpunit6-compat.php

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

0 commit comments

Comments
 (0)