| 1 |
<?php |
| 2 |
|
| 3 |
use MediaWiki\Config\ConfigException; |
| 4 |
use MediaWiki\Config\HashConfig; |
| 5 |
use MediaWiki\Config\MultiConfig; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
class MultiConfigTest extends \MediaWikiUnitTestCase { |
| 11 |
|
| 12 |
public function testGet() { |
| 13 |
|
| 14 |
$multi = new MultiConfig( [ |
| 15 |
new HashConfig( [ 'foo' => 'bar' ] ), |
| 16 |
new HashConfig( [ 'foo' => 'baz', 'bar' => 'foo' ] ), |
| 17 |
new HashConfig( [ 'bar' => 'baz' ] ), |
| 18 |
] ); |
| 19 |
|
| 20 |
$this->assertEquals( 'bar', $multi->get( 'foo' ) ); |
| 21 |
$this->assertEquals( 'foo', $multi->get( 'bar' ) ); |
| 22 |
$this->expectException( ConfigException::class ); |
| 23 |
$this->expectExceptionMessage( 'MultiConfig::get: undefined option:' ); |
| 24 |
$multi->get( 'notset' ); |
| 25 |
} |
| 26 |
|
| 27 |
public function testHas() { |
| 28 |
$conf = new MultiConfig( [ |
| 29 |
new HashConfig( [ 'foo' => 'foo' ] ), |
| 30 |
new HashConfig( [ 'something' => 'bleh' ] ), |
| 31 |
new HashConfig( [ 'meh' => 'eh' ] ), |
| 32 |
] ); |
| 33 |
|
| 34 |
$this->assertTrue( $conf->has( 'foo' ) ); |
| 35 |
$this->assertTrue( $conf->has( 'something' ) ); |
| 36 |
$this->assertTrue( $conf->has( 'meh' ) ); |
| 37 |
$this->assertFalse( $conf->has( 'what' ) ); |
| 38 |
} |
| 39 |
} |