Merge "Update docs/hooks.txt for ShowSearchHitTitle"
[mediawiki.git] / tests / phpunit / includes / config / HashConfigTest.php
blob19b412d2c6c29c85513dab52307a1ee33951d1d5
1 <?php
3 class HashConfigTest extends MediaWikiTestCase {
5 /**
6 * @covers HashConfig::newInstance
7 */
8 public function testNewInstance() {
9 $conf = HashConfig::newInstance();
10 $this->assertInstanceOf( 'HashConfig', $conf );
13 /**
14 * @covers HashConfig::__construct
16 public function testConstructor() {
17 $conf = new HashConfig();
18 $this->assertInstanceOf( 'HashConfig', $conf );
20 // Test passing arguments to the constructor
21 $conf2 = new HashConfig( [
22 'one' => '1',
23 ] );
24 $this->assertEquals( '1', $conf2->get( 'one' ) );
27 /**
28 * @covers HashConfig::get
30 public function testGet() {
31 $conf = new HashConfig( [
32 'one' => '1',
33 ] );
34 $this->assertEquals( '1', $conf->get( 'one' ) );
35 $this->setExpectedException( 'ConfigException', 'HashConfig::get: undefined option' );
36 $conf->get( 'two' );
39 /**
40 * @covers HashConfig::has
42 public function testHas() {
43 $conf = new HashConfig( [
44 'one' => '1',
45 ] );
46 $this->assertTrue( $conf->has( 'one' ) );
47 $this->assertFalse( $conf->has( 'two' ) );
50 /**
51 * @covers HashConfig::set
53 public function testSet() {
54 $conf = new HashConfig( [
55 'one' => '1',
56 ] );
57 $conf->set( 'two', '2' );
58 $this->assertEquals( '2', $conf->get( 'two' ) );
59 // Check that set overwrites
60 $conf->set( 'one', '3' );
61 $this->assertEquals( '3', $conf->get( 'one' ) );