Make WordPress Core


Ignore:
Timestamp:
07/31/2022 04:25:27 PM (4 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/actions.php

    r53804 r53805  
    2121        $this->assertSame( 1, $a->get_call_count() );
    2222        // Only our hook was called.
    23         $this->assertSame( array( $hook_name ), $a->get_tags() );
     23        $this->assertSame( array( $hook_name ), $a->get_hook_names() );
    2424
    2525        $argsvar = $a->get_args();
     
    4040        // Make sure our hook was called correctly.
    4141        $this->assertSame( 1, $a->get_call_count() );
    42         $this->assertSame( array( $hook_name ), $a->get_tags() );
     42        $this->assertSame( array( $hook_name ), $a->get_hook_names() );
    4343
    4444        // Now remove the action, do it again, and make sure it's not called this time.
     
    4646        do_action( $hook_name );
    4747        $this->assertSame( 1, $a->get_call_count() );
    48         $this->assertSame( array( $hook_name ), $a->get_tags() );
     48        $this->assertSame( array( $hook_name ), $a->get_hook_names() );
    4949
    5050    }
     
    216216            // 'action2' is called first because it has priority 9.
    217217            array(
    218                 'action' => 'action2',
    219                 'tag'    => $hook_name,
    220                 'args'   => array( '' ),
     218                'action'    => 'action2',
     219                'hook_name' => $hook_name,
     220                'tag'       => $hook_name, // Back compat.
     221                'args'      => array( '' ),
    221222            ),
    222223            // 'action' is called second.
    223224            array(
    224                 'action' => 'action',
    225                 'tag'    => $hook_name,
    226                 'args'   => array( '' ),
     225                'action'    => 'action',
     226                'hook_name' => $hook_name,
     227                'tag'       => $hook_name, // Back compat.
     228                'args'      => array( '' ),
    227229            ),
    228230        );
     
    275277        $this->assertSame( 4, $a->get_call_count() );
    276278        // Only our hook was called.
    277         $this->assertSame( array( $hook_name1, $hook_name2, $hook_name1, $hook_name1 ), $a->get_tags() );
     279        $this->assertSame( array( $hook_name1, $hook_name2, $hook_name1, $hook_name1 ), $a->get_hook_names() );
    278280
    279281        remove_action( 'all', array( &$a, 'action' ) );
     
    295297        // Make sure our hook was called correctly.
    296298        $this->assertSame( 1, $a->get_call_count() );
    297         $this->assertSame( array( $hook_name ), $a->get_tags() );
     299        $this->assertSame( array( $hook_name ), $a->get_hook_names() );
    298300
    299301        // Now remove the action, do it again, and make sure it's not called this time.
     
    302304        do_action( $hook_name );
    303305        $this->assertSame( 1, $a->get_call_count() );
    304         $this->assertSame( array( $hook_name ), $a->get_tags() );
     306        $this->assertSame( array( $hook_name ), $a->get_hook_names() );
    305307    }
    306308
Note: See TracChangeset for help on using the changeset viewer.