Make WordPress Core


Ignore:
Timestamp:
07/31/2022 04:25:27 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Tests: Update the terminology used for action or filter names in MockAction class.

This replaces the "tag" wording with "hook name" where appropriate, to match the core function signatures.

Includes:

  • Introducing a ::get_hook_names() method instead of ::get_tags(), keeping the latter as an alias.
  • Adding a hook_name key to the ::$events property, keeping tag for backward compatibility for now.
  • Adding missing @since tags for class methods.

Follow-up to [24/tests], [62/tests], [70/tests], [50807], [53804].

See #55652.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/filters.php

    r53804 r53805  
    1919        $this->assertSame( 1, $a->get_call_count() );
    2020        // Only our hook was called.
    21         $this->assertSame( array( $hook_name ), $a->get_tags() );
     21        $this->assertSame( array( $hook_name ), $a->get_hook_names() );
    2222
    2323        $argsvar = $a->get_args();
     
    3636        // Make sure our hook was called correctly.
    3737        $this->assertSame( 1, $a->get_call_count() );
    38         $this->assertSame( array( $hook_name ), $a->get_tags() );
     38        $this->assertSame( array( $hook_name ), $a->get_hook_names() );
    3939
    4040        // Now remove the filter, do it again, and make sure it's not called this time.
     
    4242        $this->assertSame( $val, apply_filters( $hook_name, $val ) );
    4343        $this->assertSame( 1, $a->get_call_count() );
    44         $this->assertSame( array( $hook_name ), $a->get_tags() );
     44        $this->assertSame( array( $hook_name ), $a->get_hook_names() );
    4545
    4646    }
     
    136136            // 'filter2' is called first because it has priority 9.
    137137            array(
    138                 'filter' => 'filter2',
    139                 'tag'    => $hook_name,
    140                 'args'   => array( $val ),
     138                'filter'    => 'filter2',
     139                'hook_name' => $hook_name,
     140                'tag'       => $hook_name, // Back compat.
     141                'args'      => array( $val ),
    141142            ),
    142143            // 'filter' is called second.
    143144            array(
    144                 'filter' => 'filter',
    145                 'tag'    => $hook_name,
    146                 'args'   => array( $val ),
     145                'filter'    => 'filter',
     146                'hook_name' => $hook_name,
     147                'tag'       => $hook_name, // Back compat.
     148                'args'      => array( $val ),
    147149            ),
    148150        );
     
    193195        $this->assertSame( 4, $a->get_call_count() );
    194196        // The right hooks should have been called in order.
    195         $this->assertSame( array( $hook_name1, $hook_name2, $hook_name1, $hook_name1 ), $a->get_tags() );
     197        $this->assertSame( array( $hook_name1, $hook_name2, $hook_name1, $hook_name1 ), $a->get_hook_names() );
    196198
    197199        remove_filter( 'all', array( $a, 'filterall' ) );
     
    212214        // Make sure our hook was called correctly.
    213215        $this->assertSame( 1, $a->get_call_count() );
    214         $this->assertSame( array( $hook_name ), $a->get_tags() );
     216        $this->assertSame( array( $hook_name ), $a->get_hook_names() );
    215217
    216218        // Now remove the filter, do it again, and make sure it's not called this time.
     
    221223        // Call cound should remain at 1.
    222224        $this->assertSame( 1, $a->get_call_count() );
    223         $this->assertSame( array( $hook_name ), $a->get_tags() );
     225        $this->assertSame( array( $hook_name ), $a->get_hook_names() );
    224226    }
    225227
Note: See TracChangeset for help on using the changeset viewer.