Changeset 53806
- Timestamp:
- 07/31/2022 04:41:53 PM (3 years ago)
- Location:
- trunk/tests/phpunit/tests
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/actions.php
r53805 r53806 352 352 $args = $a->get_args(); 353 353 $this->assertSame( $args[1][0], $context2 ); 354 354 } 355 356 /** 357 * @ticket 10493 358 * 359 * @covers ::add_action 360 * @covers ::has_action 361 * @covers ::do_action 362 */ 363 public function test_action_closure() { 364 $hook_name = 'test_action_closure'; 365 $closure = static function( $a, $b ) { 366 $GLOBALS[ $a ] = $b; 367 }; 368 add_action( $hook_name, $closure, 10, 2 ); 369 370 $this->assertSame( 10, has_action( $hook_name, $closure ) ); 371 372 $context = array( 'val1', 'val2' ); 373 do_action( $hook_name, $context[0], $context[1] ); 374 375 $this->assertSame( $GLOBALS[ $context[0] ], $context[1] ); 376 377 $hook_name2 = 'test_action_closure_2'; 378 $closure2 = static function() { 379 $GLOBALS['closure_no_args'] = true; 380 }; 381 add_action( $hook_name2, $closure2 ); 382 383 $this->assertSame( 10, has_action( $hook_name2, $closure2 ) ); 384 385 do_action( $hook_name2 ); 386 387 $this->assertTrue( $GLOBALS['closure_no_args'] ); 388 389 remove_action( $hook_name, $closure ); 390 remove_action( $hook_name2, $closure2 ); 355 391 } 356 392
Note: See TracChangeset
for help on using the changeset viewer.