refactor(wpmc S7): tighten tests + cleanup bootstrap shims
tests / phpunit (push) Has been cancelled
tests / phpunit (push) Has been cancelled
- PluginBootS7Test idempotency: assertTrue(class_exists) instead of assertTrue(true) - ZipArchiveBuildTest: try/finally cleanup + unzip exit-code check - bootstrap.php: drop unused PUC shims (wp_remote_post, transient*) - CHANGELOG.md: header references Keep a Changelog (was: mirrors readme.txt) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to wp-multi-city. Format mirrors `readme.txt`.
|
||||
All notable changes to wp-multi-city. Format follows [Keep a Changelog](https://keepachangelog.com/).
|
||||
|
||||
## [1.0.0] — 2026-05-17
|
||||
|
||||
|
||||
@@ -41,6 +41,9 @@ final class PluginBootS7Test extends TestCase
|
||||
Plugin::instance()->boot();
|
||||
Plugin::instance()->boot();
|
||||
|
||||
self::assertTrue(true, 'Double boot must not throw');
|
||||
self::assertTrue(
|
||||
class_exists('YahnisElsts\\PluginUpdateChecker\\v5\\PucFactory'),
|
||||
'PucFactory must still be loaded after double boot()'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,40 +25,47 @@ final class ZipArchiveBuildTest extends BaseTestCase
|
||||
exec($cmd, $out, $rc);
|
||||
self::assertSame(0, $rc, 'git archive failed: ' . implode("\n", $out));
|
||||
|
||||
exec('unzip -l ' . escapeshellarg($zipPath), $listing);
|
||||
$joined = implode("\n", $listing);
|
||||
try {
|
||||
$listing = [];
|
||||
$unzipRc = 0;
|
||||
exec('unzip -l ' . escapeshellarg($zipPath), $listing, $unzipRc);
|
||||
self::assertSame(0, $unzipRc, 'unzip -l failed (is unzip installed?)');
|
||||
$joined = implode("\n", $listing);
|
||||
|
||||
$required = [
|
||||
'wp-multi-city/wp-multi-city.php',
|
||||
'wp-multi-city/includes/lib/plugin-update-checker/plugin-update-checker.php',
|
||||
'wp-multi-city/wp-plugin-info.json',
|
||||
'wp-multi-city/readme.txt',
|
||||
'wp-multi-city/README.md',
|
||||
];
|
||||
foreach ($required as $path) {
|
||||
self::assertStringContainsString($path, $joined, "missing in archive: {$path}");
|
||||
$required = [
|
||||
'wp-multi-city/wp-multi-city.php',
|
||||
'wp-multi-city/includes/lib/plugin-update-checker/plugin-update-checker.php',
|
||||
'wp-multi-city/wp-plugin-info.json',
|
||||
'wp-multi-city/readme.txt',
|
||||
'wp-multi-city/README.md',
|
||||
];
|
||||
foreach ($required as $path) {
|
||||
self::assertStringContainsString($path, $joined, "missing in archive: {$path}");
|
||||
}
|
||||
|
||||
$forbidden = [
|
||||
'tests/',
|
||||
'docs/',
|
||||
'composer.json',
|
||||
'phpunit.xml.dist',
|
||||
'patchwork.json',
|
||||
'release.sh',
|
||||
'CLAUDE.md',
|
||||
'.gitattributes',
|
||||
'.gitea/',
|
||||
];
|
||||
foreach ($forbidden as $path) {
|
||||
self::assertStringNotContainsString(
|
||||
'wp-multi-city/' . $path,
|
||||
$joined,
|
||||
"dev file leaked into archive: {$path}"
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
if (file_exists($zipPath)) {
|
||||
unlink($zipPath);
|
||||
}
|
||||
}
|
||||
|
||||
$forbidden = [
|
||||
'tests/',
|
||||
'docs/',
|
||||
'composer.json',
|
||||
'phpunit.xml.dist',
|
||||
'patchwork.json',
|
||||
'release.sh',
|
||||
'CLAUDE.md',
|
||||
'.gitattributes',
|
||||
'.gitea/',
|
||||
];
|
||||
foreach ($forbidden as $path) {
|
||||
self::assertStringNotContainsString(
|
||||
'wp-multi-city/' . $path,
|
||||
$joined,
|
||||
"dev file leaked into archive: {$path}"
|
||||
);
|
||||
}
|
||||
|
||||
unlink($zipPath);
|
||||
}
|
||||
|
||||
public function test_wp_plugin_info_json_is_valid(): void
|
||||
|
||||
@@ -68,21 +68,6 @@ if (!function_exists('update_option')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!function_exists('set_transient')) {
|
||||
function set_transient(string $key, $value, int $expiry = 0): bool {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!function_exists('get_transient')) {
|
||||
function get_transient(string $key) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!function_exists('delete_transient')) {
|
||||
function delete_transient(string $key): bool {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!function_exists('wp_next_scheduled')) {
|
||||
function wp_next_scheduled(string $hook, array $args = []) {
|
||||
return false;
|
||||
@@ -114,12 +99,6 @@ if (!function_exists('wp_remote_get')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!function_exists('wp_remote_post')) {
|
||||
function wp_remote_post(string $url, array $args = []) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../includes/class-plugin.php';
|
||||
\WPMultiCity\Plugin::register_autoloader();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user