mirror of
https://github.com/roundcube/roundcubemail.git
synced 2026-03-25 01:06:56 +01:00
* 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
66 lines
1.7 KiB
PHP
66 lines
1.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Test class to test rcmail_action_contacts_index
|
|
*
|
|
* @package Tests
|
|
*/
|
|
class Actions_Contacts_Index extends ActionTestCase
|
|
{
|
|
/**
|
|
* Class constructor
|
|
*/
|
|
function test_class()
|
|
{
|
|
$object = new rcmail_action_contacts_index;
|
|
|
|
$this->assertInstanceOf('rcmail_action', $object);
|
|
}
|
|
|
|
/**
|
|
* Test run() method in HTTP mode
|
|
*/
|
|
function test_run_http()
|
|
{
|
|
$action = new rcmail_action_contacts_index;
|
|
$output = $this->initOutput(rcmail_action::MODE_HTTP, 'contacts', '');
|
|
|
|
$this->assertTrue($action->checks());
|
|
|
|
// self::initDB('contacts');
|
|
|
|
$action->run();
|
|
|
|
$this->assertSame([], $output->headers);
|
|
$this->assertNull($output->getOutput());
|
|
|
|
$sources = $output->get_env('address_sources');
|
|
|
|
$this->assertCount(3, $sources);
|
|
$this->assertSame('Personal Addresses', $sources[0]['name']);
|
|
$this->assertSame('Collected Recipients', $sources[1]['name']);
|
|
$this->assertSame('Trusted Senders', $sources[2]['name']);
|
|
$this->assertSame('Contacts', $output->getProperty('pagetitle'));
|
|
}
|
|
|
|
/**
|
|
* Test run() method in AJAX mode
|
|
*/
|
|
function test_run_ajax()
|
|
{
|
|
$action = new rcmail_action_contacts_index;
|
|
$output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'list');
|
|
|
|
$this->assertTrue($action->checks());
|
|
|
|
// self::initDB('contacts');
|
|
|
|
$action->run();
|
|
|
|
$this->assertSame([], $output->headers);
|
|
$this->assertNull($output->getOutput());
|
|
$this->assertNull($output->get_env('address_sources'));
|
|
$this->assertSame('', $output->getProperty('pagetitle'));
|
|
}
|
|
}
|