11 $server, $canServer, $httpsMode, $httpsPort, $message
16 'wgServer' => $server,
17 'wgCanonicalServer' => $canServer,
18 'wgRequest' =>
new FauxRequest( [],
false,
null, $httpsMode ?
'https' :
'http' ),
19 'wgHttpsPort' => $httpsPort
22 $this->assertEquals( $fullUrl,
wfExpandUrl( $shortUrl, $defaultProto ), $message );
31 $modes = [
'http',
'https' ];
33 'http' =>
'http://example.com',
34 'https' =>
'https://example.com',
35 'protocol-relative' =>
'//example.com'
46 foreach ( $modes as $mode ) {
47 $httpsMode = $mode ==
'https';
48 foreach ( $servers as $serverDesc => $server ) {
49 foreach ( $modes as $canServerMode ) {
50 $canServer =
"$canServerMode://example2.com";
51 foreach ( $defaultProtos as $protoDesc => $defaultProto ) {
53 'http://example.com',
'http://example.com',
54 $defaultProto, $server, $canServer, $httpsMode, 443,
55 "Testing fully qualified http URLs (no need to expand) "
56 .
"(defaultProto: $protoDesc , wgServer: $server, "
57 .
"wgCanonicalServer: $canServer, current request protocol: $mode )"
60 'https://example.com',
'https://example.com',
61 $defaultProto, $server, $canServer, $httpsMode, 443,
62 "Testing fully qualified https URLs (no need to expand) "
63 .
"(defaultProto: $protoDesc , wgServer: $server, "
64 .
"wgCanonicalServer: $canServer, current request protocol: $mode )"
66 # Would be nice to support this, see fixme on wfExpandUrl()
68 "wiki/FooBar",
'wiki/FooBar',
69 $defaultProto, $server, $canServer, $httpsMode, 443,
70 "Test non-expandable relative URLs (defaultProto: $protoDesc, "
71 .
"wgServer: $server, wgCanonicalServer: $canServer, "
72 .
"current request protocol: $mode )"
76 if ( $protoDesc ==
'protocol-relative' ) {
78 } elseif ( $protoDesc ==
'current' ) {
80 } elseif ( $protoDesc ==
'canonical' ) {
81 $p =
"$canServerMode:";
83 $p = $protoDesc .
':';
86 if ( $protoDesc ==
'canonical' ) {
88 } elseif ( $serverDesc ==
'protocol-relative' ) {
95 "$p//wikipedia.org",
'//wikipedia.org',
96 $defaultProto, $server, $canServer, $httpsMode, 443,
97 "Test protocol-relative URL (defaultProto: $protoDesc, "
98 .
"wgServer: $server, wgCanonicalServer: $canServer, "
99 .
"current request protocol: $mode )"
109 "Testing expanding URL beginning with / (defaultProto: $protoDesc, "
110 .
"wgServer: $server, wgCanonicalServer: $canServer, "
111 .
"current request protocol: $mode )"
120 'https://foreign.example.com/foo',
121 'https://foreign.example.com/foo',
123 '//wiki.example.com',
124 'http://wiki.example.com',
127 "Don't add HTTPS port to foreign URLs"
130 'https://foreign.example.com:222/foo',
131 'https://foreign.example.com:222/foo',
133 '//wiki.example.com',
134 'http://wiki.example.com',
137 "Don't overwrite HTTPS port of foreign URLs"
141 'https://wiki.example.com:111/foo',
144 '//wiki.example.com',
145 'http://wiki.example.com',
148 "Do add HTTPS port to protocol-relative URLs"