Fixes for r90105, r90193:
[lhc/web/wiklou.git] / tests / phpunit / includes / WebRequestTest.php
1 <?php
2
3 class WebRequestTest extends MediaWikiTestCase {
4 /**
5 * @dataProvider provideDetectServer
6 */
7 function testDetectServer( $expected, $input, $description ) {
8 $oldServer = $_SERVER;
9 $_SERVER = $input;
10 $result = WebRequest::detectServer();
11 $_SERVER = $oldServer;
12 $this->assertEquals( $expected, $result, $description );
13 }
14
15 function provideDetectServer() {
16 return array(
17 array(
18 'http://x',
19 array(
20 'HTTP_HOST' => 'x'
21 ),
22 'Host header'
23 ),
24 array(
25 'https://x',
26 array(
27 'HTTP_HOST' => 'x',
28 'HTTPS' => 'on',
29 ),
30 'Host header with secure'
31 ),
32 array(
33 'http://x',
34 array(
35 'HTTP_HOST' => 'x',
36 'SERVER_PORT' => 80,
37 ),
38 'Default SERVER_PORT',
39 ),
40 array(
41 'http://x',
42 array(
43 'HTTP_HOST' => 'x',
44 'HTTPS' => 'off',
45 ),
46 'Secure off'
47 ),
48 array(
49 'http://y',
50 array(
51 'SERVER_NAME' => 'y',
52 ),
53 'Server name'
54 ),
55 array(
56 'http://x',
57 array(
58 'HTTP_HOST' => 'x',
59 'SERVER_NAME' => 'y',
60 ),
61 'Host server name precedence'
62 ),
63 array(
64 'http://[::1]:81',
65 array(
66 'HTTP_HOST' => '[::1]',
67 'SERVER_NAME' => '::1',
68 'SERVER_PORT' => '81',
69 ),
70 'Apache bug 26005'
71 ),
72 array(
73 'http://localhost',
74 array(
75 'SERVER_NAME' => '[2001'
76 ),
77 'Kind of like lighttpd per commit message in MW r83847',
78 ),
79 array(
80 'http://[2a01:e35:2eb4:1::2]:777',
81 array(
82 'SERVER_NAME' => '[2a01:e35:2eb4:1::2]:777'
83 ),
84 'Possible lighttpd environment per bug 14977 comment 13',
85 ),
86 );
87 }
88 }