• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress develop tests

WordPress develop tests

WordPress develop tests a2z

  • Home
  • Plugins
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / Tests_Actions::test_action_args_3() – Test that multiple callbacks receive the correct number of args even when the number is less than, or greater than previous hooks.

You appear to be a bot. Output may be restricted

Description

Test that multiple callbacks receive the correct number of args even when the number is less than, or greater than previous hooks.

Usage

Tests_Actions::test_action_args_3();

Parameters

Returns

void

Source

File name: wordpress-develop-tests/phpunit/tests/actions.php


Lines:

1 to 32 of 32
  public function test_action_args_3() {
    $a1   = new MockAction();
    $a2   = new MockAction();
    $a3   = new MockAction();
    $tag  = __FUNCTION__;
    $val1 = __FUNCTION__ . '_val1';
    $val2 = __FUNCTION__ . '_val2';

    // $a1 accepts two arguments, $a2 doesn't, $a3 accepts two arguments.
    add_action( $tag, array( &$a1, 'action' ), 10, 2 );
    add_action( $tag, array( &$a2, 'action' ) );
    add_action( $tag, array( &$a3, 'action' ), 10, 2 );
    // Call the action with two arguments.
    do_action( $tag, $val1, $val2 );

    $call_count = $a1->get_call_count();
    // $a1 should be called with both args.
    $this->assertSame( 1, $call_count );
    $argsvar1 = $a1->get_args();
    $this->assertSame( array( $val1, $val2 ), array_pop( $argsvar1 ) );

    // $a2 should be called with one only.
    $this->assertSame( 1, $a2->get_call_count() );
    $argsvar2 = $a2->get_args();
    $this->assertSame( array( $val1 ), array_pop( $argsvar2 ) );

    // $a3 should be called with both args.
    $this->assertSame( 1, $a3->get_call_count() );
    $argsvar3 = $a3->get_args();
    $this->assertSame( array( $val1, $val2 ), array_pop( $argsvar3 ) );
  }
 

 View on GitHub

Published: 26th November 2019 | Last updated: 20th March 2022

Primary Sidebar

Information

Function name: Tests_Actions::test_action_args_3
Class ref: Tests_Actions
Plugin ref: WordPress develop tests
Version: 5.9.3
Sourcefile: phpunit/tests/actions.php
File ref: phpunit/tests/actions.php
Deprecated?: No
API Letters: A,T

Footer

WordPress develop tests
WordPress develop tests
WordPress develop tests a2z
WordPress 6.3.1
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  develop.wp-a2z.org
© Copyright WordPress develop tests 2014-2023. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites