From 7d8b9361c5991f85626f0276970e8b281cbbe40c Mon Sep 17 00:00:00 2001 From: marcusquinn <6428977+marcusquinn@users.noreply.github.com> Date: Fri, 18 Apr 2025 20:01:13 +0100 Subject: [PATCH] Fix: Resolve CI PHPCS and PHPUnit errors - Correct docblock spacing in Admin class for PHPCS. - Update AdminTest wp_localize_script mock using Mockery::on() to fix expectation error. --- includes/Admin/class-admin.php | 1 - tests/test-admin.php | 13 +++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/includes/Admin/class-admin.php b/includes/Admin/class-admin.php index 8c03bda..d07d218 100644 --- a/includes/Admin/class-admin.php +++ b/includes/Admin/class-admin.php @@ -41,7 +41,6 @@ class Admin { /** * Enqueues admin scripts and styles. * - * @phpcs:ignore WordPress.CodeAnalysis.UnusedFunctionParameter.Found * @param string $hook_suffix The current admin page. */ diff --git a/tests/test-admin.php b/tests/test-admin.php index d807974..f4f750c 100644 --- a/tests/test-admin.php +++ b/tests/test-admin.php @@ -125,14 +125,23 @@ class AdminTest extends \WP_Mock\Tools\TestCase { 'args' => [ $script_handle, 'wpst_admin_params', - \Mockery::type( 'array' ), // We don't need to assert the exact array content here + \Mockery::on( + function ( $data ) use ( $expected_data ) { + return is_array( $data ) + && isset( $data['ajax_url'] ) + && $data['ajax_url'] === $expected_data['ajax_url'] + && isset( $data['nonce'] ) + && is_string( $data['nonce'] ); // Check nonce exists and is a string + } + ), ], ] ); // Call the method under test. - $this->admin->enqueue_admin_assets( 'test-hook' ); + $this->admin->enqueue_admin_assets( 'any_hook_suffix' ); // Assertions are implicitly handled by WP_Mock's expectation checks on tearDown. + $this->assertTrue( true ); // Add a basic assertion to prevent risky test warning } }