Changeset 54362
- Timestamp:
- 09/30/2022 12:38:58 AM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme-json.php
r54360 r54362 1710 1710 */ 1711 1711 protected static function get_property_value( $styles, $path, $theme_json = null ) { 1712 $value = _wp_array_get( $styles, $path ); 1712 $value = _wp_array_get( $styles, $path, '' ); 1713 1714 if ( '' === $value || null === $value ) { 1715 // No need to process the value further. 1716 return ''; 1717 } 1713 1718 1714 1719 /* -
trunk/tests/phpunit/tests/theme/wpThemeJson.php
r54272 r54362 2998 2998 2999 2999 /** 3000 * Tests that get_property_value() static method returns an empty string 3001 * if the path is invalid or the value is null. 3002 * 3003 * Also, tests that PHP 8.1 "passing null to non-nullable" deprecation notice 3004 * is not thrown when passing the value to strncmp() in the method. 3005 * 3006 * The notice that we should not see: 3007 * `Deprecated: strncmp(): Passing null to parameter #1 ($string1) of type string is deprecated`. 3008 * 3009 * @dataProvider data_get_property_value_should_return_string_for_invalid_paths_or_null_values 3010 * 3011 * @ticket 56620 3012 * 3013 * @covers WP_Theme_JSON::get_property_value 3014 * 3015 * @param array $styles An array with style definitions. 3016 * @param array $path Path to the desired properties. 3017 * 3018 */ 3019 public function test_get_property_value_should_return_string_for_invalid_paths_or_null_values( $styles, $path ) { 3020 $reflection_class = new ReflectionClass( WP_Theme_JSON::class ); 3021 3022 $get_property_value_method = $reflection_class->getMethod( 'get_property_value' ); 3023 $get_property_value_method->setAccessible( true ); 3024 $result = $get_property_value_method->invoke( null, $styles, $path ); 3025 3026 $this->assertSame( '', $result ); 3027 } 3028 3029 /** 3030 * Data provider for test_get_property_value_should_return_string_for_invalid_paths_or_null_values(). 3031 * 3032 * @return array 3033 */ 3034 public function data_get_property_value_should_return_string_for_invalid_paths_or_null_values() { 3035 return array( 3036 'empty string' => array( 3037 'styles' => array(), 3038 'path' => array( 'non_existent_path' ), 3039 ), 3040 'null' => array( 3041 'styles' => array( 'some_null_value' => null ), 3042 'path' => array( 'some_null_value' ), 3043 ), 3044 ); 3045 } 3046 3047 /** 3000 3048 * Testing that dynamic properties in theme.json that refer to other dynamic properties in a loop 3001 3049 * should be left untouched. … … 3084 3132 $this->assertSame( $expected, $theme_json->get_stylesheet() ); 3085 3133 } 3086 3087 3134 3088 3135 /**
Note: See TracChangeset
for help on using the changeset viewer.