[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:35:01 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            |  Resolution:
 Keywords:                    |     Focuses:
------------------------------+------------------------------
Description changed by westonruter:

Old description:

> 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
> [https://core.trac.wordpress.org/browser/trunk/tests/phpunit/tests/customize/widgets.php?rev=31622#L31
> 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
> [https://core.trac.wordpress.org/browser/trunk/tests/phpunit/data/themedir1/default
> 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.

New description:

 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
 [https://core.trac.wordpress.org/browser/trunk/tests/phpunit/tests/customize/widgets.php?rev=31622#L31
 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
 [https://core.trac.wordpress.org/browser/trunk/tests/phpunit/data/themedir1/default
 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' );
 }}}

--

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


More information about the wp-trac mailing list