Make WordPress Core

Opened 4 years ago

Last modified 14 months ago

#36786 new defect (bug)

Can't pass filter names to `MockAction::get_call_count()` — at Version 1

Reported by: dlh Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch needs-testing
Focuses: Cc:

Description (last modified by netweb)

The first of these tests works as expected, but the second generates an "Undefined index" notice.

function test_get_call_count_action() {
        $action = rand_str();
        $ma = new MockAction();

        add_action( $action, array( $ma, 'action' ) );
        do_action( $action );

        $this->assertSame( 1, $ma->get_call_count( 'action' ) );

function test_get_call_count_filter() {
        $filter = rand_str();
        $ma = new MockAction();

        add_filter( $filter, array( $ma, 'filter' ) );
        apply_filters( $filter, rand_str() );

        $this->assertSame( 1, $ma->get_call_count( 'filter' ) );

The attached patch attempts to fix the notice and allow passing filter names to get_call_count().

Change History (2)

4 years ago

#1 @netweb
4 years ago

  • Description modified (diff)
  • Keywords has-patch added
Note: See TracTickets for help on using tickets.