WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 21 months ago

#36786 new defect (bug)

Can't pass filter names to `MockAction::get_call_count()`

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.

<?php
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().

Attachments (1)

36786.patch (777 bytes) - added by dlh 2 years ago.

Download all attachments as: .zip

Change History (3)

@dlh
2 years ago

#1 @netweb
2 years ago

  • Description modified (diff)
  • Keywords has-patch added

#2 @johnbillion
21 months ago

  • Keywords needs-testing added
  • Milestone changed from Awaiting Review to Future Release
Note: See TracTickets for help on using tickets.