summaryrefslogtreecommitdiff
path: root/tests/units/Helper/MailHelperTest.php
blob: e871a57d634a1e6ea0df42af049fe93338ee6d98 (plain)
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
<?php

require_once __DIR__.'/../Base.php';

use Kanboard\Helper\MailHelper;

class MailHelperTest extends Base
{
    public function testMailboxHash()
    {
        $helper = new MailHelper($this->container);
        $this->assertEquals('test1', $helper->getMailboxHash('a+test1@localhost'));
        $this->assertEquals('', $helper->getMailboxHash('test1@localhost'));
        $this->assertEquals('', $helper->getMailboxHash('test1'));
    }

    public function testFilterSubject()
    {
        $helper = new MailHelper($this->container);
        $this->assertEquals('Test', $helper->filterSubject('Test'));
        $this->assertEquals('Test', $helper->filterSubject('RE: Test'));
        $this->assertEquals('Test', $helper->filterSubject('FW: Test'));
    }

    public function testGetSenderAddress()
    {
        $helper = new MailHelper($this->container);
        $this->assertEquals('notifications@kanboard.local', $helper->getMailSenderAddress());

        $this->container['configModel']->save(array('mail_sender_address' => 'me@here'));
        $this->container['memoryCache']->flush();

        $this->assertEquals('me@here', $helper->getMailSenderAddress());
    }

    public function testGetTransport()
    {
        $helper = new MailHelper($this->container);
        $this->assertEquals(MAIL_TRANSPORT, $helper->getMailTransport());

        $this->container['configModel']->save(array('mail_transport' => 'smtp'));
        $this->container['memoryCache']->flush();

        $this->assertEquals('smtp', $helper->getMailTransport());
    }
}