mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
wp-tests-config.php can/should reside in the root of a develop checkout. `phpunit` should be run from the root. see #25088. git-svn-id: https://develop.svn.wordpress.org/trunk@25165 602fd350-edb4-49c9-b593-d223f7449a82
39 lines
863 B
PHP
39 lines
863 B
PHP
<?php
|
|
|
|
/**
|
|
* Test do_action() and related functions
|
|
*
|
|
* @group hooks
|
|
*/
|
|
class Tests_Actions_Closures extends WP_UnitTestCase {
|
|
|
|
/**
|
|
* @ticket 10493
|
|
*/
|
|
function test_action_closure() {
|
|
$tag = 'test_action_closure';
|
|
$closure = function($a, $b) { $GLOBALS[$a] = $b;};
|
|
add_action($tag, $closure, 10, 2);
|
|
|
|
$this->assertSame( 10, has_action($tag, $closure) );
|
|
|
|
$context = array( rand_str(), rand_str() );
|
|
do_action($tag, $context[0], $context[1]);
|
|
|
|
$this->assertSame($GLOBALS[$context[0]], $context[1]);
|
|
|
|
$tag2 = 'test_action_closure_2';
|
|
$closure2 = function() { $GLOBALS['closure_no_args'] = true;};
|
|
add_action($tag2, $closure2);
|
|
|
|
$this->assertSame( 10, has_action($tag2, $closure2) );
|
|
|
|
do_action($tag2);
|
|
|
|
$this->assertTrue($GLOBALS['closure_no_args']);
|
|
|
|
remove_action( $tag, $closure );
|
|
remove_action( $tag2, $closure2 );
|
|
}
|
|
}
|