Make WordPress Core

Opened 4 years ago

Last modified 13 months ago

#36786 new defect (bug)

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

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


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 (1)

4 years ago

Note: See TracTickets for help on using tickets.