1 | <?php |
||
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 |