1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
<?php
namespace Roundcube\Plugins\Tests;
use PHPUnit\Framework\TestCase;
class Tests_AttachmentReminder extends TestCase
{
static function setUpBeforeClass(): void
{
include_once INSTALL_PATH . 'plugins/attachment_reminder/attachment_reminder.php';
}
/**
* Plugin object construction test
*/
function test_constructor()
{
$rcube = \rcube::get_instance();
$plugin = new \attachment_reminder($rcube->plugins);
$this->assertInstanceOf(\attachment_reminder::class, $plugin);
$this->assertInstanceOf(\rcube_plugin::class, $plugin);
$plugin->init();
}
/**
* Test prefs_list() method
*/
function test_prefs_list()
{
$rcube = \rcube::get_instance();
$plugin = new \attachment_reminder($rcube->plugins);
$args = ['section' => 'compose', 'blocks' => ['main' => ['options' => []]]];
$result = $plugin->prefs_list($args);
$this->assertSame(
'<label for="rcmfd_attachment_reminder">Remind about forgotten attachments</label>',
$result['blocks']['main']['options']['attachment_reminder']['title']
);
$this->assertSame(
'<input name="_attachment_reminder" id="rcmfd_attachment_reminder" value="1" type="checkbox">',
$result['blocks']['main']['options']['attachment_reminder']['content']
);
}
/**
* Test prefs_save() method
*/
function test_prefs_save()
{
$rcube = \rcube::get_instance();
$plugin = new \attachment_reminder($rcube->plugins);
$_POST = [];
$args = ['section' => 'compose', 'prefs' => []];
$result = $plugin->prefs_save($args);
$this->assertFalse($result['prefs']['attachment_reminder']);
$_POST = ['_attachment_reminder' => 1];
$args = ['section' => 'compose', 'prefs' => []];
$result = $plugin->prefs_save($args);
$this->assertTrue($result['prefs']['attachment_reminder']);
}
}
|