Files
global-autoresponder/tests/rule_repository_test.php
T
2026-06-02 19:19:00 +02:00

29 lines
833 B
PHP

<?php
declare(strict_types=1);
require_once PLUGIN_ROOT . '/exec/lib/RuleRepository.php';
test('rule repository isolates users and stores rules atomically', function (): void {
$repo = new RuleRepository(TEST_TMP . '/data');
$rule = [
'subject' => 'Urlop',
'body' => 'Body',
'start_ts' => 1,
'end_ts' => 2,
'enabled' => true,
];
$created = $repo->create('alice', $rule);
assert_true(isset($created['id']));
assert_same(1, count($repo->all('alice')));
assert_same(0, count($repo->all('bob')));
try {
$repo->update('bob', $created['id'], ['subject' => 'Other']);
} catch (RuntimeException $e) {
assert_contains('not found', $e->getMessage());
return;
}
throw new RuntimeException('Expected cross-user update to fail');
});