mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-29 01:34:27 +00:00
Code Modernization: Replace dirname( __FILE__ ) calls with __DIR__ magic constant.
This avoids the performance overhead of the function call every time `dirname( __FILE__ )` was used instead of `__DIR__`. This commit also includes: * Removing unnecessary parentheses from `include`/`require` statements. These are language constructs, not function calls. * Replacing `include` statements for several files with `require_once`, for consistency: * `wp-admin/admin-header.php` * `wp-admin/admin-footer.php` * `wp-includes/version.php` Props ayeshrajans, desrosj, valentinbora, jrf, joostdevalk, netweb. Fixes #48082. git-svn-id: https://develop.svn.wordpress.org/trunk@47198 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -7,13 +7,13 @@
|
||||
* Compatibility with PHPUnit 6+
|
||||
*/
|
||||
if ( class_exists( 'PHPUnit\Runner\Version' ) ) {
|
||||
require_once dirname( __FILE__ ) . '/phpunit6/compat.php';
|
||||
require_once __DIR__ . '/phpunit6/compat.php';
|
||||
}
|
||||
|
||||
if ( defined( 'WP_TESTS_CONFIG_FILE_PATH' ) ) {
|
||||
$config_file_path = WP_TESTS_CONFIG_FILE_PATH;
|
||||
} else {
|
||||
$config_file_path = dirname( dirname( __FILE__ ) );
|
||||
$config_file_path = dirname( __DIR__ );
|
||||
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' ) {
|
||||
@@ -35,7 +35,7 @@ if ( ! is_readable( $config_file_path ) ) {
|
||||
}
|
||||
|
||||
require_once $config_file_path;
|
||||
require_once dirname( __FILE__ ) . '/functions.php';
|
||||
require_once __DIR__ . '/functions.php';
|
||||
|
||||
if ( version_compare( tests_get_phpunit_version(), '8.0', '>=' ) ) {
|
||||
printf(
|
||||
@@ -54,8 +54,8 @@ if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS && ! is_dir( ABSPATH )
|
||||
tests_reset__SERVER();
|
||||
|
||||
define( 'WP_TESTS_TABLE_PREFIX', $table_prefix );
|
||||
define( 'DIR_TESTDATA', dirname( __FILE__ ) . '/../data' );
|
||||
define( 'DIR_TESTROOT', realpath( dirname( dirname( __FILE__ ) ) ) );
|
||||
define( 'DIR_TESTDATA', __DIR__ . '/../data' );
|
||||
define( 'DIR_TESTROOT', realpath( dirname( __DIR__ ) ) );
|
||||
|
||||
define( 'WP_LANG_DIR', DIR_TESTDATA . '/languages' );
|
||||
|
||||
@@ -84,7 +84,7 @@ $multisite = $multisite || ( defined( 'WP_TESTS_MULTISITE' ) && WP_TESTS_MULTISI
|
||||
$multisite = $multisite || ( defined( 'MULTISITE' ) && MULTISITE );
|
||||
|
||||
// Override the PHPMailer.
|
||||
require_once( dirname( __FILE__ ) . '/mock-mailer.php' );
|
||||
require_once __DIR__ . '/mock-mailer.php';
|
||||
$phpmailer = new MockPHPMailer( true );
|
||||
|
||||
if ( ! defined( 'WP_DEFAULT_THEME' ) ) {
|
||||
@@ -97,7 +97,7 @@ if ( file_exists( DIR_TESTDATA . '/themedir1' ) ) {
|
||||
}
|
||||
|
||||
if ( '1' !== getenv( 'WP_TESTS_SKIP_INSTALL' ) ) {
|
||||
system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __FILE__ ) . '/install.php' ) . ' ' . escapeshellarg( $config_file_path ) . ' ' . $multisite, $retval );
|
||||
system( WP_PHP_BINARY . ' ' . escapeshellarg( __DIR__ . '/install.php' ) . ' ' . escapeshellarg( $config_file_path ) . ' ' . $multisite, $retval );
|
||||
if ( 0 !== $retval ) {
|
||||
exit( $retval );
|
||||
}
|
||||
@@ -139,22 +139,22 @@ require_once ABSPATH . '/wp-settings.php';
|
||||
_delete_all_posts();
|
||||
|
||||
if ( version_compare( tests_get_phpunit_version(), '7.0', '>=' ) ) {
|
||||
require dirname( __FILE__ ) . '/phpunit7/testcase.php';
|
||||
require __DIR__ . '/phpunit7/testcase.php';
|
||||
} else {
|
||||
require dirname( __FILE__ ) . '/testcase.php';
|
||||
require __DIR__ . '/testcase.php';
|
||||
}
|
||||
|
||||
require dirname( __FILE__ ) . '/testcase-rest-api.php';
|
||||
require dirname( __FILE__ ) . '/testcase-rest-controller.php';
|
||||
require dirname( __FILE__ ) . '/testcase-rest-post-type-controller.php';
|
||||
require dirname( __FILE__ ) . '/testcase-xmlrpc.php';
|
||||
require dirname( __FILE__ ) . '/testcase-ajax.php';
|
||||
require dirname( __FILE__ ) . '/testcase-canonical.php';
|
||||
require dirname( __FILE__ ) . '/exceptions.php';
|
||||
require dirname( __FILE__ ) . '/utils.php';
|
||||
require dirname( __FILE__ ) . '/spy-rest-server.php';
|
||||
require dirname( __FILE__ ) . '/class-wp-rest-test-search-handler.php';
|
||||
require dirname( __FILE__ ) . '/class-wp-fake-block-type.php';
|
||||
require __DIR__ . '/testcase-rest-api.php';
|
||||
require __DIR__ . '/testcase-rest-controller.php';
|
||||
require __DIR__ . '/testcase-rest-post-type-controller.php';
|
||||
require __DIR__ . '/testcase-xmlrpc.php';
|
||||
require __DIR__ . '/testcase-ajax.php';
|
||||
require __DIR__ . '/testcase-canonical.php';
|
||||
require __DIR__ . '/exceptions.php';
|
||||
require __DIR__ . '/utils.php';
|
||||
require __DIR__ . '/spy-rest-server.php';
|
||||
require __DIR__ . '/class-wp-rest-test-search-handler.php';
|
||||
require __DIR__ . '/class-wp-fake-block-type.php';
|
||||
|
||||
/**
|
||||
* A class to handle additional command line arguments passed to the script.
|
||||
|
||||
Reference in New Issue
Block a user