/** * Parsing text before an article is displayed or previewed, strip out * semantic properties and add them to the ParserOutput object * * @since 1.9 * * @param string &$text */ public function parse(&$text) { $title = $this->parserData->getTitle(); $this->settings = $this->applicationFactory->getSettings(); $start = microtime(true); // Identifies the current parser run (especially when called recursively) $this->parserData->getSubject()->setContextReference('intp:' . uniqid()); $this->doStripMagicWordsFromText($text); $this->isEnabledNamespace = $this->isSemanticEnabledForNamespace($title); $this->addRedirectTargetAnnotationFromText($text); $linksInValues = $this->settings->get('smwgLinksInValues'); $text = preg_replace_callback($this->getRegexpPattern($linksInValues), $linksInValues ? 'self::process' : 'self::preprocess', $text); if ($this->isEnabledNamespace) { $this->parserData->getOutput()->addModules($this->getModules()); if (method_exists($this->parserData->getOutput(), 'recordOption')) { $this->parserData->getOutput()->recordOption('userlang'); } } $this->parserData->pushSemanticDataToParserOutput(); $this->parserData->addLimitReport('intext-parsertime', number_format(microtime(true) - $start, 3)); SMWOutputs::commitToParserOutput($this->parserData->getOutput()); }
public function testAddLimitReport() { $title = $this->getMockBuilder('Title')->disableOriginalConstructor()->getMock(); $title->expects($this->once())->method('getNamespace')->will($this->returnValue(-1)); $parserOutput = $this->getMockBuilder('ParserOutput')->disableOriginalConstructor()->setMethods(array('setLimitReportData'))->getMock(); $parserOutput->expects($this->once())->method('setLimitReportData')->with($this->stringContains('smw-limitreport-Foo'), $this->stringContains('Bar')); // FIXME 1.22+ if (!method_exists($parserOutput, 'setLimitReportData')) { $this->markTestSkipped('LimitReportData is not available.'); } $instance = new ParserData($title, $parserOutput); $instance->addLimitReport('Foo', 'Bar'); }