Ejemplo n.º 1
0
 public function execute()
 {
     $text = $this->getParameter("text");
     $title = $this->getParameter("title");
     $arguments = $this->getFrameArguments();
     if ($arguments === null) {
         $this->getResult()->setWarning("Arguments json format incorect or empty");
     }
     $parser = new Parser();
     $parser->startExternalParse(Title::newFromText($title), new ParserOptions(), 'text', true);
     $frame = $parser->getPreprocessor()->newCustomFrame($arguments);
     try {
         $output = PortableInfoboxParserTagController::getInstance()->render($text, $parser, $frame);
         $this->getResult()->addValue(null, $this->getModuleName(), ['text' => ['*' => $output]]);
     } catch (\Wikia\PortableInfobox\Parser\Nodes\UnimplementedNodeException $e) {
         $this->dieUsage(wfMessage('unimplemented-infobox-tag', [$e->getMessage()])->escaped(), "notimplemented");
     } catch (\Wikia\PortableInfobox\Parser\XmlMarkupParseErrorException $e) {
         $this->dieUsage(wfMessage('xml-parse-error')->text(), "badxml");
     }
 }
 /**
  * @dataProvider testGetLayoutDataProvider
  */
 public function testGetLayout($layout, $expectedOutput, $text, $message)
 {
     $marker = $this->controller->renderInfobox($text, $layout, $this->parser, $this->parser->getPreprocessor()->newFrame())[0];
     $output = $this->controller->replaceMarkers($marker);
     $this->assertTrue($this->checkClassName($output, $expectedOutput, $message));
 }