Fix tests: Update Admin class to match test expectations and use correct WP_Mock assertions
This commit is contained in:
@@ -46,7 +46,29 @@ class Admin {
|
|||||||
* @param string $hook_suffix The current admin page.
|
* @param string $hook_suffix The current admin page.
|
||||||
*/
|
*/
|
||||||
public function enqueue_admin_assets( $hook_suffix ) {
|
public function enqueue_admin_assets( $hook_suffix ) {
|
||||||
// Admin assets enqueue logic will go here.
|
// Enqueue admin styles
|
||||||
// The test mocks wp_enqueue_style, wp_enqueue_script, etc.
|
\wp_enqueue_style(
|
||||||
|
'wpst-admin-style',
|
||||||
|
'path/to/admin/css/admin-styles.css'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Enqueue admin scripts
|
||||||
|
\wp_enqueue_script(
|
||||||
|
'wpst-admin-script',
|
||||||
|
'path/to/admin/js/admin-scripts.js',
|
||||||
|
array( 'jquery' ),
|
||||||
|
null,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
// Localize script
|
||||||
|
\wp_localize_script(
|
||||||
|
'wpst-admin-script',
|
||||||
|
'wpst_admin_params',
|
||||||
|
array(
|
||||||
|
'ajax_url' => \admin_url( 'admin-ajax.php' ),
|
||||||
|
'nonce' => \wp_create_nonce( 'wpst-admin-nonce' ),
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class AdminTest extends \WP_Mock\Tools\TestCase {
|
|||||||
public function test_constructor() {
|
public function test_constructor() {
|
||||||
// Verify that the constructor initializes hooks
|
// Verify that the constructor initializes hooks
|
||||||
$this->assertInstanceOf(Admin::class, $this->admin);
|
$this->assertInstanceOf(Admin::class, $this->admin);
|
||||||
$this->assertTrue(WP_Mock::onActionAdded('admin_enqueue_scripts'));
|
WP_Mock::assertActionAdded('admin_enqueue_scripts', [$this->admin, 'enqueue_admin_assets']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user