Changeset 57662 for trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php
- Timestamp:
- 02/20/2024 09:53:11 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php
r57260 r57662 21 21 22 22 /** 23 * WP_Theme_JSON_Resolver::$blocks_cache property. 24 * 25 * @var ReflectionProperty 26 */ 27 private static $property_blocks_cache; 28 29 /** 30 * Original value of the WP_Theme_JSON_Resolver::$blocks_cache property. 31 * 32 * @var array 33 */ 34 private static $property_blocks_cache_orig_value; 35 36 /** 37 * WP_Theme_JSON_Resolver::$core property. 38 * 39 * @var ReflectionProperty 40 */ 41 private static $property_core; 42 43 /** 44 * Original value of the WP_Theme_JSON_Resolver::$core property. 45 * 46 * @var WP_Theme_JSON 47 */ 48 private static $property_core_orig_value; 49 50 /** 23 51 * Theme root directory. 24 52 * 25 * @var string 53 * @var string|null 26 54 */ 27 55 private $theme_root; … … 30 58 * Original theme directory. 31 59 * 32 * @var string60 * @var array|null 33 61 */ 34 62 private $orig_theme_dir; 35 63 36 64 /** 37 * WP_Theme_JSON_Resolver::$blocks_cache property. 38 * 39 * @var ReflectionProperty 40 */ 41 private static $property_blocks_cache; 42 43 /** 44 * Original value of the WP_Theme_JSON_Resolver::$blocks_cache property. 45 * 46 * @var array 47 */ 48 private static $property_blocks_cache_orig_value; 49 50 /** 51 * WP_Theme_JSON_Resolver::$core property. 52 * 53 * @var ReflectionProperty 54 */ 55 private static $property_core; 56 57 /** 58 * Original value of the WP_Theme_JSON_Resolver::$core property. 59 * 60 * @var WP_Theme_JSON 61 */ 62 private static $property_core_orig_value; 65 * @var array|null 66 */ 67 private $queries; 63 68 64 69 public static function set_up_before_class() { … … 99 104 add_filter( 'stylesheet_root', array( $this, 'filter_set_theme_root' ) ); 100 105 add_filter( 'template_root', array( $this, 'filter_set_theme_root' ) ); 101 106 $this->queries = array(); 102 107 // Clear caches. 103 108 wp_clean_themes_cache(); … … 141 146 $this->assertSame( 'block-theme', wp_get_theme()->get( 'TextDomain' ) ); 142 147 $this->assertSame( 'Motyw blokowy', $theme_data->get_data()['title'] ); 143 $this->assertSame Sets(148 $this->assertSame( 144 149 array( 145 150 'color' => array( … … 219 224 $this->assertArrayHasKey( 'page-home', $custom_templates ); 220 225 $this->assertSame( 221 $custom_templates['page-home'],222 226 array( 223 227 'title' => 'Szablon strony głównej', 224 228 'postTypes' => array( 'page' ), 225 ) 226 ); 229 ), 230 $custom_templates['page-home'] 231 ); 232 227 233 $this->assertSameSets( 228 234 array( … … 234 240 $theme_data->get_template_parts() 235 241 ); 242 236 243 $this->assertSame( 237 244 'Wariant motywu blokowego', 238 $style_variations[ 1]['title']245 $style_variations[2]['title'] 239 246 ); 240 247 } … … 258 265 259 266 /** 260 * Tests when WP_Theme_JSON_Resolver::$blocks_cache is empty or does not match261 * the all registered blocks.267 * Tests when WP_Theme_JSON_Resolver::$blocks_cache is empty or 268 * does not match the all registered blocks. 262 269 * 263 270 * Though this is a non-public method, it is vital to other functionality. … … 332 339 333 340 /** 334 * Tests when WP_Theme_JSON_Resolver::$blocks_cache is empty or does not match335 * the all registered blocks.341 * Tests when WP_Theme_JSON_Resolver::$blocks_cache is empty or 342 * does not match the all registered blocks. 336 343 * 337 344 * Though this is a non-public method, it is vital to other functionality. … … 597 604 598 605 $this->assertSame( 599 WP_Theme_JSON_Resolver::get_theme_data()->get_custom_templates(),600 606 array( 601 607 'page-home' => array( … … 607 613 'postTypes' => array( 'post' ), 608 614 ), 609 ) 615 ), 616 WP_Theme_JSON_Resolver::get_theme_data()->get_custom_templates() 610 617 ); 611 618 } … … 750 757 */ 751 758 public function test_get_theme_data_theme_supports_overrides_theme_json() { 759 switch_theme( 'default' ); 760 752 761 // Test that get_theme_data() returns a WP_Theme_JSON object. 753 762 $theme_json_resolver = new WP_Theme_JSON_Resolver(); … … 763 772 $previous_line_height = $previous_settings['typography']['lineHeight']; 764 773 $this->assertFalse( $previous_line_height, 'lineHeight setting from theme.json should be false.' ); 774 765 775 add_theme_support( 'custom-line-height' ); 766 776 $current_settings = $theme_json_resolver->get_theme_data()->get_settings(); 767 777 $line_height = $current_settings['typography']['lineHeight']; 768 778 $this->assertTrue( $line_height, 'lineHeight setting after add_theme_support() should be true.' ); 779 remove_theme_support( 'custom-line-height' ); 769 780 } 770 781 … … 810 821 * @param bool $theme_palette Whether the theme palette is present. 811 822 * @param string $theme_palette_text Message. 812 * @param bool $user_palette Whether the user palette is present.813 * @param string $user_palette_text Message.823 * @param bool $user_palette Whether the user palette is present. 824 * @param string $user_palette_text Message. 814 825 */ 815 826 public function test_get_merged_data_returns_origin( $origin, $core_palette, $core_palette_text, $block_styles, $block_styles_text, $theme_palette, $theme_palette_text, $user_palette, $user_palette_text ) { … … 818 829 'my/block-with-styles', 819 830 array( 820 'api_version' => 2,831 'api_version' => 3, 821 832 'attributes' => array( 822 833 'borderColor' => array( … … 878 889 * 879 890 * @covers WP_Theme_JSON_Resolver::get_merged_data 880 *881 891 */ 882 892 public function test_get_merged_data_returns_origin_proper() { … … 915 925 916 926 /** 917 * Data provider .927 * Data provider for test_get_merged_data_returns_origin. 918 928 * 919 929 * @return array[] … … 984 994 $expected_settings = array( 985 995 array( 986 'version' => 2, 996 'version' => WP_Theme_JSON::LATEST_SCHEMA, 997 'title' => 'variation-a', 998 'settings' => array( 999 'blocks' => array( 1000 'core/paragraph' => array( 1001 'color' => array( 1002 'palette' => array( 1003 'theme' => array( 1004 array( 1005 'slug' => 'dark', 1006 'name' => 'Dark', 1007 'color' => '#010101', 1008 ), 1009 ), 1010 ), 1011 ), 1012 ), 1013 ), 1014 ), 1015 ), 1016 array( 1017 'version' => WP_Theme_JSON::LATEST_SCHEMA, 987 1018 'title' => 'variation-b', 988 1019 'settings' => array( … … 1005 1036 ), 1006 1037 array( 1007 'version' => 2,1038 'version' => WP_Theme_JSON::LATEST_SCHEMA, 1008 1039 'title' => 'Block theme variation', 1009 1040 'settings' => array(
Note: See TracChangeset
for help on using the changeset viewer.