From 4d69c446dbe25ad37c3e2f173bda90c5340c0f27 Mon Sep 17 00:00:00 2001 From: marcusquinn <6428977+marcusquinn@users.noreply.github.com> Date: Fri, 18 Apr 2025 18:41:06 +0100 Subject: [PATCH] Fix: Use WP_Mock::userFunction for add_action instead of expectActionAdded --- tests/test-admin.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test-admin.php b/tests/test-admin.php index dd7b285..85aa40b 100644 --- a/tests/test-admin.php +++ b/tests/test-admin.php @@ -40,7 +40,10 @@ class AdminTest extends \WP_Mock\Tools\TestCase { $this->core = $this->createMock(Core::class); // Set up WordPress function mocks - WP_Mock::expectActionAdded('admin_enqueue_scripts', [$this->admin, 'enqueue_admin_assets']); + WP_Mock::userFunction('add_action', [ + 'times' => 1, + 'args' => ['admin_enqueue_scripts', [$this->admin, 'enqueue_admin_assets']] + ]); // Instantiate the class under test *after* setting up mocks $this->admin = new Admin($this->core);