Esempio n. 1
0
 /**
  * @dataProvider textDataProvider
  */
 public function testGetMagicWords($text, array $expected)
 {
     $title = Title::newFromText(__METHOD__);
     $settings = Settings::newFromArray(array('smwgShowFactboxEdit' => SMW_FACTBOX_HIDDEN, 'smwgShowFactbox' => SMW_FACTBOX_HIDDEN));
     $this->applicationFactory->registerObject('Settings', $settings);
     $parserOutput = $this->getMockBuilder('\\ParserOutput')->disableOriginalConstructor()->getMock();
     $parserOutput->expects($this->any())->method('getExtensionData')->will($this->returnValue($expected['magicWords']));
     // MW 1.19, 1.20
     $parserOutput->mSMWMagicWords = $expected['magicWords'];
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $messageBuilder = $this->getMockBuilder('\\SMW\\MediaWiki\\MessageBuilder')->disableOriginalConstructor()->getMock();
     $instance = new Factbox($store, new ParserData($title, $parserOutput), $messageBuilder);
     if (isset($expected['preview']) && $expected['preview']) {
         $instance->useInPreview(true);
     }
     $reflector = new ReflectionClass('\\SMW\\Factbox');
     $magic = $reflector->getMethod('getMagicWords');
     $magic->setAccessible(true);
     $result = $magic->invoke($instance);
     $this->assertInternalType('integer', $result);
     $this->assertEquals($expected['constants'], $result);
 }
Esempio n. 2
0
 /**
  * @dataProvider tableContentDataProvider
  */
 public function testGetTableContent($test, $expected)
 {
     $title = Title::newFromText(__METHOD__);
     $parserData = new ParserData($title, new ParserOutput());
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $message = $this->getMockBuilder('\\Message')->disableOriginalConstructor()->getMock();
     $message->expects($this->any())->method('inContentLanguage')->will($this->returnSelf());
     $messageBuilder = $this->getMockBuilder('\\SMW\\MediaWiki\\MessageBuilder')->disableOriginalConstructor()->getMock();
     $messageBuilder->expects($this->any())->method('getMessage')->will($this->returnValue($message));
     $mockDIProperty = $this->mockbuilder->newObject('DIProperty', array('isUserDefined' => $test['isUserDefined'], 'isShown' => $test['isShown'], 'getLabel' => 'Quuey'));
     $parserData->setSemanticData(new SemanticData(DIWikiPage::newFromTitle($title)));
     $parserData->getSemanticData()->addPropertyObjectValue($mockDIProperty, DIWikiPage::newFromTitle($title));
     $instance = new Factbox($store, $parserData, $messageBuilder);
     $this->stringValidator->assertThatStringContains($expected, $instance->doBuild()->getContent());
 }