public function testEnabledSubpageForTitleManipulation() { $instance = new PageDisplayOutputModifier(); $instance->setHideSubpageParentState(true); $instance->setSubpageByNamespace(array(NS_MAIN => true)); $title = $this->getMockBuilder('\\Title')->disableOriginalConstructor()->getMock(); $title->expects($this->once())->method('isSubpage')->will($this->returnValue(true)); $title->expects($this->once())->method('getNamespace')->will($this->returnValue(NS_MAIN)); $output = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock(); $output->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $instance->modifyOutput($output); }
private function addCallbackHandlers($store, $configuration) { $propertyRegistry = new PropertyRegistry(); /** * @see https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks.md */ $this->handlers['SMW::Property::initProperties'] = function () use($propertyRegistry) { return $propertyRegistry->register(); }; /** * @see https://www.mediawiki.org/wiki/Manual:Hooks/SkinTemplateOutputPageBeforeExec */ $this->handlers['SkinTemplateOutputPageBeforeExec'] = function (&$skin, &$template) use($store, $configuration) { $bySubpageLinksFinder = new BySubpageLinksFinder(); $bySubpageLinksFinder->setSubpageDiscoverySupportState($configuration['useSubpageFinderFallback']); $byPropertyHierarchicalLinksFinder = new ByPropertyHierarchicalLinksFinder($store); $byPropertyHierarchicalLinksFinder->setFindClosestDescendantState($configuration['tryToFindClosestDescendant']); $byPropertyHierarchicalLinksFinder->setPropertySearchPatternByNamespace($configuration['propertySearchPatternByNamespace']); $htmlBreadcrumbLinksBuilder = new HtmlBreadcrumbLinksBuilder($byPropertyHierarchicalLinksFinder, $bySubpageLinksFinder); $htmlBreadcrumbLinksBuilder->setLinker(new DummyLinker()); $htmlBreadcrumbLinksBuilder->setBreadcrumbTrailStyleClass($configuration['breadcrumbTrailStyleClass']); $htmlBreadcrumbLinksBuilder->setBreadcrumbDividerStyleClass($configuration['breadcrumbDividerStyleClass']); $skinTemplateOutputModifier = new SkinTemplateOutputModifier($htmlBreadcrumbLinksBuilder); $skinTemplateOutputModifier->modifyTemplate($template); $skinTemplateOutputModifier->modifyOutput($skin->getOutput()); return true; }; /** * @see https://www.mediawiki.org/wiki/Manual:Hooks/BeforePageDisplay */ $this->handlers['BeforePageDisplay'] = function (&$output, &$skin) use($configuration) { $pageDisplayOutputModifier = new PageDisplayOutputModifier(); $pageDisplayOutputModifier->setHideSubpageParentState($configuration['hideSubpageParent']); $pageDisplayOutputModifier->setSubpageByNamespace($configuration['wgNamespacesWithSubpages']); $pageDisplayOutputModifier->modifyOutput($output); return true; }; }