Changeset 53804 for trunk/tests/phpunit/tests/actions/closures.php
- Timestamp:
- 07/31/2022 03:03:46 PM (3 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
r52010 r53804 16 16 */ 17 17 public function test_action_closure() { 18 $ tag= 'test_action_closure';19 $closure = static function( $a, $b ) {18 $hook_name = 'test_action_closure'; 19 $closure = static function( $a, $b ) { 20 20 $GLOBALS[ $a ] = $b; 21 21 }; 22 add_action( $ tag, $closure, 10, 2 );22 add_action( $hook_name, $closure, 10, 2 ); 23 23 24 $this->assertSame( 10, has_action( $ tag, $closure ) );24 $this->assertSame( 10, has_action( $hook_name, $closure ) ); 25 25 26 26 $context = array( 'val1', 'val2' ); 27 do_action( $ tag, $context[0], $context[1] );27 do_action( $hook_name, $context[0], $context[1] ); 28 28 29 29 $this->assertSame( $GLOBALS[ $context[0] ], $context[1] ); 30 30 31 $ tag2= 'test_action_closure_2';32 $closure2 = static function() {31 $hook_name2 = 'test_action_closure_2'; 32 $closure2 = static function() { 33 33 $GLOBALS['closure_no_args'] = true; 34 34 }; 35 add_action( $ tag2, $closure2 );35 add_action( $hook_name2, $closure2 ); 36 36 37 $this->assertSame( 10, has_action( $ tag2, $closure2 ) );37 $this->assertSame( 10, has_action( $hook_name2, $closure2 ) ); 38 38 39 do_action( $ tag2 );39 do_action( $hook_name2 ); 40 40 41 41 $this->assertTrue( $GLOBALS['closure_no_args'] ); 42 42 43 remove_action( $ tag, $closure );44 remove_action( $ tag2, $closure2 );43 remove_action( $hook_name, $closure ); 44 remove_action( $hook_name2, $closure2 ); 45 45 } 46 46 }
Note: See TracChangeset
for help on using the changeset viewer.