Sync global-autoresponder current state
This commit is contained in:
+304
-20
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
test('mockup and planned UI do not expose backend terms', function (): void {
|
||||
test('mockup and planned UI do not expose removed internal mail terms', function (): void {
|
||||
foreach (glob(dirname(__DIR__, 2) . '/docs/mockups/*.html') ?: [] as $file) {
|
||||
$html = file_get_contents($file) ?: '';
|
||||
assert_false(stripos($html, 'Exim') !== false, basename($file) . ' exposes Exim');
|
||||
assert_false(stripos($html, 'Ex' . 'im') !== false, basename($file) . ' exposes removed mail integration');
|
||||
assert_false(stripos($html, 'DirectAdmin API') !== false, basename($file) . ' exposes API');
|
||||
assert_false(stripos($html, 'backend.sh') !== false, basename($file) . ' exposes backend script');
|
||||
assert_false(stripos($html, 'back' . 'end.sh') !== false, basename($file) . ' exposes removed switch script');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -46,7 +46,7 @@ test('autoresponder index keeps add button only in top navigation', function ():
|
||||
assert_false(strpos($source, "ctx->t('Add autoresponder')") !== false);
|
||||
});
|
||||
|
||||
test('rule form uses minute time input and no summary box in exim mode', function (): void {
|
||||
test('rule form uses minute time input and directadmin frequency range', function (): void {
|
||||
require_once PLUGIN_ROOT . '/exec/lib/Settings.php';
|
||||
require_once PLUGIN_ROOT . '/exec/lib/Lang.php';
|
||||
require_once PLUGIN_ROOT . '/exec/lib/DirectAdminUser.php';
|
||||
@@ -57,7 +57,7 @@ test('rule form uses minute time input and no summary box in exim mode', functio
|
||||
require_once PLUGIN_ROOT . '/exec/handlers/_form_helpers.php';
|
||||
|
||||
$settingsPath = TEST_TMP . '/form.conf';
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\nGLOBAL_AUTORESPONDER_BACKEND=exim\n");
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
$ctx = new AppContext(
|
||||
new DirectAdminUser('alice', 'enhanced', 'pl', TEST_TMP . '/config'),
|
||||
@@ -69,21 +69,230 @@ test('rule form uses minute time input and no summary box in exim mode', functio
|
||||
);
|
||||
|
||||
$html = render_rule_form($ctx, 'create', null);
|
||||
assert_contains('name="name"', $html);
|
||||
assert_contains('Nazwa autorespondera', $html);
|
||||
assert_contains('Ta nazwa jest wykorzystywana tylko w celach opisowych', $html);
|
||||
assert_contains('type="time"', $html);
|
||||
assert_contains('step="60"', $html);
|
||||
assert_false(strpos($html, 'summary-card') !== false, 'Summary box should not be rendered in create/edit form');
|
||||
assert_contains('Przedrostek tematu', $html);
|
||||
assert_contains(': pierwotny temat', $html);
|
||||
assert_contains('Częstość odpowiedzi', $html);
|
||||
assert_contains('Wysyłaj automatyczną odpowiedź dla każdej wiadomości', $html);
|
||||
assert_false(strpos($html, 'Wysyłaj automatyczną odpowiedź dla każdej wiadomości') !== false);
|
||||
assert_contains('14 dni', $html);
|
||||
assert_contains('1 minuta', $html);
|
||||
assert_contains('1 dzień', $html);
|
||||
assert_contains('Treść wiadomości', $html);
|
||||
});
|
||||
|
||||
test('rule form uses exact hour selector and directadmin frequency range in da mode', function (): void {
|
||||
test('autoresponder index shows descriptive name and created timestamp columns', function (): void {
|
||||
$settingsPath = TEST_TMP . '/index-columns.conf';
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
$repo = new RuleRepository(TEST_TMP . '/index-data');
|
||||
$repo->create('alice', [
|
||||
'name' => 'Urlop zarządu',
|
||||
'subject_prefix' => 'Urlop',
|
||||
'repeat_minutes' => 1440,
|
||||
'body' => 'Body',
|
||||
'enabled' => true,
|
||||
'start_ts' => 1780495200,
|
||||
'end_ts' => 1780581540,
|
||||
]);
|
||||
$ctx = new AppContext(
|
||||
new DirectAdminUser('alice', 'enhanced', 'pl', TEST_TMP . '/config'),
|
||||
$settings,
|
||||
$repo,
|
||||
new CsrfGuard('secret', 'alice', 'sid'),
|
||||
Lang::load('pl', $settings),
|
||||
new AuditLog(TEST_TMP . '/audit.log')
|
||||
);
|
||||
|
||||
$html = render_rules_index_body($ctx);
|
||||
assert_contains('Nazwa autorespondera', $html);
|
||||
assert_contains('Utworzono', $html);
|
||||
assert_contains('Urlop zarządu', $html);
|
||||
assert_false(strpos($html, 'Zaktualizowano') !== false);
|
||||
});
|
||||
|
||||
test('dashboard omits account mailbox helper subtitles', function (): void {
|
||||
$settingsPath = TEST_TMP . '/index-subtitles.conf';
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
$repo = new RuleRepository(TEST_TMP . '/index-subtitles-data');
|
||||
$repo->create('alice', [
|
||||
'name' => 'Urlop zarządu',
|
||||
'subject_prefix' => 'Urlop',
|
||||
'repeat_minutes' => 1440,
|
||||
'body' => 'Body',
|
||||
'enabled' => true,
|
||||
'start_ts' => 1780495200,
|
||||
'end_ts' => 1780581540,
|
||||
]);
|
||||
$ctx = new AppContext(
|
||||
new DirectAdminUser('alice', 'enhanced', 'pl', TEST_TMP . '/config'),
|
||||
$settings,
|
||||
$repo,
|
||||
new CsrfGuard('secret', 'alice', 'sid'),
|
||||
Lang::load('pl', $settings),
|
||||
new AuditLog(TEST_TMP . '/audit.log')
|
||||
);
|
||||
|
||||
$index = render_rules_index_body($ctx);
|
||||
$chrome = file_get_contents(PLUGIN_ROOT . '/exec/lib/AppContext.php') ?: '';
|
||||
|
||||
assert_false(strpos($index, 'Wszystkie prawidłowe skrzynki POP/IMAP konta') !== false);
|
||||
assert_false(strpos($chrome, 'Manage automatic replies for account mailboxes') !== false);
|
||||
});
|
||||
|
||||
test('create conflict modal offers replacing active rule or adding disabled rule', function (): void {
|
||||
$settingsPath = TEST_TMP . '/create-conflict.conf';
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
$repo = new RuleRepository(TEST_TMP . '/create-conflict-data');
|
||||
$existing = $repo->create('alice', [
|
||||
'name' => 'Stary urlop',
|
||||
'subject_prefix' => 'Urlop',
|
||||
'repeat_minutes' => 1440,
|
||||
'body' => 'Body',
|
||||
'enabled' => true,
|
||||
'start_ts' => 1780495200,
|
||||
'end_ts' => 1780581540,
|
||||
]);
|
||||
$ctx = new AppContext(
|
||||
new DirectAdminUser('alice', 'enhanced', 'pl', TEST_TMP . '/config'),
|
||||
$settings,
|
||||
$repo,
|
||||
new CsrfGuard('secret', 'alice', 'sid'),
|
||||
Lang::load('pl', $settings),
|
||||
new AuditLog(TEST_TMP . '/audit.log')
|
||||
);
|
||||
|
||||
$modal = render_create_conflict_modal($ctx, [
|
||||
'name' => 'Nowy urlop',
|
||||
'subject_prefix' => 'Nowy',
|
||||
'repeat_minutes' => 1440,
|
||||
'body' => 'Nowa treść',
|
||||
'enabled' => true,
|
||||
'start_value' => '2026-06-10T00:00',
|
||||
'end_value' => '2026-06-24T23:59',
|
||||
], $existing);
|
||||
|
||||
assert_contains('Dla użytkownika alice istnieje już globalny autoresponder', $modal);
|
||||
assert_contains('Stary urlop', $modal);
|
||||
assert_contains('Nowy urlop', $modal);
|
||||
assert_contains('name="conflict_action" value="replace"', $modal);
|
||||
assert_contains('name="conflict_action" value="create_disabled"', $modal);
|
||||
assert_contains('Włącz autoresponder (Nowy urlop) i wyłącz poprzedni (Stary urlop)', $modal);
|
||||
assert_contains('Dodaj autoresponder (Nowy urlop) jako wyłączony', $modal);
|
||||
});
|
||||
|
||||
test('native directadmin autoresponder modal lists entries before creating global rule', function (): void {
|
||||
$settingsPath = TEST_TMP . '/native-conflict.conf';
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
$ctx = new AppContext(
|
||||
new DirectAdminUser('alice', 'enhanced', 'pl', TEST_TMP . '/config'),
|
||||
$settings,
|
||||
new RuleRepository(TEST_TMP . '/native-conflict-data'),
|
||||
new CsrfGuard('secret', 'alice', 'sid'),
|
||||
Lang::load('pl', $settings),
|
||||
new AuditLog(TEST_TMP . '/audit.log')
|
||||
);
|
||||
|
||||
$modal = render_native_vacation_conflict_modal($ctx, [
|
||||
'name' => 'Nowy urlop',
|
||||
'subject_prefix' => 'Nowy',
|
||||
'repeat_minutes' => 1440,
|
||||
'body' => 'Nowa treść',
|
||||
'enabled' => true,
|
||||
'start_value' => '2026-06-10T00:00',
|
||||
'end_value' => '2026-06-24T23:59',
|
||||
], [
|
||||
['domain' => 'example.com', 'mailbox' => 'info', 'email' => 'info@example.com'],
|
||||
['domain' => 'example.com', 'mailbox' => 'sales', 'email' => 'sales@example.com'],
|
||||
]);
|
||||
|
||||
assert_contains('użytkownik alice ma już utworzone natywne autorespondery', $modal);
|
||||
assert_contains('info@example.com', $modal);
|
||||
assert_contains('sales@example.com', $modal);
|
||||
assert_contains('name="native_conflict_action" value="disable_native"', $modal);
|
||||
assert_contains('<strong>Istniejące autorespondery / wiadomości urlopowe zostaną usunięte w przypadku kontynuacji.</strong>', $modal);
|
||||
assert_contains('class="danger-fill" type="submit">USUŃ ISTNIEJĄCE AUTORESPONDERY</button>', $modal);
|
||||
assert_contains('Anuluj', $modal);
|
||||
});
|
||||
|
||||
test('delete confirmation only asks yes no with rule name and created date', function (): void {
|
||||
$settingsPath = TEST_TMP . '/delete-confirm.conf';
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\nGLOBAL_AUTORESPONDER_TIMEZONE=Europe/Warsaw\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
$ctx = new AppContext(
|
||||
new DirectAdminUser('alice', 'enhanced', 'pl', TEST_TMP . '/config'),
|
||||
$settings,
|
||||
new RuleRepository(TEST_TMP . '/delete-confirm-data'),
|
||||
new CsrfGuard('secret', 'alice', 'sid'),
|
||||
Lang::load('pl', $settings),
|
||||
new AuditLog(TEST_TMP . '/audit.log')
|
||||
);
|
||||
$rule = [
|
||||
'id' => 'rule-delete',
|
||||
'name' => 'Urlop testowy',
|
||||
'subject_prefix' => 'Urlop',
|
||||
'created_at' => 1780495200,
|
||||
];
|
||||
|
||||
$html = render_delete_confirmation_body($ctx, $rule);
|
||||
|
||||
assert_contains('Czy napewno chcesz usunąć globalny autoresponder Urlop testowy utworzony 2026-06-03 16:00?', $html);
|
||||
assert_contains('>Tak</button>', $html);
|
||||
assert_contains('>Nie</a>', $html);
|
||||
assert_false(strpos($html, 'Preview autoresponder') !== false);
|
||||
assert_false(strpos($html, 'Deleting this rule will disable') !== false);
|
||||
assert_false(strpos($html, 'Treść odpowiedzi') !== false);
|
||||
});
|
||||
|
||||
test('toggle conflict modal asks before replacing currently active rule', function (): void {
|
||||
$settingsPath = TEST_TMP . '/toggle-conflict.conf';
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
$repo = new RuleRepository(TEST_TMP . '/toggle-conflict-data');
|
||||
$existing = $repo->create('alice', [
|
||||
'name' => 'Aktywny urlop',
|
||||
'subject_prefix' => 'Urlop',
|
||||
'repeat_minutes' => 1440,
|
||||
'body' => 'Body',
|
||||
'enabled' => true,
|
||||
'start_ts' => 1780495200,
|
||||
'end_ts' => 1780581540,
|
||||
]);
|
||||
$target = $repo->create('alice', [
|
||||
'name' => 'Nowy aktywny',
|
||||
'subject_prefix' => 'Nowy',
|
||||
'repeat_minutes' => 1440,
|
||||
'body' => 'Body',
|
||||
'enabled' => false,
|
||||
'start_ts' => 1780495200,
|
||||
'end_ts' => 1780581540,
|
||||
]);
|
||||
$ctx = new AppContext(
|
||||
new DirectAdminUser('alice', 'enhanced', 'pl', TEST_TMP . '/config'),
|
||||
$settings,
|
||||
$repo,
|
||||
new CsrfGuard('secret', 'alice', 'sid'),
|
||||
Lang::load('pl', $settings),
|
||||
new AuditLog(TEST_TMP . '/audit.log')
|
||||
);
|
||||
|
||||
$modal = render_toggle_conflict_modal($ctx, $target, $existing);
|
||||
assert_contains('może być aktywny tylko jeden globalny autoresponder', $modal);
|
||||
assert_contains('Włącz autoresponder', $modal);
|
||||
assert_contains('name="conflict_action" value="replace"', $modal);
|
||||
assert_contains('name="id" value="' . $target['id'] . '"', $modal);
|
||||
});
|
||||
|
||||
test('rule form uses exact hour selector and directadmin frequency range', function (): void {
|
||||
$settingsPath = TEST_TMP . '/form-da.conf';
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\nGLOBAL_AUTORESPONDER_BACKEND=da\n");
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
$ctx = new AppContext(
|
||||
new DirectAdminUser('alice', 'enhanced', 'pl', TEST_TMP . '/config'),
|
||||
@@ -102,22 +311,69 @@ test('rule form uses exact hour selector and directadmin frequency range in da m
|
||||
assert_false(strpos($html, 'name="start_value_period"') !== false);
|
||||
});
|
||||
|
||||
test('rule form groups start and end calendars in one schedule panel', function (): void {
|
||||
$settingsPath = TEST_TMP . '/form-schedule-layout.conf';
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
$ctx = new AppContext(
|
||||
new DirectAdminUser('alice', 'enhanced', 'pl', TEST_TMP . '/config'),
|
||||
$settings,
|
||||
new RuleRepository(TEST_TMP . '/data'),
|
||||
new CsrfGuard('secret', 'alice', 'sid'),
|
||||
Lang::load('pl', $settings),
|
||||
new AuditLog(TEST_TMP . '/audit.log')
|
||||
);
|
||||
|
||||
$html = render_rule_form($ctx, 'create', null);
|
||||
assert_same(1, substr_count($html, 'schedule-panel'));
|
||||
assert_contains('schedule-grid', $html);
|
||||
assert_contains('schedule-column schedule-start', $html);
|
||||
assert_contains('schedule-column schedule-end', $html);
|
||||
assert_contains('Data rozpoczęcia', $html);
|
||||
assert_contains('Godzina rozpoczęcia', $html);
|
||||
assert_contains('Data zakończenia', $html);
|
||||
assert_contains('Godzina zakończenia', $html);
|
||||
});
|
||||
|
||||
test('skins define different schedule calendar layouts', function (): void {
|
||||
$enhanced = file_get_contents(PLUGIN_ROOT . '/user/enhanced.css') ?: '';
|
||||
$evolution = file_get_contents(PLUGIN_ROOT . '/user/evolution.css') ?: '';
|
||||
$appContext = file_get_contents(PLUGIN_ROOT . '/exec/lib/AppContext.php') ?: '';
|
||||
|
||||
assert_contains('.schedule-grid { grid-template-columns: 1fr;', $enhanced);
|
||||
assert_contains('.schedule-grid { grid-template-columns: repeat(2, minmax(460px, 1fr));', $evolution);
|
||||
assert_contains('.schedule-scroll { overflow-x: auto;', $evolution);
|
||||
assert_contains('width: 100% !important;', $evolution);
|
||||
assert_contains('margin-left: 0 !important;', $evolution);
|
||||
assert_contains('max-width: none !important;', $evolution);
|
||||
assert_false(str_contains($evolution, '#content'), 'Evolution CSS must not override DirectAdmin shell containers globally');
|
||||
assert_false((bool)preg_match('/^\\.container,$/m', $evolution), 'Evolution CSS must not override every DirectAdmin container globally');
|
||||
assert_false(str_contains($evolution, '.content-wrapper'), 'Evolution CSS must not override shell wrappers globally');
|
||||
assert_false(str_contains($evolution, '@import'));
|
||||
assert_contains("skin === 'evolution'", $appContext);
|
||||
assert_contains("enhanced.css", $appContext);
|
||||
assert_contains("evolution.css", $appContext);
|
||||
assert_contains('expandDirectAdminPluginContainers', $appContext);
|
||||
assert_contains("pluginSkin !== 'evolution'", $appContext);
|
||||
assert_contains("wrap.parentElement", $appContext);
|
||||
});
|
||||
|
||||
test('autoresponder table does not expose mailbox scope column', function (): void {
|
||||
$source = file_get_contents(PLUGIN_ROOT . '/exec/handlers/index.php') ?: '';
|
||||
assert_false(strpos($source, "ctx->t('Scope')") !== false);
|
||||
assert_false(strpos($source, "ctx->t(\$rule['dynamic_scope']") !== false);
|
||||
});
|
||||
|
||||
test('mutating handlers synchronize active backend after storage changes', function (): void {
|
||||
test('mutating handlers synchronize directadmin vacations after storage changes', function (): void {
|
||||
foreach (['create.php', 'update.php', 'delete.php', 'toggle.php'] as $handler) {
|
||||
$source = file_get_contents(PLUGIN_ROOT . '/exec/handlers/' . $handler) ?: '';
|
||||
assert_contains('syncActiveBackend', $source, $handler . ' must synchronize backend after mutation');
|
||||
assert_contains('syncDirectAdminVacations', $source, $handler . ' must synchronize native vacations after mutation');
|
||||
}
|
||||
});
|
||||
|
||||
test('calendar picker is based on selected rule month and supports month navigation', function (): void {
|
||||
$settingsPath = TEST_TMP . '/form-calendar.conf';
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\nGLOBAL_AUTORESPONDER_BACKEND=exim\n");
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
$ctx = new AppContext(
|
||||
new DirectAdminUser('alice', 'enhanced', 'pl', TEST_TMP . '/config'),
|
||||
@@ -131,7 +387,6 @@ test('calendar picker is based on selected rule month and supports month navigat
|
||||
$html = render_rule_form($ctx, 'update', [
|
||||
'id' => 'abc',
|
||||
'subject_prefix' => 'Urlop',
|
||||
'reply_every_message' => false,
|
||||
'repeat_minutes' => 1440,
|
||||
'body' => 'Body',
|
||||
'enabled' => true,
|
||||
@@ -148,7 +403,7 @@ test('calendar picker is based on selected rule month and supports month navigat
|
||||
|
||||
test('calendar picker disables dates before today', function (): void {
|
||||
$settingsPath = TEST_TMP . '/form-calendar-min.conf';
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\nGLOBAL_AUTORESPONDER_BACKEND=exim\n");
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
$ctx = new AppContext(
|
||||
new DirectAdminUser('alice', 'enhanced', 'pl', TEST_TMP . '/config'),
|
||||
@@ -164,9 +419,39 @@ test('calendar picker disables dates before today', function (): void {
|
||||
assert_false(str_contains($html, 'data-date-value="2000-01-15"'), 'Past dates must not be clickable');
|
||||
});
|
||||
|
||||
test('update form calendar allows existing past schedule dates', function (): void {
|
||||
$settingsPath = TEST_TMP . '/form-calendar-update-past.conf';
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\nGLOBAL_AUTORESPONDER_TIMEZONE=Europe/Warsaw\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
$ctx = new AppContext(
|
||||
new DirectAdminUser('alice', 'enhanced', 'pl', TEST_TMP . '/config'),
|
||||
$settings,
|
||||
new RuleRepository(TEST_TMP . '/data'),
|
||||
new CsrfGuard('secret', 'alice', 'sid'),
|
||||
Lang::load('pl', $settings),
|
||||
new AuditLog(TEST_TMP . '/audit.log')
|
||||
);
|
||||
|
||||
$html = render_rule_form($ctx, 'update', [
|
||||
'id' => 'abc',
|
||||
'name' => 'Historyczny urlop',
|
||||
'subject_prefix' => 'Urlop',
|
||||
'repeat_minutes' => 1440,
|
||||
'body' => 'Body',
|
||||
'enabled' => true,
|
||||
'start_value' => '2000-01-10T09:00',
|
||||
'end_value' => '2000-01-11T17:00',
|
||||
]);
|
||||
|
||||
assert_contains('data-min-date=""', $html);
|
||||
assert_contains('data-date-value="2000-01-10"', $html);
|
||||
assert_contains('data-date-value="2000-01-11"', $html);
|
||||
assert_false(str_contains($html, 'br-cal-day-disabled'), 'Update form must not disable past dates');
|
||||
});
|
||||
|
||||
test('new rule form selects current date for start and end calendars by default', function (): void {
|
||||
$settingsPath = TEST_TMP . '/form-calendar-defaults.conf';
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\nGLOBAL_AUTORESPONDER_BACKEND=exim\nGLOBAL_AUTORESPONDER_TIMEZONE=Europe/Warsaw\n");
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\nGLOBAL_AUTORESPONDER_TIMEZONE=Europe/Warsaw\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
$ctx = new AppContext(
|
||||
new DirectAdminUser('alice', 'enhanced', 'pl', TEST_TMP . '/config'),
|
||||
@@ -188,7 +473,7 @@ test('new rule form selects current date for start and end calendars by default'
|
||||
|
||||
test('rule form localizes calendar and preview labels without translating user content globally', function (): void {
|
||||
$settingsPath = TEST_TMP . '/form-i18n.conf';
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=en\nGLOBAL_AUTORESPONDER_BACKEND=exim\n");
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=en\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
$ctx = new AppContext(
|
||||
new DirectAdminUser('alice', 'enhanced', 'en', TEST_TMP . '/config'),
|
||||
@@ -210,14 +495,13 @@ test('rule form localizes calendar and preview labels without translating user c
|
||||
assert_contains('Cancel', $preview);
|
||||
});
|
||||
|
||||
test('directadmin backend allows only one enabled global rule per account', function (): void {
|
||||
test('plugin allows only one enabled global rule per account', function (): void {
|
||||
$settingsPath = TEST_TMP . '/form-da-single.conf';
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\nGLOBAL_AUTORESPONDER_BACKEND=da\n");
|
||||
test_write($settingsPath, "DEFAULT_PLUGIN_LANGUAGE=pl\n");
|
||||
$settings = Settings::load($settingsPath);
|
||||
$repo = new RuleRepository(TEST_TMP . '/single-data');
|
||||
$repo->create('alice', [
|
||||
'subject_prefix' => 'Pierwsza',
|
||||
'reply_every_message' => false,
|
||||
'repeat_minutes' => 1440,
|
||||
'body' => 'Body',
|
||||
'enabled' => true,
|
||||
@@ -235,10 +519,10 @@ test('directadmin backend allows only one enabled global rule per account', func
|
||||
|
||||
$thrown = false;
|
||||
try {
|
||||
enforce_rule_backend_constraints($ctx, null, ['enabled' => true]);
|
||||
enforce_rule_directadmin_constraints($ctx, null, ['enabled' => true]);
|
||||
} catch (RuntimeException $e) {
|
||||
$thrown = true;
|
||||
assert_contains('Backend DirectAdmin obsługuje tylko jedną aktywną regułę globalną.', $e->getMessage());
|
||||
assert_contains('W ramach użytkownika może być aktywny tylko jeden globalny autoresponder.', $e->getMessage());
|
||||
}
|
||||
assert_true($thrown);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user