Ticket #55437: 55437.diff
| File 55437.diff, 2.7 KB (added by , 4 years ago) |
|---|
-
src/wp-includes/block-template-utils.php
503 503 504 504 $template = new WP_Block_Template(); 505 505 $template->id = $theme . '//' . $template_file['slug']; 506 $template->theme = $theme;506 $template->theme = ! empty( $template_file['theme'] ) ? $template_file['theme'] : $theme; 507 507 $template->content = _inject_theme_attribute_in_block_template_content( $template_content ); 508 508 $template->slug = $template_file['slug']; 509 509 $template->source = 'theme'; -
tests/phpunit/tests/block-template-utils.php
123 123 $this->assertSame( WP_TEMPLATE_PART_AREA_HEADER, $template_part->area ); 124 124 } 125 125 126 /** 127 * Tests that _build_block_template_result_from_post() returns the correct theme 128 * for the template when a child theme is active. 129 * 130 * @ticket 55437 131 * 132 * @covers ::_build_block_template_result_from_post 133 */ 134 function test_build_block_template_result_from_post_with_child_theme() { 135 switch_theme( 'block-theme-child' ); 136 137 $template = _build_block_template_result_from_post( 138 self::$template_post, 139 'wp_template' 140 ); 141 142 $this->assertSame( self::TEST_THEME, $template->theme ); 143 } 144 126 145 function test_build_block_template_result_from_file() { 127 146 $template = _build_block_template_result_from_file( 128 147 array( … … 161 180 $this->assertSame( WP_TEMPLATE_PART_AREA_HEADER, $template_part->area ); 162 181 } 163 182 183 /** 184 * Tests that _build_block_template_result_from_file() returns the correct theme 185 * for the template when a child theme is active. 186 * 187 * @ticket 55437 188 * 189 * @covers ::_build_block_template_result_from_file 190 */ 191 function test_build_block_template_result_from_file_with_child_theme() { 192 switch_theme( 'block-theme-child' ); 193 194 $template = _build_block_template_result_from_file( 195 array( 196 'slug' => 'single', 197 'path' => __DIR__ . '/../data/templates/template.html', 198 'theme' => self::TEST_THEME, 199 ), 200 'wp_template' 201 ); 202 203 $this->assertSame( self::TEST_THEME, $template->theme ); 204 } 205 164 206 function test_inject_theme_attribute_in_block_template_content() { 165 207 $theme = get_stylesheet(); 166 208 $content_without_theme_attribute = '<!-- wp:template-part {"slug":"header","align":"full", "tagName":"header","className":"site-header"} /-->';
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)