public function testWikiPage_TYPE_LAST_EDITOR() { $userPage = MockTitle::buildMock('Lula'); $userPage->expects($this->any())->method('getNamespace')->will($this->returnValue(NS_USER)); $instance = $this->constructPageInfoProviderInstance(array('wikiPage' => array(), 'revision' => array(), 'user' => array('getUserPage' => $userPage))); $this->assertEquals($userPage, $instance->getLastEditor()); }
public function testCanConstruct() { $oldTitle = MockTitle::buildMock('old'); $newTitle = MockTitle::buildMock('new'); $instance = new TitleMoveComplete($oldTitle, $newTitle, new MockSuperUser(), 0, 0); $this->assertInstanceOf('\\SMW\\MediaWiki\\Hooks\\TitleMoveComplete', $instance); }
public function testProcess() { $oldTitle = MockTitle::buildMock('old'); $newTitle = MockTitle::buildMock('new'); $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass(); $store->expects($this->once())->method('changeTitle')->with($this->equalTo($oldTitle), $this->equalTo($newTitle), $this->anything(), $this->anything()); $this->applicationFactory->registerObject('Settings', Settings::newFromArray(array('smwgCacheType' => 'hash', 'smwgAutoRefreshOnPageMove' => true))); $this->applicationFactory->registerObject('Store', $store); $instance = new TitleMoveComplete($oldTitle, $newTitle, new MockSuperUser(), 0, 0); $this->assertTrue($instance->process()); }
public function testTryToResolveCircularRedirectThrowsException() { $title = MockTitle::buildMock('Uuuuuuuuuu'); $wikiPage = $this->getMockBuilder('\\WikiPage')->disableOriginalConstructor()->getMock(); $wikiPage->expects($this->atLeastOnce())->method('getRedirectTarget')->will($this->returnValue($title)); $pageCreator = $this->getMockBuilder('\\SMW\\MediaWiki\\PageCreator')->disableOriginalConstructor()->getMock(); $pageCreator->expects($this->any())->method('createPage')->will($this->returnValue($wikiPage)); $instance = $this->getMockBuilder('\\SMW\\MediaWiki\\DeepRedirectTargetResolver')->setConstructorArgs(array($pageCreator))->setMethods(array('isRedirect'))->getMock(); $instance->expects($this->any())->method('isRedirect')->will($this->returnValue(true)); $this->setExpectedException('RuntimeException'); $instance->findRedirectTargetFor($title); }
public function titleDataProvider() { $language = Language::factory('en'); #0 Standard title $title = MockTitle::buildMockForMainNamespace(); $title->expects($this->atLeastOnce())->method('getPrefixedText')->will($this->returnValue('Foo')); $title->expects($this->atLeastOnce())->method('isSpecialPage')->will($this->returnValue(false)); $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language)); $provider[] = array(array('title' => $title), array('result' => true)); #1 as SpecialPage $title = MockTitle::buildMock(); $title->expects($this->atLeastOnce())->method('isSpecialPage')->will($this->returnValue(true)); $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language)); $provider[] = array(array('title' => $title), array('result' => false)); return $provider; }
public function titleDataProvider() { $validIdTitle = MockTitle::buildMock('validIdTitle'); $validIdTitle->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(9999)); #0 Id = cache $provider[] = array(array('title' => $validIdTitle, 'smwgAutoRefreshOnPurge' => true, 'smwgFactboxCacheRefreshOnPurge' => true), array('factboxPreProcess' => false, 'autorefreshPreProcess' => false, 'autorefreshPostProcess' => true, 'factboxPostProcess' => false)); #1 Disabled setting $validIdTitle = MockTitle::buildMock('Disabled'); $validIdTitle->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(9099)); $provider[] = array(array('title' => $validIdTitle, 'smwgAutoRefreshOnPurge' => false, 'smwgFactboxCacheRefreshOnPurge' => false), array('factboxPreProcess' => false, 'autorefreshPreProcess' => false, 'autorefreshPostProcess' => false, 'factboxPostProcess' => false)); // #2 No Id $nullIdTitle = MockTitle::buildMock('NullId'); $nullIdTitle->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(0)); $provider[] = array(array('title' => $nullIdTitle, 'smwgAutoRefreshOnPurge' => true, 'smwgFactboxCacheRefreshOnPurge' => true), array('factboxPreProcess' => false, 'autorefreshPreProcess' => false, 'autorefreshPostProcess' => false, 'factboxPostProcess' => false)); #3 No Id $provider[] = array(array('title' => $nullIdTitle, 'smwgAutoRefreshOnPurge' => true, 'smwgFactboxCacheRefreshOnPurge' => false), array('factboxPreProcess' => false, 'autorefreshPreProcess' => false, 'autorefreshPostProcess' => false, 'factboxPostProcess' => false)); return $provider; }
public function specialPropertiesDataProvider() { $provider = array(); #0 Unknown $provider[] = array(array('subject' => DIWikiPage::newFromTitle(Title::newFromText('UNKNOWN')), 'settings' => array('smwgPageSpecialProperties' => array('Lala', '_Lula', '-Lila', '')), 'pageInfo' => array()), array('propertyCount' => 0)); #1 TYPE_MODIFICATION_DATE $provider[] = array(array('subject' => DIWikiPage::newFromTitle(Title::newFromText('withModificationDate')), 'settings' => array('smwgPageSpecialProperties' => array(DIProperty::TYPE_MODIFICATION_DATE)), 'pageInfo' => array('getModificationDate' => 1272508903)), array('propertyCount' => 1, 'propertyKeys' => '_MDAT', 'propertyValues' => array('2010-04-29T02:41:43'))); #2 TYPE_CREATION_DATE $provider[] = array(array('subject' => DIWikiPage::newFromTitle(Title::newFromText('withCreationDate')), 'settings' => array('smwgPageSpecialProperties' => array(DIProperty::TYPE_CREATION_DATE)), 'pageInfo' => array('getCreationDate' => 1272508903)), array('propertyCount' => 1, 'propertyKeys' => '_CDAT', 'propertyValues' => array('2010-04-29T02:41:43'))); #3 TYPE_NEW_PAGE $provider[] = array(array('subject' => DIWikiPage::newFromTitle(Title::newFromText('NEW_PAGE_isNew')), 'settings' => array('smwgPageSpecialProperties' => array(DIProperty::TYPE_NEW_PAGE)), 'pageInfo' => array('isNewPage' => true)), array('propertyCount' => 1, 'propertyKeys' => '_NEWP', 'propertyValues' => array(true))); #4 $provider[] = array(array('subject' => DIWikiPage::newFromTitle(Title::newFromText('NEW_PAGE_isNotNew')), 'settings' => array('smwgPageSpecialProperties' => array(DIProperty::TYPE_NEW_PAGE)), 'pageInfo' => array('isNewPage' => false)), array('propertyCount' => 1, 'propertyKeys' => '_NEWP', 'propertyValues' => array(false))); #5 TYPE_LAST_EDITOR $userPage = MockTitle::buildMock('Lula'); $userNS = Localizer::getInstance()->getNamespaceTextById(NS_USER); $userPage->expects($this->any())->method('getNamespace')->will($this->returnValue(NS_USER)); $provider[] = array(array('subject' => DIWikiPage::newFromTitle(Title::newFromText('withLastEditor')), 'settings' => array('smwgPageSpecialProperties' => array(DIProperty::TYPE_LAST_EDITOR)), 'pageInfo' => array('getLastEditor' => $userPage)), array('propertyCount' => 1, 'propertyKeys' => '_LEDT', 'propertyValues' => array(":{$userNS}:Lula"))); #6 Combined entries $userPage = MockTitle::buildMock('Lula'); $userNS = Localizer::getInstance()->getNamespaceTextById(NS_USER); $userPage->expects($this->any())->method('getNamespace')->will($this->returnValue(NS_USER)); $provider[] = array(array('subject' => DIWikiPage::newFromTitle(Title::newFromText('withCombinedEntries')), 'settings' => array('smwgPageSpecialProperties' => array('_MDAT', '_LEDT')), 'pageInfo' => array('getModificationDate' => 1272508903, 'getLastEditor' => $userPage)), array('propertyCount' => 2, 'propertyKeys' => array('_MDAT', '_LEDT'), 'propertyValues' => array('2010-04-29T02:41:43', ":{$userNS}:Lula"))); #7 TYPE_MEDIA $provider[] = array(array('subject' => DIWikiPage::newFromTitle(Title::newFromText('MimePropertyForFilePage')), 'settings' => array('smwgPageSpecialProperties' => array(DIProperty::TYPE_MEDIA)), 'pageInfo' => array('isFilePage' => true, 'getMediaType' => 'FooMedia')), array('propertyCount' => 1, 'propertyKeys' => '_MEDIA', 'propertyValues' => array('FooMedia'))); #8 $provider[] = array(array('subject' => DIWikiPage::newFromTitle(Title::newFromText('MediaPropertyForNonFilePage')), 'settings' => array('smwgPageSpecialProperties' => array(DIProperty::TYPE_MEDIA)), 'pageInfo' => array('isFilePage' => false, 'getMediaType' => 'FooMedia')), array('propertyCount' => 0)); #9 TYPE_MIME $provider[] = array(array('subject' => DIWikiPage::newFromTitle(Title::newFromText('MimePropertyForFilePage')), 'settings' => array('smwgPageSpecialProperties' => array(DIProperty::TYPE_MIME)), 'pageInfo' => array('isFilePage' => true, 'getMimeType' => 'FooMime')), array('propertyCount' => 1, 'propertyKeys' => '_MIME', 'propertyValues' => array('FooMime'))); #10 $provider[] = array(array('subject' => DIWikiPage::newFromTitle(Title::newFromText('MimePropertyForNonFilePage')), 'settings' => array('smwgPageSpecialProperties' => array(DIProperty::TYPE_MIME)), 'pageInfo' => array('isFilePage' => false, 'getMimeType' => 'FooMime')), array('propertyCount' => 0)); #11 Empty TYPE_MIME $provider[] = array(array('subject' => DIWikiPage::newFromTitle(Title::newFromText('EmptyMimePropertyFilePage')), 'settings' => array('smwgPageSpecialProperties' => array(DIProperty::TYPE_MIME)), 'pageInfo' => array('isFilePage' => true, 'getMimeType' => '')), array('propertyCount' => 0)); #12 Empty TYPE_MEDIA $provider[] = array(array('subject' => DIWikiPage::newFromTitle(Title::newFromText('EmptyMediaPropertyFilePage')), 'settings' => array('smwgPageSpecialProperties' => array(DIProperty::TYPE_MEDIA)), 'pageInfo' => array('isFilePage' => true, 'getMediaType' => '')), array('propertyCount' => 0)); #13 Null TYPE_MIME $provider[] = array(array('subject' => DIWikiPage::newFromTitle(Title::newFromText('NullMimePropertyFilePage')), 'settings' => array('smwgPageSpecialProperties' => array(DIProperty::TYPE_MIME)), 'pageInfo' => array('isFilePage' => true, 'getMimeType' => null)), array('propertyCount' => 0)); #14 Null TYPE_MEDIA $provider[] = array(array('subject' => DIWikiPage::newFromTitle(Title::newFromText('NullMediaPropertyFilePage')), 'settings' => array('smwgPageSpecialProperties' => array(DIProperty::TYPE_MEDIA)), 'pageInfo' => array('isFilePage' => true, 'getMimeType' => null)), array('propertyCount' => 0)); return $provider; }
public function skinTemplateDataProvider() { #0 Standard title $settings = array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgToolboxBrowseLink' => true); $message = $this->getMockBuilder('\\Message')->disableOriginalConstructor()->getMock(); $skin = $this->getMockBuilder('\\Skin')->disableOriginalConstructor()->getMock(); $skin->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue(Title::newFromText(__METHOD__))); $skin->expects($this->any())->method('msg')->will($this->returnValue($message)); $skinTemplate = $this->getMockBuilder('\\SkinTemplate')->disableOriginalConstructor()->getMock(); $skinTemplate->expects($this->atLeastOnce())->method('getSkin')->will($this->returnValue($skin)); $skinTemplate->data['isarticle'] = true; $provider[] = array(array('skinTemplate' => $skinTemplate, 'settings' => $settings), array('count' => 4)); #1 isarticle = false $skinTemplate = $this->getMockBuilder('\\SkinTemplate')->disableOriginalConstructor()->getMock(); $skinTemplate->expects($this->atLeastOnce())->method('getSkin')->will($this->returnValue($skin)); $skinTemplate->data['isarticle'] = false; $provider[] = array(array('skinTemplate' => $skinTemplate, 'settings' => $settings), array('count' => 0)); #2 smwgToolboxBrowseLink = false $skinTemplate = $this->getMockBuilder('\\SkinTemplate')->disableOriginalConstructor()->getMock(); $skinTemplate->expects($this->atLeastOnce())->method('getSkin')->will($this->returnValue($skin)); $skinTemplate->data['isarticle'] = true; $settings = array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgToolboxBrowseLink' => false); $provider[] = array(array('skinTemplate' => $skinTemplate, 'settings' => $settings), array('count' => 0)); #3 smwgNamespacesWithSemanticLinks = false $settings = array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => false), 'smwgToolboxBrowseLink' => true); $provider[] = array(array('skinTemplate' => $skinTemplate, 'settings' => $settings), array('count' => 0)); #4 Special page $settings = array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgToolboxBrowseLink' => true); $title = MockTitle::buildMock(__METHOD__); $title->expects($this->atLeastOnce())->method('isSpecialPage')->will($this->returnValue(true)); $skin = $this->getMockBuilder('\\Skin')->disableOriginalConstructor()->getMock(); $skin->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $skinTemplate = $this->getMockBuilder('\\SkinTemplate')->disableOriginalConstructor()->getMock(); $skinTemplate->expects($this->atLeastOnce())->method('getSkin')->will($this->returnValue($skin)); $skinTemplate->data['isarticle'] = true; $provider[] = array(array('skinTemplate' => $skinTemplate, 'settings' => $settings), array('count' => 0)); return $provider; }
public function titleDataProvider() { #0 Runs store update $store = $this->getMockBuilder('SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass(); $store->expects($this->atLeastOnce())->method('updateData'); $title = MockTitle::buildMock(__METHOD__); $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_MAIN)); $title->expects($this->atLeastOnce())->method('inNamespace')->will($this->returnValue(false)); $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(5001)); $provider[] = array(array('store' => $store, 'title' => $title, 'cache' => true, 'data-status' => true)); #1 No cache entry, no store update $store = $this->getMockBuilder('SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass(); $store->expects($this->never())->method('updateData'); $title = MockTitle::buildMock(__METHOD__); $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_MAIN)); $title->expects($this->atLeastOnce())->method('inNamespace')->will($this->returnValue(false)); $provider[] = array(array('store' => $store, 'title' => $title, 'cache' => false, 'data-status' => true)); #2 SpecialPage, no store update $store = $this->getMockBuilder('SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass(); $store->expects($this->never())->method('updateData'); $title = MockTitle::buildMock(__METHOD__); $title->expects($this->atLeastOnce())->method('isSpecialPage')->will($this->returnValue(true)); $provider[] = array(array('store' => $store, 'title' => $title, 'cache' => false, 'data-status' => true)); #3 NS_FILE, no store update $store = $this->getMockBuilder('SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass(); $store->expects($this->never())->method('updateData'); $title = MockTitle::buildMock(__METHOD__); $title->expects($this->atLeastOnce())->method('inNamespace')->will($this->returnValue(true)); $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_FILE)); $provider[] = array(array('store' => $store, 'title' => $title, 'cache' => true, 'data-status' => true)); return $provider; }
public function outputDataProvider() { $language = Language::factory('en'); $title = MockTitle::buildMockForMainNamespace(__METHOD__ . 'mock-subject'); $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true)); $subject = DIWikiPage::newFromTitle($title); $semanticData = $this->getMockBuilder('\\SMW\\SemanticData')->disableOriginalConstructor()->getMock(); $semanticData->expects($this->atLeastOnce())->method('getSubject')->will($this->returnValue($subject)); $semanticData->expects($this->atLeastOnce())->method('hasVisibleProperties')->will($this->returnValue(true)); $semanticData->expects($this->atLeastOnce())->method('getPropertyValues')->will($this->returnValue(array(DIWikiPage::newFromTitle($title)))); $semanticData->expects($this->atLeastOnce())->method('getProperties')->will($this->returnValue(array(new DIProperty(__METHOD__ . 'property')))); $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass(); #0 Factbox build, being visible $title = MockTitle::buildMock(__METHOD__ . 'title-being-visible'); $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true)); $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_MAIN)); $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language)); $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(10001)); $title->expects($this->atLeastOnce())->method('getLatestRevID')->will($this->returnValue(10001)); $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock(); $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext())); $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgShowFactbox' => SMW_FACTBOX_NONEMPTY, 'outputPage' => $outputPage, 'store' => $store, 'parserOutput' => $this->makeParserOutput($semanticData)), array('text' => $subject->getDBKey())); #1 Factbox build, being visible, using WebRequest oldid $title = MockTitle::buildMock(__METHOD__ . 'title-with-oldid'); $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true)); $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_MAIN)); $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language)); $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(10002)); $title->expects($this->atLeastOnce())->method('getLatestRevID')->will($this->returnValue(10002)); $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock(); $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $context = new \RequestContext(); $context->setRequest(new \FauxRequest(array('oldid' => 9001), true)); $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue($context)); $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgShowFactbox' => SMW_FACTBOX_NONEMPTY, 'outputPage' => $outputPage, 'store' => $store, 'parserOutput' => $this->makeParserOutput($semanticData)), array('text' => $subject->getDBKey())); #2 Factbox is expected not to be visible $title = MockTitle::buildMock(__METHOD__ . 'title-ns-disabled'); $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_MAIN)); $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language)); $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(10003)); $title->expects($this->atLeastOnce())->method('getLatestRevID')->will($this->returnValue(10003)); $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock(); $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext())); $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => false), 'smwgShowFactbox' => SMW_FACTBOX_HIDDEN, 'outputPage' => $outputPage, 'store' => $store, 'parserOutput' => $this->makeParserOutput($semanticData)), array('text' => null)); #3 No semantic data $title = MockTitle::buildMock(__METHOD__ . 'title-empty-semanticdata'); $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_MAIN)); $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language)); $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(10004)); $title->expects($this->atLeastOnce())->method('getLatestRevID')->will($this->returnValue(10004)); $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock(); $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext())); $semanticData = $this->getMockBuilder('\\SMW\\SemanticData')->disableOriginalConstructor()->getMock(); $semanticData->expects($this->atLeastOnce())->method('isEmpty')->will($this->returnValue(true)); $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass(); $store->expects($this->atLeastOnce())->method('getSemanticData')->will($this->returnValue($semanticData)); $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgShowFactbox' => SMW_FACTBOX_NONEMPTY, 'outputPage' => $outputPage, 'store' => $store, 'parserOutput' => $this->makeParserOutput(null)), array('text' => null)); // #4 SpecialPage $title = MockTitle::buildMock(__METHOD__ . 'title-specialpage'); $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_MAIN)); $title->expects($this->atLeastOnce())->method('isSpecialPage')->will($this->returnValue(true)); $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock(); $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext())); $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass(); $store->expects($this->atLeastOnce())->method('getSemanticData')->will($this->returnValue($semanticData)); $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgShowFactbox' => SMW_FACTBOX_NONEMPTY, 'outputPage' => $outputPage, 'store' => $store, 'parserOutput' => $this->makeParserOutput(null)), array('text' => '')); // #5 does not exist $title = MockTitle::buildMock(__METHOD__ . 'title-not-exists'); $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_MAIN)); $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(false)); $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock(); $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext())); $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass(); $store->expects($this->atLeastOnce())->method('getSemanticData')->will($this->returnValue($semanticData)); $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'smwgShowFactbox' => SMW_FACTBOX_NONEMPTY, 'outputPage' => $outputPage, 'store' => $store, 'parserOutput' => $this->makeParserOutput(null)), array('text' => '')); return $provider; }
/** * @return array */ public function hiddenCategoriesDataProvider() { $provider = array(); $hidCategory = MockTitle::buildMock(__METHOD__); $hidCategory->expects($this->any())->method('getNamespace')->will($this->returnValue(NS_CATEGORY)); $hidCategory->expects($this->any())->method('getText')->will($this->returnValue('Bar')); // #0 Standard category, show hidden category $provider[] = array(array('namespace' => NS_MAIN, 'categories' => array('Foo', 'Bar'), 'hidCategories' => array($hidCategory), 'settings' => array('smwgUseCategoryHierarchy' => false, 'smwgCategoriesAsInstances' => true, 'smwgShowHiddenCategories' => true)), array('propertyCount' => 1, 'propertyKeys' => '_INST', 'propertyValues' => array('Foo', 'Bar'))); // #1 Standard category, omit hidden category $provider[] = array(array('namespace' => NS_MAIN, 'categories' => array('Foo', 'Bar'), 'hidCategories' => array($hidCategory), 'settings' => array('smwgUseCategoryHierarchy' => false, 'smwgCategoriesAsInstances' => true, 'smwgShowHiddenCategories' => false)), array('propertyCount' => 1, 'propertyKeys' => '_INST', 'propertyValues' => array('Foo'))); // #2 Category hierarchy or Sub-category, show hidden category $provider[] = array(array('namespace' => NS_CATEGORY, 'categories' => array('Foo', 'Bar'), 'hidCategories' => array($hidCategory), 'settings' => array('smwgUseCategoryHierarchy' => true, 'smwgCategoriesAsInstances' => false, 'smwgShowHiddenCategories' => true)), array('propertyCount' => 1, 'propertyKeys' => '_SUBC', 'propertyValues' => array('Foo', 'Bar'))); // #3 Category hierarchy or Sub-category, omit hidden category $provider[] = array(array('namespace' => NS_CATEGORY, 'categories' => array('Foo', 'Bar'), 'hidCategories' => array($hidCategory), 'settings' => array('smwgUseCategoryHierarchy' => true, 'smwgCategoriesAsInstances' => false, 'smwgShowHiddenCategories' => false)), array('propertyCount' => 1, 'propertyKeys' => '_SUBC', 'propertyValues' => array('Foo'))); return $provider; }
public function outputDataProvider() { $text = __METHOD__ . 'text-0'; #0 Retrive content from outputPage property $title = MockTitle::buildMock(__METHOD__ . 'from-property'); $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true)); $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(10001)); $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock(); $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $outputPage->mSMWFactboxText = $text; $skin = $this->getMockBuilder('\\Skin')->disableOriginalConstructor()->getMock(); $skin->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue(null)); $skin->expects($this->atLeastOnce())->method('getOutput')->will($this->returnValue($outputPage)); $skin->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext())); $provider[] = array(array('skin' => $skin), array('text' => $text)); #1 Retrive content from cache $title = MockTitle::buildMock(__METHOD__ . 'from-cache'); $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true)); $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(10002)); $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock(); $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $text = __METHOD__ . 'text-1'; $skin = $this->getMockBuilder('\\Skin')->disableOriginalConstructor()->getMock(); $skin->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $skin->expects($this->atLeastOnce())->method('getOutput')->will($this->returnValue($outputPage)); $skin->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext())); $provider[] = array(array('skin' => $skin, 'text' => $text, 'title' => $outputPage->getTitle()), array('text' => $text)); // #2 Special page $text = __METHOD__ . 'text-2'; $title = MockTitle::buildMock(__METHOD__ . 'specialpage'); $title->expects($this->atLeastOnce())->method('isSpecialPage')->will($this->returnValue(true)); $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock(); $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $outputPage->mSMWFactboxText = $text; $skin = $this->getMockBuilder('\\Skin')->disableOriginalConstructor()->getMock(); $skin->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $skin->expects($this->atLeastOnce())->method('getOutput')->will($this->returnValue($outputPage)); $skin->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext())); $provider[] = array(array('skin' => $skin, 'text' => $text), array('text' => '')); // #3 "edit" request $text = __METHOD__ . 'text-3'; $title = MockTitle::buildMock(__METHOD__ . 'edit-request'); $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true)); $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(10003)); $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock(); $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $outputPage->mSMWFactboxText = $text; $skin = $this->getMockBuilder('\\Skin')->disableOriginalConstructor()->getMock(); $skin->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $skin->expects($this->atLeastOnce())->method('getOutput')->will($this->returnValue($outputPage)); $context = new \RequestContext(); $context->setRequest(new \FauxRequest(array('action' => 'edit'), true)); $skin->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue($context)); $provider[] = array(array('skin' => $skin, 'text' => $text), array('text' => $text)); // #4 "delete" request $text = __METHOD__ . 'text-4'; $title = MockTitle::buildMock(__METHOD__ . 'delete-request'); $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock(); $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $skin = $this->getMockBuilder('\\Skin')->disableOriginalConstructor()->getMock(); $skin->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $skin->expects($this->atLeastOnce())->method('getOutput')->will($this->returnValue($outputPage)); $context = new \RequestContext(); $context->setRequest(new \FauxRequest(array('action' => 'delete'), true)); $skin->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue($context)); $provider[] = array(array('skin' => $skin, 'text' => $text), array('text' => '')); return $provider; }
public function outputDataProvider() { $language = Language::factory('en'); $title = MockTitle::buildMockForMainNamespace(__METHOD__ . 'mock-subject'); $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true)); $subject = DIWikiPage::newFromTitle($title); $semanticData = $this->getMockBuilder('\\SMW\\SemanticData')->disableOriginalConstructor()->getMock(); $semanticData->expects($this->atLeastOnce())->method('getSubject')->will($this->returnValue($subject)); $semanticData->expects($this->atLeastOnce())->method('hasVisibleProperties')->will($this->returnValue(true)); $semanticData->expects($this->atLeastOnce())->method('getPropertyValues')->will($this->returnValue(array(DIWikiPage::newFromTitle($title)))); $semanticData->expects($this->atLeastOnce())->method('getProperties')->will($this->returnValue(array(new DIProperty(__METHOD__ . 'property')))); #0 Simple factbox build, returning content $title = MockTitle::buildMock(__METHOD__ . 'title-with-content'); $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true)); $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_MAIN)); $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language)); $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(9098)); $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock(); $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext())); $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'outputPage' => $outputPage, 'parserOutput' => $this->makeParserOutput($semanticData)), array('text' => $subject->getDBKey())); #1 Disabled namespace, no return value expected $title = MockTitle::buildMock(__METHOD__ . 'title-ns-disabled'); $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_MAIN)); $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language)); $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(90000)); $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock(); $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext())); $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => false), 'outputPage' => $outputPage, 'parserOutput' => $this->makeParserOutput($semanticData)), array('text' => '')); // #2 Specialpage, no return value expected $title = MockTitle::buildMock(__METHOD__ . 'mock-specialpage'); $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language)); $title->expects($this->atLeastOnce())->method('isSpecialPage')->will($this->returnValue(true)); $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock(); $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext())); $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'outputPage' => $outputPage, 'parserOutput' => $this->makeParserOutput($semanticData)), array('text' => '')); // #3 Redirect, no return value expected $title = MockTitle::buildMock(__METHOD__ . 'mock-redirect'); $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language)); $title->expects($this->atLeastOnce())->method('isRedirect')->will($this->returnValue(true)); $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock(); $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext())); $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'outputPage' => $outputPage, 'parserOutput' => $this->makeParserOutput($semanticData)), array('text' => '')); // #4 Oldid $title = MockTitle::buildMockForMainNamespace(__METHOD__ . 'mock-oldid'); $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true)); $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language)); $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock(); $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title)); $context = new \RequestContext(); $context->setRequest(new \FauxRequest(array('oldid' => 9001), true)); $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue($context)); $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'outputPage' => $outputPage, 'parserOutput' => $this->makeParserOutput($semanticData)), array('text' => $subject->getDBKey())); return $provider; }
public function testCreateFilePage() { $instance = new PageCreator(); $this->assertInstanceOf('\\WikiFilePage', $instance->createFilePage(MockTitle::buildMock(__METHOD__))); }