@@ 14-33 (lines=20) @@ | ||
11 | ||
12 | class MailboxCheckValidationTest extends TestCase |
|
13 | { |
|
14 | public function testValidMailbox() |
|
15 | { |
|
16 | $socketHelperMock = $this->createMock(SmtpSocketHelper::class); |
|
17 | ||
18 | $socketHelperMock |
|
19 | ->expects($this->any()) |
|
20 | ->method('isResource') |
|
21 | ->willReturn(true) |
|
22 | ; |
|
23 | ||
24 | $socketHelperMock |
|
25 | ->expects($this->any()) |
|
26 | ->method('getResponseCode') |
|
27 | ->willReturnOnConsecutiveCalls(220, 250, 250, 250) |
|
28 | ; |
|
29 | ||
30 | $validation = new MailboxCheckValidation($socketHelperMock, '[email protected]'); |
|
31 | ||
32 | $this->assertTrue($validation->isValid('[email protected]', new EmailLexer())); |
|
33 | } |
|
34 | ||
35 | public function testDNSWarnings() |
|
36 | { |
|
@@ 43-62 (lines=20) @@ | ||
40 | $this->assertEquals($expectedWarnings, $validation->getWarnings()); |
|
41 | } |
|
42 | ||
43 | public function testIllegalMailboxError() |
|
44 | { |
|
45 | $socketHelperMock = $this->createMock(SmtpSocketHelper::class); |
|
46 | ||
47 | $socketHelperMock |
|
48 | ->expects($this->any()) |
|
49 | ->method('isResource') |
|
50 | ->willReturn(true) |
|
51 | ; |
|
52 | ||
53 | $socketHelperMock |
|
54 | ->expects($this->any()) |
|
55 | ->method('getResponseCode') |
|
56 | ->willReturnOnConsecutiveCalls(220, 250, 250, 550) |
|
57 | ; |
|
58 | ||
59 | $validation = new MailboxCheckValidation($socketHelperMock, '[email protected]'); |
|
60 | $validation->isValid('[email protected]', new EmailLexer()); |
|
61 | $this->assertEquals(new IllegalMailbox(550), $validation->getError()); |
|
62 | } |
|
63 | } |
|
64 |