Skip to content

Commit 3d575e9

Browse files
committed
Add phpunit compat file back.
1 parent 61d2415 commit 3d575e9

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

tests/phpunit/bootstrap.php

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

24+
if ( version_compare( getenv( 'WP_VERSION' ), '4.8', '<' ) && class_exists( 'PHPUnit\Runner\Version' ) ) {
25+
require_once dirname( __FILE__ ) . '/phpunit6-compat.php';
26+
}
27+
2428
if ( file_exists( $test_root . '/includes/functions.php' ) ) {
2529
require_once $test_root . '/includes/functions.php';
2630
function _manually_load_plugin() {

tests/phpunit/phpunit6-compat.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
if ( class_exists( 'PHPUnit\Runner\Version' ) && version_compare( PHPUnit\Runner\Version::id(), '6.0', '>=' ) ) {
3+
class_alias( 'PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase' );
4+
class_alias( 'PHPUnit\Framework\Exception', 'PHPUnit_Framework_Exception' );
5+
class_alias( 'PHPUnit\Framework\ExpectationFailedException', 'PHPUnit_Framework_ExpectationFailedException' );
6+
class_alias( 'PHPUnit\Framework\Error\Notice', 'PHPUnit_Framework_Error_Notice' );
7+
class_alias( 'PHPUnit\Framework\Error\Warning', 'PHPUnit_Framework_Error_Warning' );
8+
class_alias( 'PHPUnit\Framework\Test', 'PHPUnit_Framework_Test' );
9+
class_alias( 'PHPUnit\Framework\Warning', 'PHPUnit_Framework_Warning' );
10+
class_alias( 'PHPUnit\Framework\AssertionFailedError', 'PHPUnit_Framework_AssertionFailedError' );
11+
class_alias( 'PHPUnit\Framework\TestSuite', 'PHPUnit_Framework_TestSuite' );
12+
class_alias( 'PHPUnit\Framework\TestListener', 'PHPUnit_Framework_TestListener' );
13+
class_alias( 'PHPUnit\Util\GlobalState', 'PHPUnit_Util_GlobalState' );
14+
class_alias( 'PHPUnit\Util\Getopt', 'PHPUnit_Util_Getopt' );
15+
class PHPUnit_Util_Test extends PHPUnit\Util\Test {
16+
public static function getTickets( $className, $methodName ) {
17+
$annotations = self::parseTestMethodAnnotations( $className, $methodName );
18+
$tickets = array();
19+
if ( isset( $annotations['class']['ticket'] ) ) {
20+
$tickets = $annotations['class']['ticket'];
21+
}
22+
if ( isset( $annotations['method']['ticket'] ) ) {
23+
$tickets = array_merge( $tickets, $annotations['method']['ticket'] );
24+
}
25+
return array_unique( $tickets );
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)