From: Antoine Musso Date: Mon, 24 Oct 2011 09:32:33 +0000 (+0000) Subject: test {{SERVERNAME}} with relative URLS X-Git-Tag: 1.31.0-rc.0~26936 X-Git-Url: https://git.cyclocoop.org//%22?a=commitdiff_plain;h=ae87825ed967a5cb4fff653196572141f831d221;p=lhc%2Fweb%2Fwiklou.git test {{SERVERNAME}} with relative URLS 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'. --- diff --git a/tests/phpunit/includes/parser/MagicVariableTest.php b/tests/phpunit/includes/parser/MagicVariableTest.php index a8c0574c7f..31645313b9 100644 --- a/tests/phpunit/includes/parser/MagicVariableTest.php +++ b/tests/phpunit/includes/parser/MagicVariableTest.php @@ -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 */