Changeset 42343 for trunk/tests/phpunit/tests/actions/closures.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/actions/closures.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/actions/closures.php
r38763 r42343 12 12 */ 13 13 function test_action_closure() { 14 $tag = 'test_action_closure'; 15 $closure = function($a, $b) { $GLOBALS[$a] = $b;}; 16 add_action($tag, $closure, 10, 2); 14 $tag = 'test_action_closure'; 15 $closure = function( $a, $b ) { 16 $GLOBALS[ $a ] = $b; 17 }; 18 add_action( $tag, $closure, 10, 2 ); 17 19 18 $this->assertSame( 10, has_action( $tag, $closure) );20 $this->assertSame( 10, has_action( $tag, $closure ) ); 19 21 20 22 $context = array( 'val1', 'val2' ); 21 do_action( $tag, $context[0], $context[1]);23 do_action( $tag, $context[0], $context[1] ); 22 24 23 $this->assertSame( $GLOBALS[$context[0]], $context[1]);25 $this->assertSame( $GLOBALS[ $context[0] ], $context[1] ); 24 26 25 $tag2 = 'test_action_closure_2'; 26 $closure2 = function() { $GLOBALS['closure_no_args'] = true;}; 27 add_action($tag2, $closure2); 27 $tag2 = 'test_action_closure_2'; 28 $closure2 = function() { 29 $GLOBALS['closure_no_args'] = true; 30 }; 31 add_action( $tag2, $closure2 ); 28 32 29 $this->assertSame( 10, has_action( $tag2, $closure2) );33 $this->assertSame( 10, has_action( $tag2, $closure2 ) ); 30 34 31 do_action( $tag2);35 do_action( $tag2 ); 32 36 33 $this->assertTrue( $GLOBALS['closure_no_args']);37 $this->assertTrue( $GLOBALS['closure_no_args'] ); 34 38 35 39 remove_action( $tag, $closure );
Note: See TracChangeset
for help on using the changeset viewer.