From 817d4fc55ba1d921d1757a96268b3ac20cc22e6c Mon Sep 17 00:00:00 2001 From: umherirrender Date: Wed, 20 Mar 2013 20:10:18 +0100 Subject: [PATCH] MagicVariableTest.php: Use dataProvider Setting a global 3 times in one test method looks weird Change-Id: I97f6a932ee2d5c9a5e427cf0f40ced730b7e12ec --- .../includes/parser/MagicVariableTest.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/phpunit/includes/parser/MagicVariableTest.php b/tests/phpunit/includes/parser/MagicVariableTest.php index 51643ce4e3..75e1fd1ced 100644 --- a/tests/phpunit/includes/parser/MagicVariableTest.php +++ b/tests/phpunit/includes/parser/MagicVariableTest.php @@ -172,19 +172,20 @@ class MagicVariableTest extends MediaWikiTestCase { * Rough tests for {{SERVERNAME}} magic word * Bug 31176 * @group Database + * @dataProvider dataServernameFromDifferentProtocols */ - function testServernameFromDifferentProtocols() { - global $wgServer; - $saved_wgServer = $wgServer; + function testServernameFromDifferentProtocols( $server ) { + $this->setMwGlobals( 'wgServer', $server ); - $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; + function dataServernameFromDifferentProtocols() { + return array( + array( 'http://localhost/' ), + array( 'https://localhost/' ), + array( '//localhost/' ), # bug 31176 + ); } ############### HELPERS ############################################ -- 2.20.1