WordPress.org

Make WordPress Core

Ticket #48312: 48312.diff

File 48312.diff, 828 bytes (added by david.binda, 4 months ago)
  • tests/phpunit/tests/actions.php

     
    557557                $p1->post_title = 'Bar1';
    558558                $p2->post_title = 'Bar2';
    559559        }
     560
     561        /**
     562         * @ticket 48312
     563         *
     564         * Tests PHP 4 notation for calling actions while passing in an object by reference.
     565         */
     566        function test_action_args_4() {
     567                $a   = new MockAction();
     568                $tag = __FUNCTION__;
     569                $val = new stdClass;
     570
     571                add_action( $tag, array( &$a, 'action' ) );
     572                // call the action with PHP 4 notation for passing object by reference
     573                do_action( $tag, [ $val ] );
     574
     575                $call_count = $a->get_call_count();
     576                $argsvar = $a->get_args();
     577                $this->assertEquals( array( $val ), array_pop( $argsvar ) );
     578        }
    560579}