|
15 | 15 |
|
16 | 16 | // Detect PHP version |
17 | 17 | $php_version = phpversion(); |
| 18 | + |
18 | 19 | $php_major_version = (int)explode('.', $php_version)[0]; |
19 | 20 | $php_minor_version = (int)explode('.', explode('.', $php_version)[1])[0]; |
20 | 21 |
|
21 | | -echo "PHP Version: $php_version\n"; |
| 22 | +if (function_exists('esc_html')) { |
| 23 | + echo esc_html("PHP Version: $php_version") . "\n"; |
| 24 | +} else { |
| 25 | + echo "PHP Version: $php_version\n"; |
| 26 | +} |
22 | 27 |
|
23 | 28 | // Define the path to the PHPUnit executable |
24 | 29 | $phpunit_path = __DIR__ . '/vendor/bin/phpunit'; |
25 | 30 |
|
26 | 31 | if (!file_exists($phpunit_path)) { |
27 | | - echo "Error: PHPUnit not found at $phpunit_path\n"; |
28 | | - echo "Please run 'composer install' first.\n"; |
| 32 | + if (function_exists('esc_html')) { |
| 33 | + echo esc_html("Error: PHPUnit not found at $phpunit_path") . "\n"; |
| 34 | + echo esc_html("Please run 'composer install' first.") . "\n"; |
| 35 | + } else { |
| 36 | + echo "Error: PHPUnit not found at $phpunit_path\n"; |
| 37 | + echo "Please run 'composer install' first.\n"; |
| 38 | + } |
29 | 39 | exit(1); |
30 | 40 | } |
31 | 41 |
|
32 | 42 | // Get the PHPUnit version |
33 | 43 | $phpunit_version_output = shell_exec("$phpunit_path --version"); |
34 | 44 | preg_match('/PHPUnit\s+([0-9]+\.[0-9]+)/', $phpunit_version_output, $matches); |
35 | 45 | $phpunit_version = isset($matches[1]) ? $matches[1] : 'unknown'; |
36 | | -echo "PHPUnit Version: $phpunit_version\n"; |
| 46 | +if (function_exists('esc_html')) { |
| 47 | + echo esc_html("PHPUnit Version: $phpunit_version") . "\n"; |
| 48 | +} else { |
| 49 | + echo "PHPUnit Version: $phpunit_version\n"; |
| 50 | +} |
37 | 51 |
|
38 | 52 | // Build the command arguments |
39 | 53 | $args = $_SERVER['argv']; |
|
44 | 58 |
|
45 | 59 | // PHP 8.x specific settings |
46 | 60 | if ($php_major_version >= 8) { |
47 | | - echo "Running in PHP 8.x compatibility mode\n"; |
| 61 | + if (function_exists('esc_html')) { |
| 62 | + echo esc_html("Running in PHP 8.x compatibility mode") . "\n"; |
| 63 | + } else { |
| 64 | + echo "Running in PHP 8.x compatibility mode\n"; |
| 65 | + } |
48 | 66 |
|
49 | 67 | // For PHP 8.3 and 8.4, use PHPUnit 10+ with specific settings |
50 | 68 | if ($php_major_version == 8 && ($php_minor_version >= 3)) { |
51 | | - echo "Using PHP 8.3+ with PHPUnit requires special handling\n"; |
| 69 | + if (function_exists('esc_html')) { |
| 70 | + echo esc_html("Using PHP 8.3+ with PHPUnit requires special handling") . "\n"; |
| 71 | + } else { |
| 72 | + echo "Using PHP 8.3+ with PHPUnit requires special handling\n"; |
| 73 | + } |
52 | 74 |
|
53 | 75 | // Add any PHP 8.3/8.4 specific flags |
54 | 76 | $default_args[] = '--no-deprecations'; |
55 | 77 |
|
56 | 78 | // For PHPUnit 10+ |
57 | 79 | if (version_compare($phpunit_version, '10.0', '>=')) { |
58 | | - echo "Using PHPUnit 10+ with PHP 8.3+\n"; |
| 80 | + if (function_exists('esc_html')) { |
| 81 | + echo esc_html("Using PHPUnit 10+ with PHP 8.3+") . "\n"; |
| 82 | + } else { |
| 83 | + echo "Using PHPUnit 10+ with PHP 8.3+\n"; |
| 84 | + } |
59 | 85 | // No special settings needed for PHPUnit 10+ |
60 | 86 | } else { |
61 | | - echo "Warning: Using older PHPUnit with PHP 8.3+, some features may not work correctly\n"; |
| 87 | + if (function_exists('esc_html')) { |
| 88 | + echo esc_html("Warning: Using older PHPUnit with PHP 8.3+, some features may not work correctly") . "\n"; |
| 89 | + } else { |
| 90 | + echo "Warning: Using older PHPUnit with PHP 8.3+, some features may not work correctly\n"; |
| 91 | + } |
62 | 92 | } |
63 | 93 | } |
64 | 94 | // For PHP 8.0-8.2 (using PHPUnit 9.x typically) |
65 | 95 | elseif ($php_minor_version >= 0 && $php_minor_version <= 2) { |
66 | | - echo "Using PHP 8.0-8.2 with appropriate PHPUnit version\n"; |
| 96 | + if (function_exists('esc_html')) { |
| 97 | + echo esc_html("Using PHP 8.0-8.2 with appropriate PHPUnit version") . "\n"; |
| 98 | + } else { |
| 99 | + echo "Using PHP 8.0-8.2 with appropriate PHPUnit version\n"; |
| 100 | + } |
67 | 101 |
|
68 | 102 | // If using older PHPUnit with PHP 8.x |
69 | 103 | if (version_compare($phpunit_version, '9.0', '<')) { |
70 | | - echo "Using PHPUnit < 9.0 with PHP 8.x requires special handling\n"; |
| 104 | + if (function_exists('esc_html')) { |
| 105 | + echo esc_html("Using PHPUnit < 9.0 with PHP 8.x requires special handling") . "\n"; |
| 106 | + } else { |
| 107 | + echo "Using PHPUnit < 9.0 with PHP 8.x requires special handling\n"; |
| 108 | + } |
71 | 109 |
|
72 | 110 | // Load the compatibility layer first |
73 | 111 | if (file_exists(__DIR__ . '/tests/php8-compatibility.php')) { |
74 | | - echo "Loading PHP 8.x compatibility layer\n"; |
| 112 | + if (function_exists('esc_html')) { |
| 113 | + echo esc_html("Loading PHP 8.x compatibility layer") . "\n"; |
| 114 | + } else { |
| 115 | + echo "Loading PHP 8.x compatibility layer\n"; |
| 116 | + } |
75 | 117 | require_once __DIR__ . '/tests/php8-compatibility.php'; |
76 | 118 | } |
77 | 119 |
|
78 | 120 | // Use custom error settings |
79 | 121 | error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED & ~E_STRICT); |
80 | 122 | } else { |
81 | | - echo "Using PHPUnit 9.x with PHP 8.0-8.2\n"; |
| 123 | + if (function_exists('esc_html')) { |
| 124 | + echo esc_html("Using PHPUnit 9.x with PHP 8.0-8.2") . "\n"; |
| 125 | + } else { |
| 126 | + echo "Using PHPUnit 9.x with PHP 8.0-8.2\n"; |
| 127 | + } |
82 | 128 | } |
83 | 129 | } |
84 | 130 | } |
|
87 | 133 | $command = escapeshellcmd($phpunit_path); |
88 | 134 | $command .= ' ' . implode(' ', array_map('escapeshellarg', array_merge($default_args, $args))); |
89 | 135 |
|
90 | | -echo "Running command: $command\n"; |
91 | | -echo "-----------------------------------------------------------\n"; |
| 136 | +if (function_exists('esc_html')) { |
| 137 | + echo esc_html("Running command: $command") . "\n"; |
| 138 | + echo esc_html("-----------------------------------------------------------") . "\n"; |
| 139 | +} else { |
| 140 | + echo "Running command: $command\n"; |
| 141 | + echo "-----------------------------------------------------------\n"; |
| 142 | +} |
92 | 143 |
|
93 | 144 | // Execute PHPUnit with the arguments |
94 | 145 | passthru($command, $return_var); |
|
0 commit comments