Files
roundcubemail/tests/Actions/Contacts/List.php
Aleksander Machniak 545a1569f1 Steps -> Actions refactoring (#7688)
* Move action handling code to rcmail class
* Add rcmail_action class
* Add action aliases
* Get rid of $OUTPUT global
* Move some methods from rcmail to rcmail_action
* PHP8 compat. fixes
* Add framework for testing actions
* Fix obvious code mistakes
2020-11-01 11:25:38 +01:00

52 lines
1.4 KiB
PHP

<?php
/**
* Test class to test rcmail_action_contacts_list
*
* @package Tests
*/
class Actions_Contacts_List extends ActionTestCase
{
/**
* Class constructor
*/
function test_class()
{
$object = new rcmail_action_contacts_list;
$this->assertInstanceOf('rcmail_action', $object);
}
/**
* Test listing contacts
*/
function test_list()
{
$action = new rcmail_action_contacts_list;
$output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'list');
$this->assertTrue($action->checks());
self::initDB('contacts');
$this->runAndAssert($action, OutputJsonMock::E_EXIT);
$result = $output->getOutput();
$this->assertSame(['Content-Type: application/json; charset=UTF-8'], $output->headers);
$this->assertSame('list', $result['action']);
$this->assertSame(1, $result['env']['pagecount']);
$commands = explode("\n", trim($result['exec']));
$this->assertCount(8, $commands);
$this->assertSame('this.set_group_prop([]);', $commands[0]);
$this->assertSame('this.set_rowcount("Contacts 1 to 6 of 6");', $commands[1]);
$this->assertStringMatchesFormat(
'this.add_contact_row("%i",{"name":"George Bush"},"person",'
. '{"name":"George Bush","email":"g.bush@gov.com","ID":"%i"});',
$commands[2]
);
}
}