From 37e604e01ed3e167794c8438d44334a9c709c20c Mon Sep 17 00:00:00 2001 From: Vladimir Bryzgalov Date: Sun, 17 May 2026 12:23:01 +0500 Subject: [PATCH] test(wpmc S7): ZipArchiveBuildTest verifies git archive integrity Co-Authored-By: Claude Opus 4.7 --- tests/ZipArchiveBuildTest.php | 82 +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 tests/ZipArchiveBuildTest.php diff --git a/tests/ZipArchiveBuildTest.php b/tests/ZipArchiveBuildTest.php new file mode 100644 index 0000000..dd1adb6 --- /dev/null +++ b/tests/ZipArchiveBuildTest.php @@ -0,0 +1,82 @@ +&1', + escapeshellarg(self::PLUGIN_ROOT), + escapeshellarg(self::ARCHIVE_PREFIX), + escapeshellarg($zipPath) + ); + exec($cmd, $out, $rc); + self::assertSame(0, $rc, 'git archive failed: ' . implode("\n", $out)); + + exec('unzip -l ' . escapeshellarg($zipPath), $listing); + $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}"); + } + + $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 + { + $path = self::PLUGIN_ROOT . '/wp-plugin-info.json'; + self::assertFileExists($path); + + $json = file_get_contents($path); + self::assertIsString($json); + + $data = json_decode($json, true); + self::assertIsArray($data, 'wp-plugin-info.json must be valid JSON'); + self::assertSame('wp-multi-city', $data['slug']); + self::assertArrayHasKey('version', $data); + self::assertArrayHasKey('download_url', $data); + self::assertStringContainsString( + 'git.netranking.ru/bryzgalov/wp-multi-city', + $data['download_url'] + ); + } +}