MediaWiki  1.30.0
MultiConfigTest.php
Go to the documentation of this file.
1 <?php
2 
4 
11  public function testGet() {
12  $multi = new MultiConfig( [
13  new HashConfig( [ 'foo' => 'bar' ] ),
14  new HashConfig( [ 'foo' => 'baz', 'bar' => 'foo' ] ),
15  new HashConfig( [ 'bar' => 'baz' ] ),
16  ] );
17 
18  $this->assertEquals( 'bar', $multi->get( 'foo' ) );
19  $this->assertEquals( 'foo', $multi->get( 'bar' ) );
20  $this->setExpectedException( 'ConfigException', 'MultiConfig::get: undefined option:' );
21  $multi->get( 'notset' );
22  }
23 
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 }
MultiConfig
Provides a fallback sequence for Config objects.
Definition: MultiConfig.php:28
HashConfig
A Config instance which stores all settings as a member variable.
Definition: HashConfig.php:28
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
MultiConfigTest\testGet
testGet()
Tests that settings are fetched in the right order.
Definition: MultiConfigTest.php:11
MediaWikiTestCase
Definition: MediaWikiTestCase.php:15
MultiConfigTest\testHas
testHas()
MultiConfig::has.
Definition: MultiConfigTest.php:27
MultiConfigTest
Definition: MultiConfigTest.php:3