Make WordPress Core


Ignore:
Timestamp:
07/31/2022 03:03:46 PM (4 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/hooks/removeFilter.php

    r52389 r53804  
    1212                $callback      = '__return_null';
    1313                $hook          = new WP_Hook();
    14                 $tag           = __FUNCTION__;
     14                $hook_name     = __FUNCTION__;
    1515                $priority      = 1;
    1616                $accepted_args = 2;
    1717
    18                 $hook->add_filter( $tag, $callback, $priority, $accepted_args );
    19                 $hook->remove_filter( $tag, $callback, $priority );
     18                $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
     19                $hook->remove_filter( $hook_name, $callback, $priority );
    2020
    2121                $this->assertArrayNotHasKey( $priority, $hook->callbacks );
    … …  
    2626                $callback      = array( $a, 'action' );
    2727                $hook          = new WP_Hook();
    28                 $tag           = __FUNCTION__;
     28                $hook_name     = __FUNCTION__;
    2929                $priority      = 1;
    3030                $accepted_args = 2;
    3131
    32                 $hook->add_filter( $tag, $callback, $priority, $accepted_args );
    33                 $hook->remove_filter( $tag, $callback, $priority );
     32                $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
     33                $hook->remove_filter( $hook_name, $callback, $priority );
    3434
    3535                $this->assertArrayNotHasKey( $priority, $hook->callbacks );
    … …  
    3939                $callback      = array( 'MockAction', 'action' );
    4040                $hook          = new WP_Hook();
    41                 $tag           = __FUNCTION__;
     41                $hook_name     = __FUNCTION__;
    4242                $priority      = 1;
    4343                $accepted_args = 2;
    4444
    45                 $hook->add_filter( $tag, $callback, $priority, $accepted_args );
    46                 $hook->remove_filter( $tag, $callback, $priority );
     45                $hook->add_filter( $hook_name, $callback, $priority, $accepted_args );
     46                $hook->remove_filter( $hook_name, $callback, $priority );
    4747
    4848                $this->assertArrayNotHasKey( $priority, $hook->callbacks );
    … …  
    5353                $callback_two  = '__return_false';
    5454                $hook          = new WP_Hook();
    55                 $tag           = __FUNCTION__;
     55                $hook_name     = __FUNCTION__;
    5656                $priority      = 1;
    5757                $accepted_args = 2;
    5858
    59                 $hook->add_filter( $tag, $callback_one, $priority, $accepted_args );
    60                 $hook->add_filter( $tag, $callback_two, $priority, $accepted_args );
     59                $hook->add_filter( $hook_name, $callback_one, $priority, $accepted_args );
     60                $hook->add_filter( $hook_name, $callback_two, $priority, $accepted_args );
    6161
    62                 $hook->remove_filter( $tag, $callback_one, $priority );
     62                $hook->remove_filter( $hook_name, $callback_one, $priority );
    6363
    6464                $this->assertCount( 1, $hook->callbacks[ $priority ] );
    … …  
    6969                $callback_two  = '__return_false';
    7070                $hook          = new WP_Hook();
    71                 $tag           = __FUNCTION__;
     71                $hook_name     = __FUNCTION__;
    7272                $priority      = 1;
    7373                $accepted_args = 2;
    7474
    75                 $hook->add_filter( $tag, $callback_one, $priority, $accepted_args );
    76                 $hook->add_filter( $tag, $callback_two, $priority + 1, $accepted_args );
     75                $hook->add_filter( $hook_name, $callback_one, $priority, $accepted_args );
     76                $hook->add_filter( $hook_name, $callback_two, $priority + 1, $accepted_args );
    7777
    78                 $hook->remove_filter( $tag, $callback_one, $priority );
     78                $hook->remove_filter( $hook_name, $callback_one, $priority );
    7979                $this->assertArrayNotHasKey( $priority, $hook->callbacks );
    8080                $this->assertCount( 1, $hook->callbacks[ $priority + 1 ] );
Note: See TracChangeset for help on using the changeset viewer.