Browse and delete polls from a numbered list in the polls menu
CI / Deploy / PHP 8.5 (push) Successful in 1m7s
CI / Deploy / PHP 8.4 (push) Successful in 1m12s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped

Paged list with pick by number (open) and "d 1,3" to delete several at
once after one confirmation. List query and table moved into the shared
base command.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-16 13:35:38 +01:00
1 parent 6e8fef022b
commit 7b83cf2f2c
6 files changed
+202 -39

No files matched your search

+38 -2
View File
@@ -127,9 +127,10 @@ class PollsCommandsTest extends TestCase
public function testMenuListsAndOpensPollWithLink(): void
{
[$poll, $token] = $this->createPoll('Menü-Umfrage', 'menu@example.org');
[, $token] = $this->createPoll('Menü-Umfrage', 'menu@example.org');
$this->exec('polls', ['1', '4', (string)$poll->id, '2', '0', '0']);
// Menu 1 (list), open row 1, show the link, back, leave the list, quit.
$this->exec('polls', ['1', '1', '2', '0', '', '0']);
$this->assertExitSuccess();
$this->assertOutputContains('menu@example.org');
$this->assertOutputContains('https://plenario.test/admin/' . $token);
@@ -150,6 +151,41 @@ class PollsCommandsTest extends TestCase
$this->assertSame(0, $this->pollsTable()->find()->where(['id' => $poll->id])->count());
}
public function testMenuListDeletesByNumber(): void
{
[$a] = $this->createPoll('Eins', 'eins@example.org');
[$b] = $this->createPoll('Zwei', 'zwei@example.org');
[$c] = $this->createPoll('Drei', 'drei@example.org');
// Unknown number and cancelled confirmation delete nothing.
$this->exec('polls', ['1', 'd 9', 'd 1', 'n', '', '0']);
$this->assertErrorContains('Nummer 9 gibt es nicht');
$this->assertSame(3, $this->pollsTable()->find()->count());
// Several at once with one confirmation.
$this->exec('polls', ['1', 'd 1,3', 'y', '', '0']);
$this->assertExitSuccess();
$this->assertEquals([$b->id], $this->pollsTable()->find()->all()->extract('id')->toList());
// Last one gone: the empty list returns to the menu by itself.
$this->exec('polls', ['1', 'd1', 'y', '0']);
$this->assertSame(0, $this->pollsTable()->find()->count());
$this->assertNotEmpty($a->id . $c->id);
}
public function testMenuListPagesThroughManyPolls(): void
{
for ($i = 1; $i <= 16; $i++) {
$this->createPoll('Umfrage ' . $i, 'p' . $i . '@example.org');
}
$this->exec('polls', ['1', 'n', 'p', '', '0']);
$this->assertExitSuccess();
$this->assertOutputContains('Seite 1 von 2');
$this->assertOutputContains('Seite 2 von 2');
$this->assertOutputContains('p16@example.org');
}
public function testMenuCleanupAsksBeforeDeleting(): void
{
[$old] = $this->createPoll();