Make WordPress Core

Changeset 54917


Ignore:
Timestamp:
11/30/2022 06:30:57 PM (17 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/blocks/wpBlock.php

    r54175 r54917  
    605605        );
    606606        $block         = new WP_Block( $parsed_block, $context, $this->registry );
    607         function filterQuery( $query, $block, $page ) {
    608             $query['post_type'] = 'book';
    609             return $query;
    610         }
    611         add_filter( 'query_loop_block_query_vars', 'filterQuery', 10, 3 );
     607
     608        add_filter(
     609            'query_loop_block_query_vars',
     610            static function( $query, $block, $page ) {
     611                $query['post_type'] = 'book';
     612                return $query;
     613            },
     614            10,
     615            3
     616        );
     617
    612618        $query = build_query_vars_from_query_block( $block, 1 );
    613         remove_filter( 'query_loop_block_query_vars', 'filterQuery' );
    614619        $this->assertSame(
    615620            $query,
Note: See TracChangeset for help on using the changeset viewer.