|
12 | 12 | namespace EmailChecker\Tests; |
13 | 13 |
|
14 | 14 | use EmailChecker\Adapter\AdapterInterface; |
| 15 | +use EmailChecker\Adapter\ArrayAdapter; |
15 | 16 | use EmailChecker\EmailChecker; |
16 | 17 |
|
17 | 18 | final class EmailCheckerTest extends TestCase |
18 | 19 | { |
19 | 20 | public function testEmailIsValid(): void |
20 | 21 | { |
21 | | - $adapter = $this->createMock(AdapterInterface::class); |
22 | | - $adapter |
23 | | - ->method('isThrowawayDomain') |
24 | | - ->willReturn(false); |
25 | | - |
| 22 | + $adapter = new ArrayAdapter([]); |
26 | 23 | $checker = new EmailChecker($adapter); |
27 | 24 |
|
28 | 25 | self::assertTrue($checker->isValid('foo@bar.org')); |
29 | 26 | } |
30 | 27 |
|
31 | 28 | public function testEmailIsNotValid(): void |
32 | 29 | { |
33 | | - $adapter = $this->createMock(AdapterInterface::class); |
34 | | - $adapter |
35 | | - ->method('isThrowawayDomain') |
36 | | - ->willReturn(true); |
37 | | - |
| 30 | + $adapter = new ArrayAdapter(['bar.org']); |
38 | 31 | $checker = new EmailChecker($adapter); |
39 | 32 |
|
40 | 33 | self::assertFalse($checker->isValid('foo@bar.org')); |
41 | 34 | } |
42 | 35 |
|
43 | 36 | public function testMalformattedEmail(): void |
44 | 37 | { |
45 | | - $adapter = $this->createMock(AdapterInterface::class); |
| 38 | + $adapter = new ArrayAdapter([]); |
46 | 39 | $checker = new EmailChecker($adapter); |
47 | 40 |
|
48 | 41 | self::assertFalse($checker->isValid('foo[at]bar.org')); |
49 | 42 | } |
| 43 | + |
| 44 | + public function testSubDomain(): void |
| 45 | + { |
| 46 | + $adapter = new ArrayAdapter(['bar.org']); |
| 47 | + $checker = new EmailChecker($adapter); |
| 48 | + |
| 49 | + self::assertFalse($checker->isValid('foo@baz.bar.org')); |
| 50 | + } |
50 | 51 | } |
0 commit comments