Skip to content

Commit c35dbde

Browse files
committed
fix: Improve autoload function parameter naming and add PHPCS ignore comments for test setup
1 parent 6f4c067 commit c35dbde

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

tests/bootstrap.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
// Register plugin autoloader for traits and namespaced classes.
3030
spl_autoload_register(
31-
function ( $class ) {
31+
function ( $class_name ) {
3232
// Handle PSR-4 namespaced classes (MSKD\*)
3333
if ( strpos( $class, 'MSKD\\' ) === 0 ) {
3434
// Skip test classes - they are handled by Composer autoloader.
@@ -65,18 +65,21 @@ function ( $class ) {
6565
// Create mock directory structure for PHPMailer.
6666
$phpmailer_dir = '/tmp/wordpress/wp-includes/PHPMailer';
6767
if ( ! is_dir( $phpmailer_dir ) ) {
68-
mkdir( $phpmailer_dir, 0777, true );
68+
// phpcs:ignore WordPress.WP.AlternativeFunctions.mkdir_mkdir -- Required for test setup.
69+
mkdir( $phpmailer_dir, 0777, true );
6970
}
7071

7172
// Create mock directory for wp-admin/includes.
7273
$wp_admin_includes_dir = '/tmp/wordpress/wp-admin/includes';
7374
if ( ! is_dir( $wp_admin_includes_dir ) ) {
74-
mkdir( $wp_admin_includes_dir, 0777, true );
75+
// phpcs:ignore WordPress.WP.AlternativeFunctions.mkdir_mkdir -- Required for test setup.
76+
mkdir( $wp_admin_includes_dir, 0777, true );
7577
}
7678

7779
// Create mock upgrade.php with dbDelta function stub.
7880
if ( ! file_exists( $wp_admin_includes_dir . '/upgrade.php' ) ) {
79-
file_put_contents(
81+
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Required for test setup.
82+
file_put_contents(
8083
$wp_admin_includes_dir . '/upgrade.php',
8184
'<?php
8285
// Mock upgrade.php for testing
@@ -91,7 +94,8 @@ function dbDelta( $queries = "", $execute = true ) {
9194

9295
// Create mock PHPMailer classes for testing.
9396
if ( ! file_exists( $phpmailer_dir . '/PHPMailer.php' ) ) {
94-
file_put_contents(
97+
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Required for test setup.
98+
file_put_contents(
9599
$phpmailer_dir . '/PHPMailer.php',
96100
'<?php
97101
namespace PHPMailer\PHPMailer;
@@ -117,7 +121,8 @@ public function send() { return true; }
117121
}
118122

119123
if ( ! file_exists( $phpmailer_dir . '/SMTP.php' ) ) {
120-
file_put_contents(
124+
// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Required for test setup.
125+
file_put_contents(
121126
$phpmailer_dir . '/SMTP.php',
122127
'<?php
123128
namespace PHPMailer\PHPMailer;

0 commit comments

Comments
 (0)