Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block Hooks: Remove filter global reset from test teardown #6244

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions tests/phpunit/tests/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,6 @@ public function set_up() {
* @since 6.5.0
*/
public function tear_down() {
global $wp_current_filter;

if (
'rest_pre_insert_wp_template' === current_filter() ||
'rest_pre_insert_wp_template_part' === current_filter()
) {
array_pop( $wp_current_filter );
}

if ( WP_Block_Type_Registry::get_instance()->is_registered( 'tests/hooked-block' ) ) {
unregister_block_type( 'tests/hooked-block' );
}
Expand Down Expand Up @@ -420,7 +411,8 @@ public function test_wp_generate_block_templates_export_file() {
*/
public function test_inject_ignored_hooked_blocks_metadata_attributes_into_template() {
global $wp_current_filter;
// Mock currently set filter.
// Mock currently set filter. The $wp_current_filter global is reset during teardown by
// WP_UnitTestCase_Base::_restore_hooks() in tests/phpunit/includes/abstract-testcase.php.
$wp_current_filter[] = 'rest_pre_insert_wp_template';

register_block_type(
Expand Down Expand Up @@ -453,7 +445,8 @@ public function test_inject_ignored_hooked_blocks_metadata_attributes_into_templ
*/
public function test_inject_ignored_hooked_blocks_metadata_attributes_into_template_part() {
global $wp_current_filter;
// Mock currently set filter.
// Mock currently set filter. The $wp_current_filter global is reset during teardown by
// WP_UnitTestCase_Base::_restore_hooks() in tests/phpunit/includes/abstract-testcase.php.
$wp_current_filter[] = 'rest_pre_insert_wp_template_part';

register_block_type(
Expand Down
Loading