Skip to content

Commit

Permalink
Remove filter and block type during teardown
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Mar 6, 2024
1 parent d88698e commit 98cdebd
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions tests/phpunit/tests/rest-api/wpRestTemplatesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ public static function wpTearDownAfterClass() {
wp_delete_post( self::$post->ID );
}

/**
* Tear down after each test.
*
* @since 6.5.0
*/
public function tear_down() {
if ( has_filter( 'rest_pre_insert_wp_template_part', 'inject_ignored_hooked_blocks_metadata_attributes' ) ) {
remove_filter( 'rest_pre_insert_wp_template_part', 'inject_ignored_hooked_blocks_metadata_attributes', 10 );
}
if ( WP_Block_Type_Registry::get_instance()->is_registered( 'tests/block' ) ) {
unregister_block_type( 'tests/hooked-block' );
}

parent::tear_down();
}

/**
* @covers WP_REST_Templates_Controller::register_routes
* @ticket 54596
Expand Down Expand Up @@ -950,9 +966,5 @@ public function test_prepare_item_for_database_injects_hooked_block() {
$prepared->post_content,
'The hooked block was not injected into the anchor block\'s ignoredHookedBlocks metadata.'
);

remove_filter( 'rest_pre_insert_wp_template_part', 'inject_ignored_hooked_blocks_metadata_attributes', 10 );

unregister_block_type( 'tests/hooked-block' );
}
}

0 comments on commit 98cdebd

Please sign in to comment.