From 299ac4dbb9351371961155ca30d772ba2cebb549 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 31 Jul 2022 21:35:40 +0000 Subject: [PATCH] Tests: Move the test for action callback representations to the general action tests file. A separate file in the `actions` directory may have seemed like a good location at the time, but this is the only test left there. For consistency, it is now moved with the other action tests. Follow-up to [1294/tests], [53806]. See #55652. git-svn-id: https://develop.svn.wordpress.org/trunk@53808 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/actions.php | 24 +++++++++++++++++++---- tests/phpunit/tests/actions/callbacks.php | 24 ----------------------- 2 files changed, 20 insertions(+), 28 deletions(-) delete mode 100644 tests/phpunit/tests/actions/callbacks.php diff --git a/tests/phpunit/tests/actions.php b/tests/phpunit/tests/actions.php index e3cfa48ed2..e78969be08 100644 --- a/tests/phpunit/tests/actions.php +++ b/tests/phpunit/tests/actions.php @@ -331,8 +331,7 @@ class Tests_Actions extends WP_UnitTestCase { * @covers ::do_action */ public function test_action_keyed_array() { - $a = new MockAction(); - + $a = new MockAction(); $hook_name = __FUNCTION__; add_action( $hook_name, array( &$a, 'action' ) ); @@ -361,7 +360,7 @@ class Tests_Actions extends WP_UnitTestCase { * @covers ::do_action */ public function test_action_closure() { - $hook_name = 'test_action_closure'; + $hook_name = __FUNCTION__; $closure = static function( $a, $b ) { $GLOBALS[ $a ] = $b; }; @@ -374,7 +373,7 @@ class Tests_Actions extends WP_UnitTestCase { $this->assertSame( $GLOBALS[ $context[0] ], $context[1] ); - $hook_name2 = 'test_action_closure_2'; + $hook_name2 = __FUNCTION__ . '_2'; $closure2 = static function() { $GLOBALS['closure_no_args'] = true; }; @@ -390,6 +389,23 @@ class Tests_Actions extends WP_UnitTestCase { remove_action( $hook_name2, $closure2 ); } + /** + * @ticket 23265 + * + * @covers ::add_action + */ + public function test_action_callback_representations() { + $hook_name = __FUNCTION__; + + $this->assertFalse( has_action( $hook_name ) ); + + add_action( $hook_name, array( 'Class', 'method' ) ); + + $this->assertSame( 10, has_action( $hook_name, array( 'Class', 'method' ) ) ); + + $this->assertSame( 10, has_action( $hook_name, 'Class::method' ) ); + } + /** * @covers ::remove_action */ diff --git a/tests/phpunit/tests/actions/callbacks.php b/tests/phpunit/tests/actions/callbacks.php deleted file mode 100644 index ab7475a761..0000000000 --- a/tests/phpunit/tests/actions/callbacks.php +++ /dev/null @@ -1,24 +0,0 @@ -assertFalse( has_action( $hook_name ) ); - - add_action( $hook_name, array( 'Class', 'method' ) ); - - $this->assertSame( 10, has_action( $hook_name, array( 'Class', 'method' ) ) ); - - $this->assertSame( 10, has_action( $hook_name, 'Class::method' ) ); - } -}