|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Overwatch\ServiceBundle\Tests\Expectation; |
|
4
|
|
|
|
|
5
|
|
|
use Overwatch\ServiceBundle\Expectation\ToResolveToExpectation; |
|
6
|
|
|
use phpmock\phpunit\PHPMock; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* ToResolveToExpectationTest |
|
10
|
|
|
*/ |
|
11
|
|
|
class ToResolveToExpectationTest extends \PHPUnit_Framework_TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
use PHPMock; |
|
14
|
|
|
|
|
15
|
|
|
private $expectation; |
|
16
|
|
|
|
|
17
|
|
|
public function setUp() |
|
18
|
|
|
{ |
|
19
|
|
|
$this->createDnsMock(); |
|
20
|
|
|
|
|
21
|
|
|
$this->expectation = new ToResolveToExpectation([ |
|
22
|
|
|
'record_types' => ['A', 'AAAA', 'CNAME'] |
|
23
|
|
|
]); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function testExpectation() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->assertContains( |
|
29
|
|
|
' record that resolves to ', |
|
30
|
|
|
$this->expectation->run('console.aws.amazon.com', 'lbr-optimized.console-l.amazonaws.com') |
|
31
|
|
|
); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @expectedException Overwatch\ExpectationBundle\Exception\ExpectationFailedException |
|
36
|
|
|
* @expectedExceptionMessage actually resolves to |
|
37
|
|
|
*/ |
|
38
|
|
|
public function testExpectationFailed() |
|
39
|
|
|
{ |
|
40
|
|
|
$this->expectation->run('console.aws.amazon.com', 'ns-921.amazon.com'); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
private function createDnsMock() |
|
44
|
|
|
{ |
|
45
|
|
|
$mock = $this->getFunctionMock('Overwatch\ServiceBundle\Expectation', 'dns_get_record'); |
|
46
|
|
|
$mock->expects($this->once())->willReturn([ |
|
47
|
|
|
[ |
|
48
|
|
|
'host' => 'console.aws.amazon.com', |
|
49
|
|
|
'class' => 'IN', |
|
50
|
|
|
'ttl' => 60, |
|
51
|
|
|
'type' => 'SOA', |
|
52
|
|
|
'mname' => 'ns-921.amazon.com', |
|
53
|
|
|
'rname' => 'root.amazon.com', |
|
54
|
|
|
'serial' => 1441402959, |
|
55
|
|
|
'refresh' => 3600, |
|
56
|
|
|
'retry' => 900, |
|
57
|
|
|
'expire' => 7776000, |
|
58
|
|
|
'minimum-ttl'=> 60 |
|
59
|
|
|
|
|
60
|
|
|
], |
|
61
|
|
|
[ |
|
62
|
|
|
'host' => 'console.aws.amazon.com', |
|
63
|
|
|
'class' => 'IN', |
|
64
|
|
|
'ttl' => 108, |
|
65
|
|
|
'type' => 'NS', |
|
66
|
|
|
'target'=> 'ns-921.amazon.com' |
|
67
|
|
|
], |
|
68
|
|
|
[ |
|
69
|
|
|
'host' => 'console.aws.amazon.com', |
|
70
|
|
|
'class' => 'IN', |
|
71
|
|
|
'ttl' => 60, |
|
72
|
|
|
'type' => 'CNAME', |
|
73
|
|
|
'target'=> 'lbr-optimized.console-l.amazonaws.com' |
|
74
|
|
|
] |
|
75
|
|
|
]); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|