Files
mxautologin/tests/package_contents_test.php
T
2026-06-30 20:33:54 +02:00

55 lines
2.5 KiB
PHP

<?php
declare(strict_types=1);
test('plugin metadata and packaging docs match project rules', function (): void {
$conf = file_get_contents(PLUGIN_ROOT . '/plugin.conf') ?: '';
$packing = file_get_contents(PROJECT_ROOT . '/PACKING.md') ?: '';
assert_contains('name=MX-Autologin', $conf);
assert_contains('id=mx_autologin', $conf);
assert_contains('type=user', $conf);
assert_contains('version=1.0.13', $conf);
assert_contains('user_run_as=root', $conf);
assert_contains('/Users/marek/GPT/ChatGPT/da_plugins/mail-login/src', $packing);
assert_contains('/Users/marek/GPT/ChatGPT/da_plugins/mail-login/archives/X.Y.Z/mx_autologin.tar.gz', $packing);
});
test('package source excludes local-only files and dangerous placeholders', function (): void {
$package = file_get_contents(PLUGIN_ROOT . '/scripts/package.sh') ?: '';
assert_contains("--exclude='./.git'", $package);
assert_contains("--exclude='./tests'", $package);
assert_contains('mx_autologin.tar.gz', $package);
assert_true(is_file(PLUGIN_ROOT . '/scripts/keygen.sh'));
$bad = [];
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(PLUGIN_ROOT, FilesystemIterator::SKIP_DOTS));
foreach ($it as $file) {
if (!$file->isFile()) {
continue;
}
$relative = substr($file->getPathname(), strlen(PLUGIN_ROOT) + 1);
if (str_starts_with($relative, '.git/') || str_starts_with($relative, 'tests/')) {
continue;
}
$content = file_get_contents($file->getPathname()) ?: '';
if (preg_match('/TODO|TBD|FIXME|placeholder|not implemented/i', $content)) {
$bad[] = $relative;
}
}
assert_same([], $bad);
});
test('directadmin entry points use mx autologin directory and display label', function (): void {
$txt = file_get_contents(PLUGIN_ROOT . '/hooks/user_txt.html') ?: '';
$img = file_get_contents(PLUGIN_ROOT . '/hooks/user_img.html') ?: '';
$login = file_get_contents(PLUGIN_ROOT . '/user/login.raw') ?: '';
$index = file_get_contents(PLUGIN_ROOT . '/user/index.html') ?: '';
assert_contains('/CMD_PLUGINS/mx_autologin/login.raw', $txt);
assert_contains('Zaloguj do serwera poczty', $txt);
assert_contains('/CMD_PLUGINS/mx_autologin/images/user_icon.svg', $img);
assert_contains('alt="Zaloguj do serwera poczty"', $img);
assert_contains('/usr/local/directadmin/plugins/mx_autologin/php.ini', $login);
assert_contains('/CMD_PLUGINS/mx_autologin/login.raw', $index);
});