[wp-trac] [WordPress Trac] #31550: Use an empty theme for WP_DEFAULT_THEME during unit tests

WordPress Trac noreply at wordpress.org
Fri Mar 6 23:19:46 UTC 2015

#31550: Use an empty theme for WP_DEFAULT_THEME during unit tests
 Reporter:  westonruter       |      Owner:
     Type:  defect (bug)      |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  Build/Test Tools  |    Version:
 Severity:  normal            |   Keywords:
  Focuses:                    |
 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:

 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:

 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.

Ticket URL: <https://core.trac.wordpress.org/ticket/31550>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list