mwHooksHandler = new MwHooksHandler(); } public function tearDown(): void { $this->mwHooksHandler->restoreListedHooks(); parent::tearDown(); } public function testRunNamespaceManagerWithNoConstantsDefined() { $this->mwHooksHandler->deregisterListedHooks(); $default = [ 'smwgNamespacesWithSemanticLinks' => [], 'wgNamespacesWithSubpages' => [], 'wgExtraNamespaces' => [], 'wgNamespaceAliases' => [], 'wgContentNamespaces' => [], 'wgNamespacesToBeSearchedDefault' => [], 'wgLanguageCode' => 'en' ]; $instance = $this->getMockBuilder( '\SMW\NamespaceManager' ) ->setMethods( [ 'isDefinedConstant' ] ) ->getMock(); $instance->expects( $this->atLeastOnce() ) ->method( 'isDefinedConstant' ) ->willReturn( false ); $instance->init( $default ); } public function testCanonicalNames() { $this->mwHooksHandler->deregisterListedHooks(); $applicationFactory = ApplicationFactory::getInstance(); $namespaceInfo = $applicationFactory->singleton( 'NamespaceInfo' ); $count = 0; $index = NamespaceManager::buildNamespaceIndex( $applicationFactory->getSettings()->get( 'smwgNamespaceIndex' ) ); $names = NamespaceManager::getCanonicalNames(); $this->assertIsArray( $names ); $this->assertIsArray( $index ); foreach ( $index as $ns => $idx ) { $mwNamespace = $namespaceInfo->getCanonicalName( $idx ); if ( $mwNamespace && isset( $names[$idx] ) ) { $this->assertEquals( $mwNamespace, $names[$idx] ); $count++; } } $this->assertCount( $count, $names, "Asserts that expected amount of cannonical names have been verified" ); } }