Exemplo n.º 1
0
 /**
  * @dataProvider queryDataProvider
  */
 public function testInstantiatedQueryData(array $params, array $expected)
 {
     $parserData = $this->applicationFactory->newParserData(Title::newFromText(__METHOD__), new ParserOutput());
     $messageFormatter = $this->getMockBuilder('\\SMW\\MessageFormatter')->disableOriginalConstructor()->getMock();
     $instance = new ShowParserFunction($parserData, $messageFormatter);
     $instance->parse($params);
     foreach ($parserData->getSemanticData()->getSubSemanticData() as $containerSemanticData) {
         $this->assertInstanceOf('SMWContainerSemanticData', $containerSemanticData);
         $this->semanticDataValidator->assertThatPropertiesAreSet($expected, $containerSemanticData);
     }
 }
 public function testQueryWithErroneousData()
 {
     $parserData = $this->applicationFactory->newParserData(Title::newFromText(__METHOD__), new ParserOutput());
     $messageFormatter = $this->getMockBuilder('\\SMW\\MessageFormatter')->disableOriginalConstructor()->getMock();
     $circularReferenceGuard = $this->getMockBuilder('\\SMW\\CircularReferenceGuard')->disableOriginalConstructor()->getMock();
     $instance = new ShowParserFunction($parserData, $messageFormatter, $circularReferenceGuard);
     // #2 [[..]] is not acknowledged therefore displays an error message
     // {{#show: [[File:Fooo]]
     // |?Modification date
     // |default=no results
     // |format=table
     // }}
     $params = array('[[File:Fooo]]', '?Modification date', 'default=no results', 'format=table');
     $instance->parse($params);
     $expected = array('output' => 'class="smwtticon warning"', 'propertyCount' => 4, 'propertyKeys' => array('_ASKFO', '_ASKDE', '_ASKSI', '_ASKST'), 'propertyValues' => array('table', 0, 1, '[[:]]'));
     $this->semanticDataValidator->assertThatPropertiesAreSet($expected, $parserData->getSemanticData()->findSubSemanticData('_QUERYc685f41368e6d9c59dfc9d8d69ef557f'));
     $expected = array('propertyCount' => 2, 'propertyKeys' => array('_ERRP', '_ERRT'));
     $errorID = null;
     foreach ($parserData->getSemanticData()->getSubSemanticData() as $subSemanticData) {
         if (strpos($subSemanticData->getSubject()->getSubobjectName(), '_ERR') !== false) {
             $errorID = $subSemanticData->getSubject()->getSubobjectName();
             break;
         }
     }
     $this->semanticDataValidator->assertThatPropertiesAreSet($expected, $parserData->getSemanticData()->findSubSemanticData($errorID));
 }