Make WordPress Core


Ignore:
Timestamp:
10/25/2016 10:24:57 AM (8 years ago)
Author:
pento
Message:

Tests: Use a minimal theme for tests.

This functionality was originally added in [38858], using symlink() to put a link to the theme in WordPress' themes directory. Unfortunately, not all installs have write access to the themes directory, causing unit tests to fail.

The new method is to add the test theme directory to $wp_theme_directories, and fix the handful of tests that don't expect $wp_theme_directories to have multiple entries.

The test install/bootstrap routines now also check that WP_DEFAULT_THEME is defined, in case the tests are being run on a system that hasn't upgraded its' wp-tests-config.php.

See #31550.
Fixes #38457.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/bootstrap.php

    r38858 r38907  
    1717 * See: https://github.com/sebastianbergmann/phpunit/issues/325
    1818 */
    19 global $wpdb, $current_site, $current_blog, $wp_rewrite, $shortcode_tags, $wp, $phpmailer;
     19global $wpdb, $current_site, $current_blog, $wp_rewrite, $shortcode_tags, $wp, $phpmailer, $wp_theme_directories;
    2020
    2121if ( !is_readable( $config_file_path ) ) {
     
    5454$phpmailer = new MockPHPMailer();
    5555
    56 // Add a symlink to the empty default theme to the themes directory, so it can be used for the tests.
    57 _symlink_default_theme();
     56// Set the theme to our special empty theme, to avoid interference from the current Twenty* theme.
     57if ( ! defined( 'WP_DEFAULT_THEME' ) ) {
     58    define( 'WP_DEFAULT_THEME', 'default' );
     59}
     60$wp_theme_directories = array( DIR_TESTDATA . '/themedir1' );
    5861
    5962system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __FILE__ ) . '/install.php' ) . ' ' . escapeshellarg( $config_file_path ) . ' ' . $multisite );
Note: See TracChangeset for help on using the changeset viewer.