Code is Poetry.

WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.



git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast
2017-11-30 23:09:33 +00:00
parent ec6a089f98
commit 8f95800d52
1103 changed files with 105981 additions and 78187 deletions

View File

@@ -13,8 +13,9 @@ if ( class_exists( 'PHPUnit\Runner\Version' ) ) {
$config_file_path = dirname( dirname( __FILE__ ) );
if ( ! file_exists( $config_file_path . '/wp-tests-config.php' ) ) {
// Support the config file from the root of the develop repository.
if ( basename( $config_file_path ) === 'phpunit' && basename( dirname( $config_file_path ) ) === 'tests' )
if ( basename( $config_file_path ) === 'phpunit' && basename( dirname( $config_file_path ) ) === 'tests' ) {
$config_file_path = dirname( dirname( $config_file_path ) );
}
}
$config_file_path .= '/wp-tests-config.php';
@@ -38,8 +39,9 @@ define( 'DIR_TESTDATA', dirname( __FILE__ ) . '/../data' );
define( 'WP_LANG_DIR', DIR_TESTDATA . '/languages' );
if ( ! defined( 'WP_TESTS_FORCE_KNOWN_BUGS' ) )
if ( ! defined( 'WP_TESTS_FORCE_KNOWN_BUGS' ) ) {
define( 'WP_TESTS_FORCE_KNOWN_BUGS', false );
}
// Cron tries to make an HTTP request to the blog, which always fails, because tests are run in CLI mode only
define( 'DISABLE_WP_CRON', true );
@@ -53,7 +55,7 @@ $PHP_SELF = $GLOBALS['PHP_SELF'] = $_SERVER['PHP_SELF'] = '/index.php';
// Should we run in multisite mode?
$multisite = '1' == getenv( 'WP_MULTISITE' );
$multisite = $multisite || ( defined( 'WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE );
$multisite = $multisite || ( defined( 'WP_TESTS_MULTISITE' ) && WP_TESTS_MULTISITE );
$multisite = $multisite || ( defined( 'MULTISITE' ) && MULTISITE );
// Override the PHPMailer
@@ -71,12 +73,12 @@ if ( 0 !== $retval ) {
}
if ( $multisite ) {
echo "Running as multisite..." . PHP_EOL;
echo 'Running as multisite...' . PHP_EOL;
defined( 'MULTISITE' ) or define( 'MULTISITE', true );
defined( 'SUBDOMAIN_INSTALL' ) or define( 'SUBDOMAIN_INSTALL', false );
$GLOBALS['base'] = '/';
} else {
echo "Running as single site... To run multisite, use -c tests/phpunit/multisite.xml" . PHP_EOL;
echo 'Running as single site... To run multisite, use -c tests/phpunit/multisite.xml' . PHP_EOL;
}
unset( $multisite );
@@ -86,14 +88,14 @@ tests_add_filter( 'wp_die_handler', '_wp_die_handler_filter' );
// Preset WordPress options defined in bootstrap file.
// Used to activate themes, plugins, as well as other settings.
if(isset($GLOBALS['wp_tests_options'])) {
if ( isset( $GLOBALS['wp_tests_options'] ) ) {
function wp_tests_options( $value ) {
$key = substr( current_filter(), strlen( 'pre_option_' ) );
return $GLOBALS['wp_tests_options'][$key];
return $GLOBALS['wp_tests_options'][ $key ];
}
foreach ( array_keys( $GLOBALS['wp_tests_options'] ) as $key ) {
tests_add_filter( 'pre_option_'.$key, 'wp_tests_options' );
tests_add_filter( 'pre_option_' . $key, 'wp_tests_options' );
}
}
@@ -142,8 +144,7 @@ class WP_PHPUnit_Util_Getopt extends PHPUnit_Util_Getopt {
if ( strlen( $arg ) > 1 && $arg[0] === '-' && $arg[1] === '-' ) {
PHPUnit_Util_Getopt::parseLongOption( substr( $arg, 2 ), $this->longOptions, $options, $argv );
}
}
catch ( PHPUnit_Framework_Exception $e ) {
} catch ( PHPUnit_Framework_Exception $e ) {
// Enforcing recognized arguments or correctly formed arguments is
// not really the concern here.
continue;
@@ -151,19 +152,19 @@ class WP_PHPUnit_Util_Getopt extends PHPUnit_Util_Getopt {
}
$skipped_groups = array(
'ajax' => true,
'ms-files' => true,
'ajax' => true,
'ms-files' => true,
'external-http' => true,
);
foreach ( $options as $option ) {
switch ( $option[0] ) {
case '--exclude-group' :
case '--exclude-group':
foreach ( $skipped_groups as $group_name => $skipped ) {
$skipped_groups[ $group_name ] = false;
}
continue 2;
case '--group' :
case '--group':
$groups = explode( ',', $option[1] );
foreach ( $groups as $group ) {
if ( is_numeric( $group ) || preg_match( '/^(UT|Plugin)\d+$/', $group ) ) {
@@ -191,6 +192,6 @@ class WP_PHPUnit_Util_Getopt extends PHPUnit_Util_Getopt {
echo 'If this changeset includes changes to HTTP, make sure there are no timeouts.' . PHP_EOL;
echo PHP_EOL;
}
}
}
}
new WP_PHPUnit_Util_Getopt( $_SERVER['argv'] );