File: AttachmentReminder.php

package info (click to toggle)
roundcube 1.6.11%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 44,868 kB
  • sloc: javascript: 195,588; php: 76,818; sql: 3,150; sh: 2,882; pascal: 1,079; makefile: 234; xml: 93; perl: 73; ansic: 48; python: 21
file content (73 lines) | stat: -rw-r--r-- 2,031 bytes parent folder | download
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']);
    }
}