From a0df887d5c740775213b3ed919604b178124abf0 Mon Sep 17 00:00:00 2001 From: marcusquinn <6428977+marcusquinn@users.noreply.github.com> Date: Fri, 18 Apr 2025 18:44:29 +0100 Subject: [PATCH] Fix: Instantiate Admin before setting add_action mock to use correct object reference --- tests/test-admin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test-admin.php b/tests/test-admin.php index 85aa40b..56a4b31 100644 --- a/tests/test-admin.php +++ b/tests/test-admin.php @@ -39,14 +39,14 @@ class AdminTest extends \WP_Mock\Tools\TestCase { // Mock Core class $this->core = $this->createMock(Core::class); - // Set up WordPress function mocks + // Instantiate the class under test first + $this->admin = new Admin($this->core); + + // Set up WordPress function mocks after instantiation to use the correct object reference 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); } /**