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

WordPress Trac noreply at wordpress.org
Mon May 9 04:20:05 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            |   Keywords:
  Focuses:                    |
------------------------------+-----------------------------
 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()`.

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


More information about the wp-trac mailing list