[wp-trac] [WordPress Trac] #31130: WP_INSTALLING causes leakage between unit tests

WordPress Trac noreply at wordpress.org
Sun Feb 8 23:50:10 UTC 2015


#31130: WP_INSTALLING causes leakage between unit tests
------------------------------------+-----------------------------
 Reporter:  boonebgorges            |       Owner:
     Type:  defect (bug)            |      Status:  new
 Priority:  normal                  |   Milestone:  Future Release
Component:  Build/Test Tools        |     Version:
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:
------------------------------------+-----------------------------
Changes (by jeremyfelt):

 * keywords:   => has-patch dev-feedback


Comment:

 [https://core.trac.wordpress.org/attachment/ticket/31130/31130.diff
 31130.diff] is an initial attempt at solving this.

 * Introduce `$wp_config` in `wp-settings.php` to hold any configuration
 data normally stored in constants.
 * Introduce `wp_define()` in `default-constants.php` for core to use as a
 way to define constants or to set the property in `$wp_config` if tests
 are running.
 * Introduce `wp_defined()` in `default-constants.php` for core to use for
 retrieval of constants or `$wp_config` data if tests are running.
 * Change all instances of `define()` and `defined()` used for
 `WP_INSTALLING` to `wp_define()` and `wp_defined()`. Some are not changed
 due to load order in places such as `wp-activate.php` or `install.php`,
 but may be possible with further exploration. These are not requirements
 for unit testing right now.
 * Reset the global `$wp_config` when tearing down tests.
 * Un-skip multisite tests that were previously skipped for `WP_INSTALLING`
 reasons. These appear to all pass.
 * Use `wp_schedule_update_network_counts()` when testing the same
 function, something we could not do before with `WP_INSTALLING` defined.

 Caveats...

 I did get one random failed test out of several attempts for
 `test_orderby_meta()`, but it never appeared again.

 {{{
 1) Tests_Comment_Query::test_orderby_meta
 Failed asserting that '322' matches expected 320.

 /srv/www/wordpress-develop/tests/phpunit/tests/comment/query.php:616
 }}}

 And the test of `current_user_can_for_blog()` on a non-existing site now
 generates a missing table error since the test actually runs now that
 `WP_INSTALLING` is not available.

 Overall, the results are good.

 * Before patching, all tests passed with 14 skipped.
 * After patching, but without resetting the `$wp_config` global to clear
 `WP_INSTALLING`, 5 tests failed and 9 skipped.
 * After resetting the `$wp_config` global, all tests passed with 9
 skipped.

 This patch/discussion could also belong on #22251. Outside of a specific
 solution for `WP_INSTALLING`, there are other things to consider—is this a
 good approach, does this belong in `$wp` rather than `$wp_config`, new
 function naming, etc...

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


More information about the wp-trac mailing list