|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* COPS (Calibre OPDS PHP Server) test file |
|
4
|
|
|
* |
|
5
|
|
|
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html) |
|
6
|
|
|
* @author Sébastien Lucas <[email protected]> |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
require_once (dirname(__FILE__) . "/config_test.php"); |
|
10
|
|
|
require_once (dirname(__FILE__) . "/../sendtomail.php"); |
|
11
|
|
|
|
|
12
|
|
|
class MailTest extends PHPUnit_Framework_TestCase |
|
13
|
|
|
{ |
|
14
|
|
|
public function testCheckConfigurationOk () { |
|
15
|
|
|
global $config; |
|
16
|
|
|
|
|
17
|
|
|
$this->assertFalse(checkConfiguration ()); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
public function testCheckConfigurationNull () { |
|
21
|
|
|
global $config; |
|
22
|
|
|
$config['cops_mail_configuration'] = NULL; |
|
23
|
|
|
|
|
24
|
|
|
$this->assertStringStartsWith("NOK", checkConfiguration ()); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function testCheckConfigurationNotArray () { |
|
28
|
|
|
global $config; |
|
29
|
|
|
$config['cops_mail_configuration'] = "Test"; |
|
30
|
|
|
|
|
31
|
|
|
$this->assertStringStartsWith("NOK", checkConfiguration ()); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function testCheckConfigurationSmtpEmpty () { |
|
35
|
|
|
global $config; |
|
36
|
|
|
$config['cops_mail_configuration']["smtp.host"] = ""; |
|
37
|
|
|
|
|
38
|
|
|
$this->assertStringStartsWith("NOK", checkConfiguration ()); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function testCheckConfigurationEmailEmpty () { |
|
42
|
|
|
global $config; |
|
43
|
|
|
$config['cops_mail_configuration']["address.from"] = ""; |
|
44
|
|
|
|
|
45
|
|
|
$this->assertStringStartsWith("NOK", checkConfiguration ()); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function testCheckConfigurationEmailNotValid () { |
|
49
|
|
|
global $config; |
|
50
|
|
|
$config['cops_mail_configuration']["address.from"] = "a"; |
|
51
|
|
|
|
|
52
|
|
|
$this->markTestIncomplete(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function testCheckRequest () { |
|
56
|
|
|
$this->assertFalse (checkRequest (12, "[email protected]")); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function testCheckRequestNoData () { |
|
60
|
|
|
$this->assertStringStartsWith ("No", checkRequest (NULL, "[email protected]")); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function testCheckRequestNoEmail () { |
|
64
|
|
|
$this->assertStringStartsWith ("No", checkRequest (12, NULL)); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
} |