Files
roundcubemail/plugins/archive/tests/Archive.php
Michael Voříšek d18406a8bd Fix binary operator spaces CS (#9330)
* align_single_space_minimal for assign

* assign operators grouping is not supported by PHP CS Fixer

* binary_operator_spaces = single_space

* fix anonymous function on single line

* align comments manually
2024-02-02 07:53:34 +01:00

88 lines
2.3 KiB
PHP

<?php
use PHPUnit\Framework\TestCase;
class Archive_Plugin extends TestCase
{
public static function setUpBeforeClass(): void
{
include_once __DIR__ . '/../archive.php';
}
/**
* Plugin object construction test
*/
public function test_constructor()
{
$rcube = rcube::get_instance();
$plugin = new archive($rcube->plugins);
$this->assertInstanceOf('archive', $plugin);
$this->assertInstanceOf('rcube_plugin', $plugin);
$plugin->init();
}
/**
* Test prefs_table() method
*/
public function test_prefs_table()
{
$rcube = rcube::get_instance();
$plugin = new archive($rcube->plugins);
$args = ['section' => 'server', 'blocks' => ['main' => ['options' => []]]];
$result = $plugin->prefs_table($args);
$this->assertSame(
'<label for="ff_read_on_archive">Mark the message as read on archive</label>',
$result['blocks']['main']['options']['read_on_archive']['title']
);
$this->assertSame(
'<input name="_read_on_archive" id="ff_read_on_archive" value="1" type="checkbox">',
$result['blocks']['main']['options']['read_on_archive']['content']
);
// TODO: section=folders
}
/**
* Test prefs_save() method
*/
public function test_prefs_save()
{
$rcube = rcube::get_instance();
$plugin = new archive($rcube->plugins);
$_POST = [];
$args = ['section' => 'folders', 'prefs' => []];
$result = $plugin->prefs_save($args);
$this->assertSame('', $result['prefs']['archive_type']);
$_POST = ['_archive_type' => 'aaa'];
$args = ['section' => 'folders', 'prefs' => []];
$result = $plugin->prefs_save($args);
$this->assertSame('aaa', $result['prefs']['archive_type']);
$_POST = [];
$args = ['section' => 'server', 'prefs' => []];
$result = $plugin->prefs_save($args);
$this->assertFalse($result['prefs']['read_on_archive']);
$_POST = ['_read_on_archive' => 1];
$args = ['section' => 'server', 'prefs' => []];
$result = $plugin->prefs_save($args);
$this->assertTrue($result['prefs']['read_on_archive']);
}
}