Restructure Media related tests to avoid duplicated code
[lhc/web/wiklou.git] / tests / phpunit / includes / config / GlobalConfigTest.php
1 <?php
2
3 class GlobalConfigTest extends MediaWikiTestCase {
4
5 /** @var GlobalConfig $config */
6 protected $config;
7
8 protected function setUp() {
9 parent::setUp();
10 $this->config = new GlobalConfig;
11 }
12
13 public static function provideGet() {
14 return array(
15 array( 'wgSitename', array( 'Sitename' ) ),
16 array( 'wgFoo', array( 'Foo' ) ),
17 array( 'efVariable', array( 'Variable', 'ef' ) ),
18 array( 'Foo', array( 'Foo', '' ) ),
19 );
20 }
21
22 /**
23 * @param string $name
24 * @param array $params
25 * @dataProvider provideGet
26 * @covers GlobalConfig::get
27 */
28 public function testGet( $name, $params ) {
29 $rand = wfRandom();
30 $old = isset( $GLOBALS[$name] ) ? $GLOBALS[$name] : null;
31 $GLOBALS[$name] = $rand;
32 $out = call_user_func_array( array( $this->config, 'get' ), $params );
33 $this->assertEquals( $rand, $out );
34 if ( $old ) {
35 $GLOBALS[$name] = $old;
36 }
37 }
38 }