Add --json to polls list and polls show
CI / Deploy / PHP 8.5 (push) Successful in 1m37s
CI / Deploy / PHP 8.4 (push) Successful in 1m39s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / deploy (push) Skipped

Machine-readable output for scripts; never contains the admin token
unless --link is given.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-16 13:59:38 +01:00
1 parent 664088e139
commit 3d6ade668f
6 files changed
+115 -2

No files matched your search

@@ -103,6 +103,46 @@ class PollsCommandsTest extends TestCase
$this->assertExitError();
}
public function testListAndShowAsJson(): void
{
[$old, $token] = $this->createPoll('Alt <b>&</b>', 'alt@example.org');
$this->createPoll('Neu', 'neu@example.org');
$this->age($old->id, 120);
$this->exec('polls list --json');
$this->assertExitSuccess();
$rows = json_decode(implode("
", $this->_out->messages()), true, flags: JSON_THROW_ON_ERROR);
$this->assertCount(2, $rows);
$this->assertSame('Alt <b>&</b>', $rows[0]['title']);
$this->assertSame('alt@example.org', $rows[0]['email']);
$this->assertTrue($rows[0]['expired']);
$this->assertFalse($rows[1]['expired']);
$this->assertNull($rows[1]['reminderSentAt']);
$this->assertArrayNotHasKey('adminUrl', $rows[0]);
$this->assertStringNotContainsString($token, implode('', $this->_out->messages()));
$this->exec('polls list --json --expired');
$this->assertCount(1, json_decode(implode("
", $this->_out->messages()), true));
$this->exec('polls list --json --email=gibtsnicht');
$this->assertSame([], json_decode(implode("
", $this->_out->messages()), true));
$this->exec('polls show ' . $old->id . ' --json');
$data = json_decode(implode("
", $this->_out->messages()), true, flags: JSON_THROW_ON_ERROR);
$this->assertSame($old->id, $data['id']);
$this->assertNull($data['adminUrl']);
$this->assertStringNotContainsString($token, implode('', $this->_out->messages()));
$this->exec('polls show ' . $old->id . ' --json --link');
$data = json_decode(implode("
", $this->_out->messages()), true, flags: JSON_THROW_ON_ERROR);
$this->assertSame('https://plenario.test/admin/' . $token, $data['adminUrl']);
}
public function testDeleteRemovesPollWithSlides(): void
{
[$poll] = $this->createPoll();