Changeset 57919 for trunk/tests/phpunit/tests/block-template-utils.php
- Timestamp:
- 04/03/2024 03:09:38 PM (13 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/block-template-utils.php
r57799 r57919 404 404 $this->assertTrue( $has_html_files, 'contains at least one html file' ); 405 405 } 406 407 /**408 * @ticket 60671409 *410 * @covers inject_ignored_hooked_blocks_metadata_attributes411 */412 public function test_inject_ignored_hooked_blocks_metadata_attributes_into_template() {413 global $wp_current_filter;414 // Mock currently set filter. The $wp_current_filter global is reset during teardown by415 // WP_UnitTestCase_Base::_restore_hooks() in tests/phpunit/includes/abstract-testcase.php.416 $wp_current_filter[] = 'rest_pre_insert_wp_template';417 418 register_block_type(419 'tests/hooked-block',420 array(421 'block_hooks' => array(422 'tests/anchor-block' => 'after',423 ),424 )425 );426 427 $id = self::TEST_THEME . '//' . 'my_template';428 $request = new WP_REST_Request( 'POST', '/wp/v2/templates/' . $id );429 430 $changes = new stdClass();431 $changes->post_content = '<!-- wp:tests/anchor-block -->Hello<!-- /wp:tests/anchor-block -->';432 433 $post = inject_ignored_hooked_blocks_metadata_attributes( $changes, $request );434 $this->assertSame(435 '<!-- wp:tests/anchor-block {"metadata":{"ignoredHookedBlocks":["tests/hooked-block"]}} -->Hello<!-- /wp:tests/anchor-block -->',436 $post->post_content,437 'The hooked block was not injected into the anchor block\'s ignoredHookedBlocks metadata.'438 );439 }440 441 /**442 * @ticket 60671443 *444 * @covers inject_ignored_hooked_blocks_metadata_attributes445 */446 public function test_inject_ignored_hooked_blocks_metadata_attributes_into_template_part() {447 global $wp_current_filter;448 // Mock currently set filter. The $wp_current_filter global is reset during teardown by449 // WP_UnitTestCase_Base::_restore_hooks() in tests/phpunit/includes/abstract-testcase.php.450 $wp_current_filter[] = 'rest_pre_insert_wp_template_part';451 452 register_block_type(453 'tests/hooked-block',454 array(455 'block_hooks' => array(456 'tests/anchor-block' => 'after',457 ),458 )459 );460 461 $id = self::TEST_THEME . '//' . 'my_template_part';462 $request = new WP_REST_Request( 'POST', '/wp/v2/template-parts/' . $id );463 464 $changes = new stdClass();465 $changes->post_content = '<!-- wp:tests/anchor-block -->Hello<!-- /wp:tests/anchor-block -->';466 467 $post = inject_ignored_hooked_blocks_metadata_attributes( $changes, $request );468 $this->assertSame(469 '<!-- wp:tests/anchor-block {"metadata":{"ignoredHookedBlocks":["tests/hooked-block"]}} -->Hello<!-- /wp:tests/anchor-block -->',470 $post->post_content,471 'The hooked block was not injected into the anchor block\'s ignoredHookedBlocks metadata.'472 );473 }474 406 }
Note: See TracChangeset
for help on using the changeset viewer.