summaryrefslogtreecommitdiffstatshomepage
path: root/tests/phpunit/includes/phpunit6
diff options
context:
space:
mode:
authorSergey Biryukov <sergeybiryukov@git.wordpress.org>2019-01-28 14:10:24 +0000
committerSergey Biryukov <sergeybiryukov@git.wordpress.org>2019-01-28 14:10:24 +0000
commit001c6498e891fe62e69963a4f02383f9ce57763f (patch)
tree4750f8d976d0d61df313648826243c7f98c13614 /tests/phpunit/includes/phpunit6
parent639f66aadeced5d3c764e0db947ed144017559c6 (diff)
downloadwordpress-001c6498e891fe62e69963a4f02383f9ce57763f.tar.gz
wordpress-001c6498e891fe62e69963a4f02383f9ce57763f.zip
Build/Test Tools: Add support for PHPUnit 7.x.
* Create an abstract `WP_UnitTestCase_Base` class to share between PHPUnit 7.x and older versions. * Add a speed-trap loader to determine which `SpeedTrapListener` class needs to be loaded for the current PHPUnit version. * Remove unnecessary `PHPUnit\Util\Test` and `PHPUnit_Util_Getopt` inheritances. * Update Travis CI config to use PHPUnit 7.x for PHP 7.1, 7.2, and nightly PHP versions. Props jipmoors, netweb, desrosj, ayeshrajans, soulseekah, SergeyBiryukov. See #43218. git-svn-id: https://develop.svn.wordpress.org/trunk@44701 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'tests/phpunit/includes/phpunit6')
-rw-r--r--tests/phpunit/includes/phpunit6/compat.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/phpunit/includes/phpunit6/compat.php b/tests/phpunit/includes/phpunit6/compat.php
new file mode 100644
index 0000000000..54bd40510e
--- /dev/null
+++ b/tests/phpunit/includes/phpunit6/compat.php
@@ -0,0 +1,38 @@
+<?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\Error\Warning', 'PHPUnit_Framework_Error_Warning' );
+ 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 {
+
+ public static function getTickets( $className, $methodName ) {
+ $annotations = PHPUnit\Util\Test::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 );
+ }
+
+ }
+
+}