-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMxRecordTest.php
61 lines (47 loc) · 1.48 KB
/
MxRecordTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
declare(strict_types=1);
namespace Tests;
use Mockery;
use PHPUnit\Framework\TestCase;
use SlickSky\SpamBlacklistQuery\Blacklist;
use SlickSky\SpamBlacklistQuery\MxRecord;
use function dns_get_record;
use function reset;
use const DNS_MX;
final class MxRecordTest extends TestCase
{
protected string $testDomain = 'google.com';
protected MxRecord $mx;
public function setUp(): void
{
$records = dns_get_record($this->testDomain, DNS_MX);
$this->mx = new MxRecord(reset($records) ?? []);
}
public function testInitialize(): void
{
$this->assertEquals($this->testDomain, $this->mx->host);
$this->assertEquals('IN', $this->mx->class);
$this->assertIsInt($this->mx->ttl);
$this->assertEquals('MX', $this->mx->type);
$this->assertIsInt($this->mx->pri);
$this->assertEquals('smtp.google.com', $this->mx->target);
}
public function testIsListed(): void
{
$blacklist = Mockery::mock(Blacklist::class);
$blacklist->shouldReceive('isListed')
->once()
->andReturn(true);
$this->mx->query($blacklist);
$this->assertTrue($this->mx->isListed());
}
public function testIsNotListed(): void
{
$blacklist = Mockery::mock(Blacklist::class);
$blacklist->shouldReceive('isListed')
->once()
->andReturn(false);
$this->mx->query($blacklist);
$this->assertFalse($this->mx->isListed());
}
}