assertInstanceOf( 'MediaWiki\\MediaWikiServices', $services ); } public function provideGetters() { // NOTE: This should list all service getters defined in MediaWikiServices. // NOTE: For every test case defined here there should be a corresponding // test case defined in provideGetService(). return [ 'BootstrapConfig' => [ 'getBootstrapConfig', Config::class ], 'ConfigFactory' => [ 'getConfigFactory', ConfigFactory::class ], 'MainConfig' => [ 'getMainConfig', Config::class ], 'SiteStore' => [ 'getSiteStore', SiteStore::class ], 'SiteLookup' => [ 'getSiteLookup', SiteLookup::class ], ]; } /** * @dataProvider provideGetters */ public function testGetters( $getter, $type ) { // Test against the default instance, since the dummy will not know the default services. $services = MediaWikiServices::getInstance(); $service = $services->$getter(); $this->assertInstanceOf( $type, $service ); } public function provideGetService() { // NOTE: This should list all service getters defined in ServiceWiring.php. // NOTE: For every test case defined here there should be a corresponding // test case defined in provideGetters(). return [ 'BootstrapConfig' => [ 'BootstrapConfig', Config::class ], 'ConfigFactory' => [ 'ConfigFactory', ConfigFactory::class ], 'MainConfig' => [ 'MainConfig', Config::class ], 'SiteStore' => [ 'SiteStore', SiteStore::class ], 'SiteLookup' => [ 'SiteLookup', SiteLookup::class ], ]; } /** * @dataProvider provideGetService */ public function testGetService( $name, $type ) { // Test against the default instance, since the dummy will not know the default services. $services = MediaWikiServices::getInstance(); $service = $services->getService( $name ); $this->assertInstanceOf( $type, $service ); } public function testDefaultServiceInstantiation() { // Check all services in the default instance, not a dummy instance! // Note that we instantiate all services here, including any that // were registered by extensions. $services = MediaWikiServices::getInstance(); $names = $services->getServiceNames(); foreach ( $names as $name ) { $this->assertTrue( $services->hasService( $name ) ); $service = $services->getService( $name ); $this->assertInternalType( 'object', $service ); } } }