Use an empty theme for WP_DEFAULT_THEME during unit tests
|Reported by:||westonruter||Owned by:||pento|
Description (last modified by westonruter)
Assertions for unit tests in Core should not have any interference from the current default theme, but this is not currently the case.
In the customize/widgets unit test, I had to add:
<?php remove_action( 'after_setup_theme', 'twentyfifteen_setup' );
This was needed because Twenty Fifteen's actions modified what the unit test was expecting. This will be a recurring problem every time a new default theme is introduced, where the unit tests will have to be update their assertions to take into account the new default theme.
The default theme loaded when unit testing should be empty, without any filter/action additions.
I suggest that the PHPUnit bootstrap perhaps copy (symlink?) the tests/phpunit/data/themedir1/default theme directory into the wp-content/themes directory (or filter the theme_root), and then let the wp-tests-config.php include:
<?php define( 'WP_DEFAULT_THEME', 'default' );
Or the WP_DEFAULT_THEME constant could be set as thus in default-constants.php when WP detects the unit tests are being run:
<?php define( 'WP_DEFAULT_THEME', defined( 'WP_RUN_CORE_TESTS' ) ? 'default' : 'twentyfifteen' );