doAllHook.php 669 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * Test the do_all_hook method of WP_Hook
  4. *
  5. * @group hooks
  6. * @covers WP_Hook::do_all_hook
  7. */
  8. class Tests_Hooks_DoAllHook extends WP_UnitTestCase {
  9. public function test_do_all_hook_with_multiple_calls() {
  10. $a = new MockAction();
  11. $callback = array( $a, 'action' );
  12. $hook = new WP_Hook();
  13. $tag = 'all';
  14. $priority = rand( 1, 100 );
  15. $accepted_args = rand( 1, 100 );
  16. $arg = 'all_arg';
  17. $hook->add_filter( $tag, $callback, $priority, $accepted_args );
  18. $args = array( $arg );
  19. $hook->do_all_hook( $args );
  20. $hook->do_all_hook( $args );
  21. $this->assertSame( 2, $a->get_call_count() );
  22. }
  23. }