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/tests/theme.php

    r38755 r38907  
    1515
    1616    function setUp() {
     17        global $wp_theme_directories;
     18
    1719        parent::setUp();
     20
     21        $backup_wp_theme_directories = $wp_theme_directories;
     22        $wp_theme_directories = array( WP_CONTENT_DIR . '/themes' );
     23
    1824        add_filter( 'extra_theme_headers', array( $this, '_theme_data_extra_headers' ) );
    1925        wp_clean_themes_cache();
     
    2228
    2329    function tearDown() {
     30        global $wp_theme_directories;
     31
     32        $wp_theme_directories = $this->wp_theme_directories;
     33
    2434        remove_filter( 'extra_theme_headers', array( $this, '_theme_data_extra_headers' ) );
    2535        wp_clean_themes_cache();
    2636        unset( $GLOBALS['wp_themes'] );
     37
    2738        parent::tearDown();
    2839    }
Note: See TracChangeset for help on using the changeset viewer.