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 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; }
public function titleProvider() { #2 $provider[] = array(Title::newFromText(__METHOD__)); $title = MockTitle::buildMockForMainNamespace(); $title->expects($this->atLeastOnce())->method('isSpecialPage')->will($this->returnValue(true)); #1 $provider[] = array($title); $title = MockTitle::buildMockForMainNamespace(); $title->expects($this->atLeastOnce())->method('isSpecialPage')->will($this->returnValue(true)); $title->expects($this->atLeastOnce())->method('isSpecial')->will($this->returnValue(true)); #2 $provider[] = array($title); $title = MockTitle::buildMockForMainNamespace(); $title->expects($this->atLeastOnce())->method('isSpecialPage')->will($this->returnValue(true)); $title->expects($this->atLeastOnce())->method('isSpecial')->will($this->returnValue(false)); #3 $provider[] = array($title); 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; }