MediaWiki  REL1_24
HashConfigTest.php
Go to the documentation of this file.
00001 <?php
00002 
00003 class HashConfigTest extends MediaWikiTestCase {
00004 
00008     public function testNewInstance() {
00009         $conf = HashConfig::newInstance();
00010         $this->assertInstanceOf( 'HashConfig', $conf );
00011     }
00012 
00016     public function testConstructor() {
00017         $conf = new HashConfig();
00018         $this->assertInstanceOf( 'HashConfig', $conf );
00019 
00020         // Test passing arguments to the constructor
00021         $conf2 = new HashConfig( array(
00022             'one' => '1',
00023         ) );
00024         $this->assertEquals( '1', $conf2->get( 'one' ) );
00025     }
00026 
00030     public function testGet() {
00031         $conf = new HashConfig( array(
00032             'one' => '1',
00033         ));
00034         $this->assertEquals( '1', $conf->get( 'one' ) );
00035         $this->setExpectedException( 'ConfigException', 'HashConfig::get: undefined option' );
00036         $conf->get( 'two' );
00037     }
00038 
00042     public function testHas() {
00043         $conf = new HashConfig( array(
00044             'one' => '1',
00045         ) );
00046         $this->assertTrue( $conf->has( 'one' ) );
00047         $this->assertFalse( $conf->has( 'two' ) );
00048     }
00049 
00053     public function testSet() {
00054         $conf = new HashConfig( array(
00055             'one' => '1',
00056         ) );
00057         $conf->set( 'two', '2' );
00058         $this->assertEquals( '2', $conf->get( 'two' ) );
00059         // Check that set overwrites
00060         $conf->set( 'one', '3' );
00061         $this->assertEquals( '3', $conf->get( 'one' ) );
00062     }
00063 }