Merge "ClassicInterwikiLookup: Call static function selectFields statically"
[lhc/web/wiklou.git] / tests / phpunit / includes / libs / DnsSrvDiscovererTest.php
1 <?php
2
3 class DnsSrvDiscovererTest extends PHPUnit_Framework_TestCase {
4 /**
5 * @covers DnsSrvDiscoverer
6 * @dataProvider provideRecords
7 */
8 public function testPickServer( $params, $expected ) {
9 $discoverer = new DnsSrvDiscoverer( '_etcd._tcp.eqiad.wmnet' );
10 $record = $discoverer->pickServer( $params );
11
12 $this->assertEquals( $expected, $record );
13
14 }
15
16 public static function provideRecords() {
17 return [
18 [
19 [ // record list
20 [
21 'target' => 'conf1003.eqiad.wmnet',
22 'port' => 'SRV',
23 'pri' => 0,
24 'weight' => 1,
25 ],
26 [
27 'target' => 'conf1002.eqiad.wmnet',
28 'port' => 'SRV',
29 'pri' => 1,
30 'weight' => 1,
31 ],
32 [
33 'target' => 'conf1001.eqiad.wmnet',
34 'port' => 'SRV',
35 'pri' => 2,
36 'weight' => 1,
37 ],
38 ], // selected record
39 [
40 'target' => 'conf1003.eqiad.wmnet',
41 'port' => 'SRV',
42 'pri' => 0,
43 'weight' => 1,
44 ]
45 ],
46 [
47 [ // record list
48 [
49 'target' => 'conf1003or2.eqiad.wmnet',
50 'port' => 'SRV',
51 'pri' => 0,
52 'weight' => 1,
53 ],
54 [
55 'target' => 'conf1003or2.eqiad.wmnet',
56 'port' => 'SRV',
57 'pri' => 0,
58 'weight' => 1,
59 ],
60 [
61 'target' => 'conf1001.eqiad.wmnet',
62 'port' => 'SRV',
63 'pri' => 2,
64 'weight' => 1,
65 ],
66 [
67 'target' => 'conf1004.eqiad.wmnet',
68 'port' => 'SRV',
69 'pri' => 2,
70 'weight' => 1,
71 ],
72 [
73 'target' => 'conf1005.eqiad.wmnet',
74 'port' => 'SRV',
75 'pri' => 3,
76 'weight' => 1,
77 ],
78 ], // selected record
79 [
80 'target' => 'conf1003or2.eqiad.wmnet',
81 'port' => 'SRV',
82 'pri' => 0,
83 'weight' => 1,
84 ]
85 ],
86 ];
87 }
88 }