defaultLanguage()); assert_false($settings->defaultEnable()); assert_same('Europe/Warsaw', $settings->timezone()); assert_same('exact_hour', $settings->scheduleMode()); assert_same('exim', $settings->backendMode()); assert_same('/usr/local/hitme_plugins/global-autoresponders/config', Settings::CONFIG_DIR); assert_same('/usr/local/hitme_plugins/global-autoresponders/data', Settings::DATA_DIR); }); test('settings template does not contain global repeat policy settings', function (): void { $template = file_get_contents(PLUGIN_ROOT . '/plugin-settings.conf') ?: ''; assert_false(str_contains($template, 'GLOBAL_AUTORESPONDER_REPLY_EVERY_MESSAGE')); assert_false(str_contains($template, 'GLOBAL_AUTORESPONDER_REPEAT_MINUTES')); }); test('settings reject invalid timezone and schedule mode', function (): void { $path = TEST_TMP . '/bad-settings.conf'; test_write($path, "GLOBAL_AUTORESPONDER_TIMEZONE=Not/AZone\nGLOBAL_AUTORESPONDER_BACKEND=bad\n"); try { Settings::load($path); } catch (InvalidArgumentException $e) { assert_contains('timezone', $e->getMessage()); return; } throw new RuntimeException('Expected invalid settings to fail'); }); test('backend mode derives schedule mode', function (): void { $path = TEST_TMP . '/backend.conf'; test_write($path, "GLOBAL_AUTORESPONDER_BACKEND=da\n"); $settings = Settings::load($path); assert_same('da', $settings->backendMode()); assert_same('directadmin_period', $settings->scheduleMode()); test_write($path, "GLOBAL_AUTORESPONDER_BACKEND=exim\n"); $settings = Settings::load($path); assert_same('exim', $settings->backendMode()); assert_same('exact_hour', $settings->scheduleMode()); }); test('directadmin user access follows DEFAULT_ENABLE and per-user overrides', function (): void { $settingsPath = TEST_TMP . '/access.conf'; test_write($settingsPath, "DEFAULT_ENABLE=false\n"); $settings = Settings::load($settingsPath); $user = new DirectAdminUser('marek', 'enhanced', 'en', TEST_TMP . '/config'); assert_false($user->hasPluginAccess($settings)); test_write(TEST_TMP . '/config/users/marek.conf', "enabled=true\n"); assert_true($user->hasPluginAccess($settings)); });