[wp-trac] [WordPress Trac] #51752: Enable the static variable in wp_get_environment_type() to be reset

WordPress Trac noreply at wordpress.org
Tue Nov 10 23:42:18 UTC 2020


#51752: Enable the static variable in wp_get_environment_type() to be reset
----------------------------+----------------------
 Reporter:  stevegrunwell   |       Owner:  (none)
     Type:  enhancement     |      Status:  closed
 Priority:  normal          |   Milestone:
Component:  Bootstrap/Load  |     Version:  5.5
 Severity:  normal          |  Resolution:  wontfix
 Keywords:                  |     Focuses:
----------------------------+----------------------
Changes (by johnbillion):

 * status:  new => closed
 * resolution:   => wontfix
 * milestone:  Awaiting Review =>


Comment:

 Yeah I'm -1 on this too. Your `myplugin_is_staging_mode()` function should
 receive the environment type as a parameter so it's testable on its own.

 {{{
 function myplugin_is_staging_mode( string $mode ) : bool {
     return 'staging' === $mode;
 }

 // Testing:
 myplugin_is_staging_mode( 'production' );
 myplugin_is_staging_mode( 'staging' );

 // Actual usage:
 myplugin_is_staging_mode( wp_get_environment_type() );
 }}}

 Your current test only tests that the `WP_ENVIRONMENT_TYPE` environment
 variable gets passed through to `wp_get_environment_type()`, which means
 it's testing WordPress more than your own code.

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


More information about the wp-trac mailing list