test {{SERVERNAME}} with relative URLS
authorAntoine Musso <hashar@users.mediawiki.org>
Mon, 24 Oct 2011 09:32:33 +0000 (09:32 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Mon, 24 Oct 2011 09:32:33 +0000 (09:32 +0000)
bug 31176 mentionned an issue with {{SERVERNAME}} returning the full
URL instead of servername when using relative URLs (//localhost).
The fix was made by r98193.

This patch test three different URL protocols (http, https & relative)
and check we return the expected 'localhost'.

tests/phpunit/includes/parser/MagicVariableTest.php

index a8c0574..3164531 100644 (file)
@@ -117,6 +117,24 @@ class MagicVariableTest extends MediaWikiTestCase {
                $this->assertUnPadded( 'revisionmonth1', $month );
        }
 
+       /**
+        * Rough tests for {{SERVERNAME}} magic word
+        * Bug 31176
+        */
+       function testServernameFromDifferentProtocols() {
+               global $wgServer;
+               $saved_wgServer= $wgServer;
+
+               $wgServer = 'http://localhost/';
+               $this->assertMagic( 'localhost', 'servername' );
+               $wgServer = 'https://localhost/';
+               $this->assertMagic( 'localhost', 'servername' );
+               $wgServer = '//localhost/';  # bug 31176
+               $this->assertMagic( 'localhost', 'servername' );
+
+               $wgServer = $saved_wgServer;
+       }
+
        ############### HELPERS ############################################
 
        /** assertion helper expecting a magic output which is zero padded */