Add a menu-driven entry to the polls CLI
`bin/cake polls` without a sub command offers list, search, open a poll (details, admin link, delete), remind and cleanup. It only wraps the existing commands, previews before destructive actions and asks first; every prompt has a safe default so closed stdin ends it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f0b5f7b2bb
commit
6e8fef022b
6 files changed
+222
-3
No files matched your search
@@ -118,6 +118,53 @@ class PollsCommandsTest extends TestCase
|
||||
$this->assertExitError();
|
||||
}
|
||||
|
||||
public function testMenuQuits(): void
|
||||
{
|
||||
$this->exec('polls', ['0']);
|
||||
$this->assertExitSuccess();
|
||||
$this->assertOutputContains('Umfragen verwalten');
|
||||
}
|
||||
|
||||
public function testMenuListsAndOpensPollWithLink(): void
|
||||
{
|
||||
[$poll, $token] = $this->createPoll('Menü-Umfrage', 'menu@example.org');
|
||||
|
||||
$this->exec('polls', ['1', '4', (string)$poll->id, '2', '0', '0']);
|
||||
$this->assertExitSuccess();
|
||||
$this->assertOutputContains('menu@example.org');
|
||||
$this->assertOutputContains('https://plenario.test/admin/' . $token);
|
||||
|
||||
$this->exec('polls', ['4', 'ZZZZZZ', '0']);
|
||||
$this->assertExitSuccess();
|
||||
$this->assertErrorContains('nicht gefunden');
|
||||
}
|
||||
|
||||
public function testMenuDeleteNeedsConfirmation(): void
|
||||
{
|
||||
[$poll] = $this->createPoll();
|
||||
|
||||
$this->exec('polls', ['4', (string)$poll->id, '3', 'n', '0', '0']);
|
||||
$this->assertSame(1, $this->pollsTable()->find()->where(['id' => $poll->id])->count());
|
||||
|
||||
$this->exec('polls', ['4', (string)$poll->id, '3', 'y', '0']);
|
||||
$this->assertSame(0, $this->pollsTable()->find()->where(['id' => $poll->id])->count());
|
||||
}
|
||||
|
||||
public function testMenuCleanupAsksBeforeDeleting(): void
|
||||
{
|
||||
[$old] = $this->createPoll();
|
||||
$this->age($old->id, 100);
|
||||
|
||||
$this->exec('polls', ['6', 'n', '0']);
|
||||
$this->assertSame(1, $this->pollsTable()->find()->count());
|
||||
|
||||
$this->exec('polls', ['6', 'y', '0']);
|
||||
$this->assertSame(0, $this->pollsTable()->find()->count());
|
||||
|
||||
$this->exec('polls', ['6', '0']);
|
||||
$this->assertOutputContains('Nichts zu tun.');
|
||||
}
|
||||
|
||||
public function testReminderGoesOutOnceInTheLastDaysBeforeExpiry(): void
|
||||
{
|
||||
[$young, $youngToken] = $this->createPoll('Jung', 'jung@example.org');
|
||||
|
||||
Reference in new issue
Block a user