From 999b52eb75a97f9b7795e4b2136196fcaff98a7d Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 30 Nov 2022 18:30:57 +0000 Subject: [PATCH] Coding Standards: Fix a non-snake_case function name in `WP_Block` tests. As the filter is only intended for a single test, it can be converted to a closure instead of being declared as a function in the global namespace. The `remove_filter()` part is redundant, as `WP_UnitTestCase_Base` saves the state of filter-related globals at `set_up()` and restores them on `tear_down()`. Follow-up to [54175]. Props jrf, SergeyBiryukov. See #56791. git-svn-id: https://develop.svn.wordpress.org/trunk@54917 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/blocks/wpBlock.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/tests/blocks/wpBlock.php b/tests/phpunit/tests/blocks/wpBlock.php index c67a30df9d..00f5a97b83 100644 --- a/tests/phpunit/tests/blocks/wpBlock.php +++ b/tests/phpunit/tests/blocks/wpBlock.php @@ -604,13 +604,18 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase { ), ); $block = new WP_Block( $parsed_block, $context, $this->registry ); - function filterQuery( $query, $block, $page ) { - $query['post_type'] = 'book'; - return $query; - } - add_filter( 'query_loop_block_query_vars', 'filterQuery', 10, 3 ); + + add_filter( + 'query_loop_block_query_vars', + static function( $query, $block, $page ) { + $query['post_type'] = 'book'; + return $query; + }, + 10, + 3 + ); + $query = build_query_vars_from_query_block( $block, 1 ); - remove_filter( 'query_loop_block_query_vars', 'filterQuery' ); $this->assertSame( $query, array(