Changeset 58843
- Timestamp:
- 08/02/2024 10:36:27 PM (4 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r58827 r58843 8834 8834 * @since 5.2.0 8835 8835 * 8836 * @global string $ wp_version The WordPress version string.8836 * @global string $_wp_tests_wp_version The WordPress version string. Used only in Core tests. 8837 8837 * 8838 8838 * @param string $required Minimum required WordPress version. … … 8840 8840 */ 8841 8841 function is_wp_version_compatible( $required ) { 8842 global $wp_version; 8842 if ( 8843 defined( 'WP_RUN_CORE_TESTS' ) 8844 && WP_RUN_CORE_TESTS 8845 && isset( $GLOBALS['_wp_tests_wp_version'] ) 8846 ) { 8847 $wp_version = $GLOBALS['_wp_tests_wp_version']; 8848 } else { 8849 $wp_version = wp_get_wp_version(); 8850 } 8843 8851 8844 8852 // Strip off any -alpha, -RC, -beta, -src suffixes. -
trunk/tests/phpunit/tests/functions/isWpVersionCompatible.php
r57735 r58843 10 10 class Tests_Functions_IsWpVersionCompatible extends WP_UnitTestCase { 11 11 /** 12 * The current WordPress version. 13 * 14 * @var string 15 */ 16 private static $wp_version; 17 18 /** 19 * Sets the test WordPress version property and global before any tests run. 20 */ 21 public static function set_up_before_class() { 22 parent::set_up_before_class(); 23 self::$wp_version = wp_get_wp_version(); 24 $GLOBALS['_wp_tests_wp_version'] = self::$wp_version; 25 } 26 27 /** 28 * Resets the test WordPress version global after each test runs. 29 */ 30 public function tear_down() { 31 $GLOBALS['_wp_tests_wp_version'] = self::$wp_version; 32 parent::tear_down(); 33 } 34 35 /** 36 * Unsets the test WordPress version global after all tests run. 37 */ 38 public static function tear_down_after_class() { 39 unset( $GLOBALS['_wp_tests_wp_version'] ); 40 parent::tear_down_after_class(); 41 } 42 43 /** 12 44 * Tests is_wp_version_compatible(). 13 45 * … … 15 47 * 16 48 * @ticket 54257 49 * @ticket 61781 17 50 * 18 51 * @param mixed $required The minimum required WordPress version. … … 29 62 */ 30 63 public function data_is_wp_version_compatible() { 31 global $wp_version; 32 64 $wp_version = wp_get_wp_version(); 33 65 $version_parts = explode( '.', $wp_version ); 34 66 $lower_version = $version_parts; … … 105 137 * 106 138 * @ticket 59448 139 * @ticket 61781 107 140 * 108 141 * @param mixed $required The minimum required WordPress version. … … 111 144 */ 112 145 public function test_is_wp_version_compatible_should_gracefully_handle_trailing_point_zero_version_numbers( $required, $wp, $expected ) { 113 global $wp_version; 114 $original_version = $wp_version; 115 $wp_version = $wp; 116 117 $actual = is_wp_version_compatible( $required ); 118 119 // Reset the version before the assertion in case of failure. 120 $wp_version = $original_version; 121 122 $this->assertSame( $expected, $actual, 'The expected result was not returned.' ); 146 $GLOBALS['_wp_tests_wp_version'] = $wp; 147 $this->assertSame( $expected, is_wp_version_compatible( $required ), 'The expected result was not returned.' ); 123 148 } 124 149 … … 184 209 * 185 210 * @ticket 54257 211 * @ticket 61781 186 212 * 187 213 * @param string $required The minimum required WordPress version. … … 190 216 */ 191 217 public function test_is_wp_version_compatible_with_development_versions( $required, $wp, $expected ) { 192 global $wp_version; 193 194 $original_version = $wp_version; 195 $wp_version = $wp; 196 $actual = is_wp_version_compatible( $required ); 197 198 // Reset the version before the assertion in case of failure. 199 $wp_version = $original_version; 200 201 $this->assertSame( $expected, $actual ); 218 $GLOBALS['_wp_tests_wp_version'] = $wp; 219 $this->assertSame( $expected, is_wp_version_compatible( $required ) ); 202 220 } 203 221 … … 208 226 */ 209 227 public function data_is_wp_version_compatible_with_development_versions() { 210 global $wp_version;211 212 228 // For consistent results, remove possible suffixes. 213 list( $version ) = explode( '-', $wp_version);229 list( $version ) = explode( '-', wp_get_wp_version() ); 214 230 215 231 $version_parts = explode( '.', $version );
Note: See TracChangeset
for help on using the changeset viewer.