[wp-trac] [WordPress Trac] #36786: Can't pass filter names to `MockAction::get_call_count()`

WordPress Trac noreply at wordpress.org
Thu Jun 2 00:53:20 UTC 2016


#36786: Can't pass filter names to `MockAction::get_call_count()`
------------------------------+------------------------------
 Reporter:  dlh               |       Owner:
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  Awaiting Review
Component:  Build/Test Tools  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  has-patch         |     Focuses:
------------------------------+------------------------------
Changes (by netweb):

 * keywords:   => has-patch


Old description:

> 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()`.

New description:

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

 {{{#!php
 <?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()`.

--

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36786#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list