public function testRenderTemplate()
 {
     $parser = $this->getMockBuilder('\\Parser')->disableOriginalConstructor()->getMock();
     $parser->expects($this->once())->method('recursiveTagParse')->with($this->stringContains('{{Bar|property=Foo|value=42}}{{Foobaz|property=Bar|value=Foo}}'));
     $instance = new HtmlTemplateRenderer(new WikitextTemplateRenderer(), $parser);
     $this->assertEmpty($instance->render());
     $instance->addField('property', 'Foo');
     $instance->addField('value', 42);
     $instance->packFieldsForTemplate('Bar');
     $instance->addField('property', 'Bar');
     $instance->addField('value', 'Foo');
     $instance->packFieldsForTemplate('Foobaz');
     $instance->render();
     $this->assertEmpty($instance->render());
 }
Пример #2
0
 /**
  * @since  1.9
  *
  * @param ArrayFormatter $parameters
  *
  * @return string|null
  */
 public function parse(ArrayFormatter $parameters)
 {
     $count = 0;
     $template = '';
     $subject = $this->parserData->getSemanticData()->getSubject();
     $parametersToArray = $parameters->toArray();
     if (isset($parametersToArray['template'])) {
         $template = $parametersToArray['template'][0];
         unset($parametersToArray['template']);
     }
     foreach ($parametersToArray as $property => $values) {
         foreach ($values as $value) {
             $dataValue = DataValueFactory::getInstance()->newPropertyValue($property, $value, false, $subject);
             $this->parserData->addDataValue($dataValue);
             $this->messageFormatter->addFromArray($dataValue->getErrors());
             $this->addFieldsToTemplate($template, $dataValue, $property, $value, $count);
         }
     }
     $this->parserData->pushSemanticDataToParserOutput();
     $html = $this->templateRenderer->render() . $this->messageFormatter->addFromArray($parameters->getErrors())->getHtml();
     return array($html, 'noparse' => true, 'isHTML' => true);
 }