mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-08 22:54:36 +00:00
General: Introduce all development mode.
Introduce the development mode `all` as a a cover-all mode for the existing `theme`, `plugin` and `core` development modes. Developers can use the `all` mode if they are developing both themes and plugins, for example. Introduce the utility function `wp_in_development_mode()` allowing developers to detect the mode via a parameter. If the development mode is set to `all` this function will always return `true`. If the development mode is specific then only the chosen mode will return `true`. Follow up to [56079,56042]. Props flixos90. Fixes #57487. git-svn-id: https://develop.svn.wordpress.org/trunk@56223 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
*
|
||||
* @group load.php
|
||||
* @covers ::wp_get_development_mode
|
||||
* @covers ::wp_in_development_mode
|
||||
*/
|
||||
class Test_WP_Get_Development_Mode extends WP_UnitTestCase {
|
||||
|
||||
@@ -43,4 +44,117 @@ class Test_WP_Get_Development_Mode extends WP_UnitTestCase {
|
||||
$_wp_tests_development_mode = 'invalid';
|
||||
$this->assertSame( '', wp_get_development_mode() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that `wp_in_development_mode()` returns expected results.
|
||||
*
|
||||
* @ticket 57487
|
||||
* @dataProvider data_wp_in_development_mode
|
||||
*/
|
||||
public function test_wp_in_development_mode( $current, $given, $expected ) {
|
||||
global $_wp_tests_development_mode;
|
||||
|
||||
$_wp_tests_development_mode = $current;
|
||||
|
||||
if ( $expected ) {
|
||||
$this->assertTrue( wp_in_development_mode( $given ), "{$given} is expected to pass in {$current} mode" );
|
||||
} else {
|
||||
$this->assertFalse( wp_in_development_mode( $given ), "{$given} is expected to fail in {$current} mode" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider that returns test scenarios for the `test_wp_in_development_mode()` method.
|
||||
*
|
||||
* @return array[]
|
||||
*/
|
||||
public function data_wp_in_development_mode() {
|
||||
return array(
|
||||
'core mode, testing for core' => array(
|
||||
'core',
|
||||
'core',
|
||||
true,
|
||||
),
|
||||
'plugin mode, testing for plugin' => array(
|
||||
'plugin',
|
||||
'plugin',
|
||||
true,
|
||||
),
|
||||
'theme mode, testing for theme' => array(
|
||||
'theme',
|
||||
'theme',
|
||||
true,
|
||||
),
|
||||
'core mode, testing for plugin' => array(
|
||||
'core',
|
||||
'plugin',
|
||||
false,
|
||||
),
|
||||
'core mode, testing for theme' => array(
|
||||
'core',
|
||||
'theme',
|
||||
false,
|
||||
),
|
||||
'plugin mode, testing for core' => array(
|
||||
'plugin',
|
||||
'core',
|
||||
false,
|
||||
),
|
||||
'plugin mode, testing for theme' => array(
|
||||
'plugin',
|
||||
'theme',
|
||||
false,
|
||||
),
|
||||
'theme mode, testing for core' => array(
|
||||
'theme',
|
||||
'core',
|
||||
false,
|
||||
),
|
||||
'theme mode, testing for plugin' => array(
|
||||
'theme',
|
||||
'plugin',
|
||||
false,
|
||||
),
|
||||
'all mode, testing for core' => array(
|
||||
'all',
|
||||
'core',
|
||||
true,
|
||||
),
|
||||
'all mode, testing for plugin' => array(
|
||||
'all',
|
||||
'plugin',
|
||||
true,
|
||||
),
|
||||
'all mode, testing for theme' => array(
|
||||
'all',
|
||||
'theme',
|
||||
true,
|
||||
),
|
||||
'all mode, testing for all' => array(
|
||||
'all',
|
||||
'all',
|
||||
true,
|
||||
),
|
||||
'all mode, testing for non-standard value' => array(
|
||||
'all',
|
||||
'random',
|
||||
true,
|
||||
),
|
||||
'invalid mode, testing for core' => array(
|
||||
'invalid',
|
||||
'core',
|
||||
false,
|
||||
),
|
||||
'invalid mode, testing for plugin' => array(
|
||||
'invalid',
|
||||
'plugin',
|
||||
false,
|
||||
),
|
||||
'invalid mode, testing for theme' => array(
|
||||
'invalid',
|
||||
'theme',
|
||||
false,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user