Add --json to polls list and polls show
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:
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();
|
||||
|
||||
Reference in new issue
Block a user