summaryrefslogtreecommitdiffstats
path: root/test/mailTest.php
blob: 9b395cc5a5167711519b8f8d1b2a5b2355c68b0a (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/**
 * COPS (Calibre OPDS PHP Server) test file
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Sébastien Lucas <sebastien@slucas.fr>
 */

require_once (dirname(__FILE__) . "/config_test.php");
require_once (dirname(__FILE__) . "/../sendtomail.php");

class MailTest extends PHPUnit_Framework_TestCase
{
    public function testCheckConfigurationOk () {
        global $config;

        $this->assertFalse(checkConfiguration ());
    }

    public function testCheckConfigurationNull () {
        global $config;
        $config['cops_mail_configuration'] = NULL;

        $this->assertStringStartsWith("NOK", checkConfiguration ());
    }

    public function testCheckConfigurationNotArray () {
        global $config;
        $config['cops_mail_configuration'] = "Test";

        $this->assertStringStartsWith("NOK", checkConfiguration ());
    }

    public function testCheckConfigurationSmtpEmpty () {
        global $config;
        $config['cops_mail_configuration']["smtp.host"] = "";

        $this->assertStringStartsWith("NOK", checkConfiguration ());
    }

    public function testCheckConfigurationEmailEmpty () {
        global $config;
        $config['cops_mail_configuration']["address.from"] = "";

        $this->assertStringStartsWith("NOK", checkConfiguration ());
    }

    public function testCheckConfigurationEmailNotValid () {
        global $config;
        $config['cops_mail_configuration']["address.from"] = "a";

        $this->markTestIncomplete();
    }

    public function testCheckRequest () {
        $this->assertFalse (checkRequest (12, "a@a.com"));
    }

    public function testCheckRequestNoData () {
        $this->assertStringStartsWith ("No", checkRequest (NULL, "a@a.com"));
    }

    public function testCheckRequestNoEmail () {
        $this->assertStringStartsWith ("No", checkRequest (12, NULL));
    }

}