mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-30 02:04:26 +00:00
Build/Test Tools: Add support for PHPUnit 6+.
This adds a compatibility shim for the new namespaced structure of PHPUnit and the removed `setExpectedException()` method. In addition, this updates the Travis config so PHPUnit 6.1 is used where appropriate. Props miyauchi, gitlost. Fixes #39822 git-svn-id: https://develop.svn.wordpress.org/trunk@40536 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
37
tests/phpunit/includes/phpunit6-compat.php
Normal file
37
tests/phpunit/includes/phpunit6-compat.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
if ( class_exists( 'PHPUnit\Runner\Version' ) && version_compare( PHPUnit\Runner\Version::id(), '6.0', '>=' ) ) {
|
||||
|
||||
class_alias( 'PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase' );
|
||||
class_alias( 'PHPUnit\Framework\Exception', 'PHPUnit_Framework_Exception' );
|
||||
class_alias( 'PHPUnit\Framework\ExpectationFailedException', 'PHPUnit_Framework_ExpectationFailedException' );
|
||||
class_alias( 'PHPUnit\Framework\Error\Notice', 'PHPUnit_Framework_Error_Notice' );
|
||||
class_alias( 'PHPUnit\Framework\Test', 'PHPUnit_Framework_Test' );
|
||||
class_alias( 'PHPUnit\Framework\Warning', 'PHPUnit_Framework_Warning' );
|
||||
class_alias( 'PHPUnit\Framework\AssertionFailedError', 'PHPUnit_Framework_AssertionFailedError' );
|
||||
class_alias( 'PHPUnit\Framework\TestSuite', 'PHPUnit_Framework_TestSuite' );
|
||||
class_alias( 'PHPUnit\Framework\TestListener', 'PHPUnit_Framework_TestListener' );
|
||||
class_alias( 'PHPUnit\Util\GlobalState', 'PHPUnit_Util_GlobalState' );
|
||||
class_alias( 'PHPUnit\Util\Getopt', 'PHPUnit_Util_Getopt' );
|
||||
|
||||
class PHPUnit_Util_Test extends PHPUnit\Util\Test {
|
||||
|
||||
public static function getTickets( $className, $methodName ) {
|
||||
$annotations = self::parseTestMethodAnnotations( $className, $methodName );
|
||||
|
||||
$tickets = array();
|
||||
|
||||
if ( isset( $annotations['class']['ticket'] ) ) {
|
||||
$tickets = $annotations['class']['ticket'];
|
||||
}
|
||||
|
||||
if ( isset( $annotations['method']['ticket'] ) ) {
|
||||
$tickets = array_merge( $tickets, $annotations['method']['ticket'] );
|
||||
}
|
||||
|
||||
return array_unique( $tickets );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user