Build/Test Tools: Backport various recent changes to the 4.7 branch.
* Add support for PHPUnit 6+. * Add Composer files to the cache on Travis. * Remove HHVM from the test infrastructure on Travis. Merges [40536], [40538], [40539], and [40546] to the 4.7 branch. See #40539 Fixes #39822, #40548 git-svn-id: https://develop.svn.wordpress.org/branches/4.7@40547 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a82fe2b598
commit
8cbc520a94
27
.travis.yml
27
.travis.yml
|
@ -4,6 +4,8 @@ cache:
|
|||
apt: true
|
||||
directories:
|
||||
- node_modules
|
||||
- vendor
|
||||
- $HOME/.composer/cache
|
||||
env:
|
||||
global:
|
||||
- WP_TRAVISCI=travis:phpunit
|
||||
|
@ -21,19 +23,8 @@ matrix:
|
|||
- php: 5.4
|
||||
- php: 5.3
|
||||
- php: 5.2
|
||||
- php: hhvm
|
||||
sudo: required
|
||||
dist: trusty
|
||||
group: edge
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- mysql-server-5.6
|
||||
- mysql-client-core-5.6
|
||||
- mysql-client-5.6
|
||||
- php: nightly
|
||||
allow_failures:
|
||||
- php: hhvm
|
||||
- php: nightly
|
||||
before_install:
|
||||
- |
|
||||
|
@ -52,7 +43,7 @@ before_install:
|
|||
fi
|
||||
before_script:
|
||||
- |
|
||||
# Remove Xdebug for a huge performance increase, but not from nightly or hhvm:
|
||||
# Remove Xdebug for a huge performance increase, but not from nightly:
|
||||
stable='^[0-9\.]+$'
|
||||
if [[ "$TRAVIS_PHP_VERSION" =~ $stable ]]; then
|
||||
phpenv config-rm xdebug.ini
|
||||
|
@ -67,9 +58,9 @@ before_script:
|
|||
# Install the specified version of PHPUnit depending on the PHP version:
|
||||
if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
|
||||
case "$TRAVIS_PHP_VERSION" in
|
||||
7.1|7.0|hhvm|nightly)
|
||||
echo "Using PHPUnit 5.7"
|
||||
composer global require "phpunit/phpunit=5.7.*"
|
||||
7.1|7.0|nightly)
|
||||
echo "Using PHPUnit 6.1"
|
||||
composer global require "phpunit/phpunit=6.1.*"
|
||||
;;
|
||||
5.6|5.5|5.4|5.3)
|
||||
echo "Using PHPUnit 4.8"
|
||||
|
@ -94,11 +85,7 @@ before_script:
|
|||
- mysql --version
|
||||
- phpenv versions
|
||||
- php --version
|
||||
- |
|
||||
# Debug PHP extensions, but not on HHVM because the command hangs indefinitely:
|
||||
if [[ "$TRAVIS_PHP_VERSION" != 'hhvm' ]]; then
|
||||
php -m
|
||||
fi
|
||||
- php -m
|
||||
- npm --version
|
||||
- node --version
|
||||
- which phpunit
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
* Installs WordPress for running the tests and loads WordPress and the test libraries
|
||||
*/
|
||||
|
||||
/**
|
||||
* Compatibility with PHPUnit 6+
|
||||
*/
|
||||
if ( class_exists( 'PHPUnit\Runner\Version' ) ) {
|
||||
require_once dirname( __FILE__ ) . '/phpunit6-compat.php';
|
||||
}
|
||||
|
||||
$config_file_path = dirname( dirname( __FILE__ ) );
|
||||
if ( ! file_exists( $config_file_path . '/wp-tests-config.php' ) ) {
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -200,4 +200,25 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase {
|
|||
if ( !empty( $buffer ) )
|
||||
$this->_last_response = $buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPUnit 6+ compatibility shim.
|
||||
*
|
||||
* @param mixed $exception
|
||||
* @param string $message
|
||||
* @param int|string $code
|
||||
*/
|
||||
public function setExpectedException( $exception, $message = '', $code = null ) {
|
||||
if ( is_callable( 'parent::setExpectedException' ) ) {
|
||||
parent::setExpectedException( $exception, $message, $code );
|
||||
} else {
|
||||
$this->expectException( $exception );
|
||||
if ( '' !== $message ) {
|
||||
$this->expectExceptionMessage( $message );
|
||||
}
|
||||
if ( null !== $code ) {
|
||||
$this->expectExceptionCode( $code );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue