wiki.techinc.nl/tests/phpunit/includes/config/HashConfigTest.php
Kunal Mehta 6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00

63 lines
1.3 KiB
PHP

<?php
class HashConfigTest extends MediaWikiTestCase {
/**
* @covers HashConfig::newInstance
*/
public function testNewInstance() {
$conf = HashConfig::newInstance();
$this->assertInstanceOf( 'HashConfig', $conf );
}
/**
* @covers HashConfig::__construct
*/
public function testConstructor() {
$conf = new HashConfig();
$this->assertInstanceOf( 'HashConfig', $conf );
// Test passing arguments to the constructor
$conf2 = new HashConfig( [
'one' => '1',
] );
$this->assertEquals( '1', $conf2->get( 'one' ) );
}
/**
* @covers HashConfig::get
*/
public function testGet() {
$conf = new HashConfig( [
'one' => '1',
] );
$this->assertEquals( '1', $conf->get( 'one' ) );
$this->setExpectedException( 'ConfigException', 'HashConfig::get: undefined option' );
$conf->get( 'two' );
}
/**
* @covers HashConfig::has
*/
public function testHas() {
$conf = new HashConfig( [
'one' => '1',
] );
$this->assertTrue( $conf->has( 'one' ) );
$this->assertFalse( $conf->has( 'two' ) );
}
/**
* @covers HashConfig::set
*/
public function testSet() {
$conf = new HashConfig( [
'one' => '1',
] );
$conf->set( 'two', '2' );
$this->assertEquals( '2', $conf->get( 'two' ) );
// Check that set overwrites
$conf->set( 'one', '3' );
$this->assertEquals( '3', $conf->get( 'one' ) );
}
}