Make WordPress Core


Ignore:
Timestamp:
07/31/2022 03:03:46 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Tests: Update the terminology used for action or filter names in hook tests.

This replaces the $tag variables with $hook_name, to match the core function signatures.

Follow-up to [24/tests], [62/tests], [866/tests], [1294/tests], [38571], [50807].

See #55652.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/actions/closures.php

    r52010 r53804  
    1616     */
    1717    public function test_action_closure() {
    18         $tag    = 'test_action_closure';
    19         $closure = static function( $a, $b ) {
     18        $hook_name = 'test_action_closure';
     19        $closure   = static function( $a, $b ) {
    2020            $GLOBALS[ $a ] = $b;
    2121        };
    22         add_action( $tag, $closure, 10, 2 );
     22        add_action( $hook_name, $closure, 10, 2 );
    2323
    24         $this->assertSame( 10, has_action( $tag, $closure ) );
     24        $this->assertSame( 10, has_action( $hook_name, $closure ) );
    2525
    2626        $context = array( 'val1', 'val2' );
    27         do_action( $tag, $context[0], $context[1] );
     27        do_action( $hook_name, $context[0], $context[1] );
    2828
    2929        $this->assertSame( $GLOBALS[ $context[0] ], $context[1] );
    3030
    31         $tag2    = 'test_action_closure_2';
    32         $closure2 = static function() {
     31        $hook_name2 = 'test_action_closure_2';
     32        $closure2   = static function() {
    3333            $GLOBALS['closure_no_args'] = true;
    3434        };
    35         add_action( $tag2, $closure2 );
     35        add_action( $hook_name2, $closure2 );
    3636
    37         $this->assertSame( 10, has_action( $tag2, $closure2 ) );
     37        $this->assertSame( 10, has_action( $hook_name2, $closure2 ) );
    3838
    39         do_action( $tag2 );
     39        do_action( $hook_name2 );
    4040
    4141        $this->assertTrue( $GLOBALS['closure_no_args'] );
    4242
    43         remove_action( $tag, $closure );
    44         remove_action( $tag2, $closure2 );
     43        remove_action( $hook_name, $closure );
     44        remove_action( $hook_name2, $closure2 );
    4545    }
    4646}
Note: See TracChangeset for help on using the changeset viewer.