11 $server, $canServer, $httpsMode, $message
15 'wgServer' => $server,
16 'wgCanonicalServer' => $canServer,
17 'wgRequest' =>
new FauxRequest( [],
false,
null, $httpsMode ?
'https' :
'http' )
20 $this->assertEquals( $fullUrl,
wfExpandUrl( $shortUrl, $defaultProto ), $message );
29 $modes = [
'http',
'https' ];
31 'http' =>
'http://example.com',
32 'https' =>
'https://example.com',
33 'protocol-relative' =>
'//example.com'
44 foreach ( $modes as $mode ) {
45 $httpsMode = $mode ==
'https';
46 foreach ( $servers as $serverDesc => $server ) {
47 foreach ( $modes as $canServerMode ) {
48 $canServer =
"$canServerMode://example2.com";
49 foreach ( $defaultProtos as $protoDesc => $defaultProto ) {
51 'http://example.com',
'http://example.com',
52 $defaultProto, $server, $canServer, $httpsMode,
53 "Testing fully qualified http URLs (no need to expand) "
54 .
"(defaultProto: $protoDesc , wgServer: $server, "
55 .
"wgCanonicalServer: $canServer, current request protocol: $mode )"
58 'https://example.com',
'https://example.com',
59 $defaultProto, $server, $canServer, $httpsMode,
60 "Testing fully qualified https URLs (no need to expand) "
61 .
"(defaultProto: $protoDesc , wgServer: $server, "
62 .
"wgCanonicalServer: $canServer, current request protocol: $mode )"
64 # Would be nice to support this, see fixme on wfExpandUrl()
66 "wiki/FooBar",
'wiki/FooBar',
67 $defaultProto, $server, $canServer, $httpsMode,
68 "Test non-expandable relative URLs (defaultProto: $protoDesc, "
69 .
"wgServer: $server, wgCanonicalServer: $canServer, "
70 .
"current request protocol: $mode )"
74 if ( $protoDesc ==
'protocol-relative' ) {
76 } elseif ( $protoDesc ==
'current' ) {
78 } elseif ( $protoDesc ==
'canonical' ) {
79 $p =
"$canServerMode:";
81 $p = $protoDesc .
':';
84 if ( $protoDesc ==
'canonical' ) {
86 } elseif ( $serverDesc ==
'protocol-relative' ) {
93 "$p//wikipedia.org",
'//wikipedia.org',
94 $defaultProto, $server, $canServer, $httpsMode,
95 "Test protocol-relative URL (defaultProto: $protoDesc, "
96 .
"wgServer: $server, wgCanonicalServer: $canServer, "
97 .
"current request protocol: $mode )"
106 "Testing expanding URL beginning with / (defaultProto: $protoDesc, "
107 .
"wgServer: $server, wgCanonicalServer: $canServer, "
108 .
"current request protocol: $mode )"