- Timestamp:
- 07/02/2024 10:01:17 AM (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/block-templates/buildBlockTemplateResultFromFile.php
r57266 r58614 8 8 */ 9 9 class Tests_Block_Templates_BuildBlockTemplateResultFromFile extends WP_Block_Templates_UnitTestCase { 10 /** 11 * Tear down each test method. 12 * 13 * @since 6.7.0 14 */ 15 public function tear_down() { 16 $registry = WP_Block_Type_Registry::get_instance(); 17 18 if ( $registry->is_registered( 'tests/my-block' ) ) { 19 $registry->unregister( 'tests/my-block' ); 20 } 21 22 parent::tear_down(); 23 } 10 24 11 25 /** … … 179 193 $this->assertEmpty( $template->post_types ); 180 194 } 195 196 /** 197 * @ticket 60506 198 */ 199 public function test_should_inject_hooked_block_into_template_part() { 200 register_block_type( 201 'tests/my-block', 202 array( 203 'block_hooks' => array( 204 'core/paragraph' => 'after', 205 ), 206 ) 207 ); 208 209 $template_part = _build_block_template_result_from_file( 210 array( 211 'slug' => 'header', 212 'postTypes' => array( 'post' ), 213 'path' => DIR_TESTDATA . '/templates/template.html', 214 ), 215 'wp_template_part' 216 ); 217 $this->assertStringEndsWith( '<!-- wp:tests/my-block /-->', $template_part->content ); 218 } 219 220 /* 221 * @ticket 60506 222 * @ticket 60854 223 */ 224 public function test_should_injected_hooked_block_into_template_part_first_child() { 225 register_block_type( 226 'tests/my-block', 227 array( 228 'block_hooks' => array( 229 'core/template-part' => 'first_child', 230 ), 231 ) 232 ); 233 234 $template_part = _build_block_template_result_from_file( 235 array( 236 'slug' => 'header', 237 'postTypes' => array( 'post' ), 238 'path' => DIR_TESTDATA . '/templates/template.html', 239 ), 240 'wp_template_part' 241 ); 242 $this->assertStringStartsWith( '<!-- wp:tests/my-block /-->', $template_part->content ); 243 } 244 245 /* 246 * @ticket 60506 247 * @ticket 60854 248 */ 249 public function test_should_injected_hooked_block_into_template_part_last_child() { 250 register_block_type( 251 'tests/my-block', 252 array( 253 'block_hooks' => array( 254 'core/template-part' => 'last_child', 255 ), 256 ) 257 ); 258 259 $template_part = _build_block_template_result_from_file( 260 array( 261 'slug' => 'header', 262 'postTypes' => array( 'post' ), 263 'path' => DIR_TESTDATA . '/templates/template.html', 264 ), 265 'wp_template_part' 266 ); 267 $this->assertStringEndsWith( '<!-- wp:tests/my-block /-->', $template_part->content ); 268 } 181 269 }
Note: See TracChangeset
for help on using the changeset viewer.