Let polls remind target one poll for testing
CI / Deploy / PHP 8.5 (push) Successful in 1m6s
CI / Deploy / PHP 8.4 (push) Successful in 1m12s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped

`polls remind <id|code>` sends the reminder to that poll right away,
ignoring the reminder window, an earlier reminder and POLL_REMINDER_DAYS.
A forced reminder does not set the reminded marker.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-16 14:10:08 +01:00
1 parent 4f03414d7a
commit f21aead039
4 files changed
+80 -10

No files matched your search

@@ -7,6 +7,7 @@ use App\Test\TestCase\PlenarioTestTrait;
use Cake\Console\TestSuite\ConsoleIntegrationTestTrait;
use Cake\Core\Configure;
use Cake\I18n\DateTime;
use Cake\TestSuite\EmailTrait;
use Cake\TestSuite\TestCase;
/**
@@ -15,6 +16,7 @@ use Cake\TestSuite\TestCase;
class PollsCommandsTest extends TestCase
{
use ConsoleIntegrationTestTrait;
use EmailTrait;
use PlenarioTestTrait;
protected function setUp(): void
@@ -193,6 +195,46 @@ class PollsCommandsTest extends TestCase
$this->assertNotEmpty($youngToken . $dueToken);
}
public function testRemindCanBeForcedForOnePoll(): void
{
[$young] = $this->createPoll('Frisch', 'frisch@example.org');
[$other] = $this->createPoll('Anderer', 'anderer@example.org');
// Not in the reminder window at all, yet it is sent on request, to this poll only.
$this->exec('polls remind ' . $young->join_code);
$this->assertExitSuccess();
$this->assertOutputContains('erzwungen');
$this->assertMailCount(1);
$this->assertMailSentTo('frisch@example.org');
$this->assertNull($this->pollsTable()->get($young->id)->expiry_reminded_at, 'a forced reminder does not mark the poll');
// Sendable again (also after a regular reminder), still not marked.
$this->pollsTable()->updateAll(['expiry_reminded_at' => DateTime::now()], ['id' => $young->id]);
$this->exec('polls remind ' . $young->id);
$this->assertExitSuccess();
$this->assertMailCount(2);
// Dry run sends nothing.
$this->exec('polls remind ' . $other->id . ' --dry-run');
$this->assertOutputContains('Würde erinnern');
$this->assertMailCount(2);
// Works with reminders switched off, fails without an expiry date and for unknown polls.
Configure::write('Plenario.retention.reminderDays', 0);
$this->exec('polls remind ' . $other->id);
$this->assertExitSuccess();
$this->assertMailCount(3);
$this->exec('polls remind 99999');
$this->assertExitError();
$this->assertErrorContains('nicht gefunden');
Configure::write('Plenario.retention.days', 0);
$this->exec('polls remind ' . $other->id);
$this->assertExitError();
$this->assertMailCount(3);
}
public function testCleanupRemindsThenDeletesOnlyExpiredPollsAndIsIdempotent(): void
{
[$old] = $this->createPoll('Alt');