|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @author Thomas Müller <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* Mail |
|
7
|
|
|
* |
|
8
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
9
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
10
|
|
|
* as published by the Free Software Foundation. |
|
11
|
|
|
* |
|
12
|
|
|
* This program is distributed in the hope that it will be useful, |
|
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
* GNU Affero General Public License for more details. |
|
16
|
|
|
* |
|
17
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
19
|
|
|
* |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
namespace OCA\Mail\Db; |
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
class TestMailAccount extends \PHPUnit_Framework_TestCase { |
|
26
|
|
|
|
|
27
|
|
|
public function testToAPI() { |
|
28
|
|
|
$a = new MailAccount(); |
|
29
|
|
|
$a->setId(3); |
|
30
|
|
|
$a->setName('Peter Parker'); |
|
31
|
|
|
$a->setInboundHost('mail.marvel.com'); |
|
32
|
|
|
$a->setInboundPort(159); |
|
33
|
|
|
$a->setInboundUser('spiderman'); |
|
34
|
|
|
$a->setInboundPassword('xxxxxxxx'); |
|
35
|
|
|
$a->setInboundSslMode('tls'); |
|
36
|
|
|
$a->setEmail('[email protected]'); |
|
37
|
|
|
$a->setId(12345); |
|
38
|
|
|
$a->setOutboundHost('smtp.marvel.com'); |
|
39
|
|
|
$a->setOutboundPort(458); |
|
40
|
|
|
$a->setOutboundUser('spiderman'); |
|
41
|
|
|
$a->setOutboundPassword('xxxx'); |
|
42
|
|
|
$a->setOutboundSslMode('ssl'); |
|
43
|
|
|
|
|
44
|
|
|
$this->assertEquals(array( |
|
45
|
|
|
'accountId' => 12345, |
|
46
|
|
|
'name' => 'Peter Parker', |
|
47
|
|
|
'emailAddress' => '[email protected]', |
|
48
|
|
|
'imapHost' => 'mail.marvel.com', |
|
49
|
|
|
'imapPort' => 159, |
|
50
|
|
|
'imapUser' => 'spiderman', |
|
51
|
|
|
'imapSslMode' => 'tls', |
|
52
|
|
|
'smtpHost' => 'smtp.marvel.com', |
|
53
|
|
|
'smtpPort' => 458, |
|
54
|
|
|
'smtpUser' => 'spiderman', |
|
55
|
|
|
'smtpSslMode' => 'ssl' |
|
56
|
|
|
), $a->toJson()); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function testMailAccountConstruct() { |
|
60
|
|
|
$expected = [ |
|
61
|
|
|
'accountId' => 12345, |
|
62
|
|
|
'accountName' => 'Peter Parker', |
|
63
|
|
|
'emailAddress' => '[email protected]', |
|
64
|
|
|
'imapHost' => 'mail.marvel.com', |
|
65
|
|
|
'imapPort' => 159, |
|
66
|
|
|
'imapUser' => 'spiderman', |
|
67
|
|
|
'imapSslMode' => 'tls', |
|
68
|
|
|
'smtpHost' => 'smtp.marvel.com', |
|
69
|
|
|
'smtpPort' => 458, |
|
70
|
|
|
'smtpUser' => 'spiderman', |
|
71
|
|
|
'smtpSslMode' => 'ssl' |
|
72
|
|
|
]; |
|
73
|
|
|
$a = new MailAccount($expected); |
|
74
|
|
|
// TODO: fix inconsistency |
|
75
|
|
|
$expected['name'] = $expected['accountName']; |
|
76
|
|
|
unset($expected['accountName']); |
|
77
|
|
|
$this->assertEquals($expected, $a->toJson()); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|