Make WordPress Core

Opened 5 years ago

Last modified 4 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 needs-refresh
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().

Attachments (1)

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

Download all attachments as: .zip

Change History (4)

5 years ago

#1 @netweb
5 years ago

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

#2 @johnbillion
5 years ago

  • Keywords needs-testing added
  • Milestone changed from Awaiting Review to Future Release

#3 @isabel_brison
4 months ago

  • Keywords needs-refresh added

The patch no longer applies cleanly.

Note: See TracTickets for help on using tickets.