diff --git a/tests/phpunit/includes/functions.php b/tests/phpunit/includes/functions.php index e8d30cb0c1..b7b9f87397 100644 --- a/tests/phpunit/includes/functions.php +++ b/tests/phpunit/includes/functions.php @@ -102,4 +102,16 @@ function _wp_die_handler_txt( $message, $title, $args ) { echo "\t $k : $v\n"; } } -} \ No newline at end of file +} + +/** + * Set a permalink structure. + * + * Hooked as a callback to the 'populate_options' action, we use this function to set a permalink structure during + * `wp_install()`, so that WP doesn't attempt to do a time-consuming remote request. + * + * @since 4.2.0 + */ +function _set_default_permalink_structure_for_tests() { + update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/' ); +} diff --git a/tests/phpunit/includes/install.php b/tests/phpunit/includes/install.php index ff4090e55a..592e3808d6 100644 --- a/tests/phpunit/includes/install.php +++ b/tests/phpunit/includes/install.php @@ -44,8 +44,17 @@ foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) { $wpdb->$table = $prefixed_table; } +// Prefill a permalink structure so that WP doesn't try to determine one itself. +add_action( 'populate_options', '_set_default_permalink_structure_for_tests' ); + wp_install( WP_TESTS_TITLE, 'admin', WP_TESTS_EMAIL, true, null, 'password' ); +// Delete dummy permalink structure, as prefilled above. +if ( ! is_multisite() ) { + delete_option( 'permalink_structure' ); +} +remove_action( 'populate_options', '_set_default_permalink_structure_for_tests' ); + if ( $multisite ) { echo "Installing network..." . PHP_EOL;