/** * @since 2.1 * * @return AskParserFunction */ public function newAskParserFunction() { $circularReferenceGuard = new CircularReferenceGuard('ask-parser'); $circularReferenceGuard->setMaxRecursionDepth(2); $parserData = ApplicationFactory::getInstance()->newParserData($this->parser->getTitle(), $this->parser->getOutput()); $messageFormatter = new MessageFormatter($this->parser->getTargetLanguage()); $instance = new AskParserFunction($parserData, $messageFormatter, $circularReferenceGuard); $instance->setEnabledFormatsThatSupportRecursiveParse(ApplicationFactory::getInstance()->getSettings()->get('smwgEnabledResultFormatsWithRecursiveAnnotationSupport')); return $instance; }
/** * @dataProvider queryDataProvider */ public function testInstantiatedQueryData(array $params, array $expected, array $settings) { foreach ($settings as $key => $value) { $this->applicationFactory->getSettings()->set($key, $value); } $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 AskParserFunction($parserData, $messageFormatter, $circularReferenceGuard); $instance->parse($params); foreach ($parserData->getSemanticData()->getSubSemanticData() as $containerSemanticData) { $this->assertInstanceOf('SMWContainerSemanticData', $containerSemanticData); $this->semanticDataValidator->assertThatPropertiesAreSet($expected, $containerSemanticData); } }
public function testEmbeddedQueryWithError() { $params = array('[[--ABC·|DEF::123]]', 'format=table'); $expected = array('propertyCount' => 2, 'propertyKeys' => array('_ASK', '_ERRC')); $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 AskParserFunction($parserData, $messageFormatter, $circularReferenceGuard); $instance->parse($params); $this->semanticDataValidator->assertThatPropertiesAreSet($expected, $parserData->getSemanticData()); }
public function testWithDisabledQueryProfiler() { $params = array('[[Modification date::+]]', 'format=table'); $expected = array('propertyCount' => 0); $this->applicationFactory->getSettings()->set('smwgQueryProfiler', false); $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 AskParserFunction($parserData, $messageFormatter, $circularReferenceGuard); $instance->parse($params); $this->semanticDataValidator->assertThatPropertiesAreSet($expected, $parserData->getSemanticData()); }