public function testAddPreConverter() { $html5Converter = new Html5('foo.xsl'); $converter1 = $this->getPreConvertMock(); $html5Converter->addPreConverter($converter1); $converter2 = $this->getPreConvertMock(); $html5Converter->addPreConverter($converter2); $this->assertSame(array($converter1, $converter2), $html5Converter->getPreConverters()); }
/** * Method for parsing ezxmltext field. * * @param \eZ\Publish\API\Repository\Values\Content\Field $field * * @return string */ public function ezxmltext(Field $field) { return $this->html5Converter->convert($field->value->xml); }
/** * @param string $inputFilePath * @param string $outputFilePath * * @dataProvider providerForTestConvert */ public function testConvert( $inputFilePath, $outputFilePath ) { $inputDocument = $this->createDocument( $inputFilePath ); $html5 = new Html5( $this->getDefaultStylesheet(), array(), array( new Expanding(), new EmbedLinking(), ) ); $result = $html5->convert( $inputDocument ); // Make <br> tags valid $result = str_replace( "<br>", "<br/>", $result ); // Make a valid XML document string $result = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><section xmlns=\"http://ez.no/namespaces/ezpublish5/xhtml5\">{$result}</section>"; $convertedDocument = $this->createDocument( $result, false ); $expectedDocument = $this->createDocument( $outputFilePath ); $this->assertEquals( $expectedDocument, $convertedDocument ); }
/** * Implements the "xmltext_to_html5" filter * * @param string $xmlData * * @return string */ public function xmltextToHtml5($xmlData) { return $this->xmlTextConverter->convert($xmlData); }
public function __construct($stylesheet, ConfigResolverInterface $configResolver, array $preConverters = array()) { $customStylesheets = $configResolver->getParameter('fieldtypes.ezxml.custom_xsl'); $customStylesheets = $customStylesheets ?: array(); parent::__construct($stylesheet, $customStylesheets, $preConverters); }
/** * Method for parsing ezxmltext field. * * @param \eZ\Publish\API\Repository\Values\Content\Field $field * * @return string */ public function ezxmltext(Field $field) { return '<![CDATA[' . $this->html5Converter->convert($field->value->xml) . ']]>'; }
/** * @dataProvider dataProviderEmbedRendering */ public function testEmbedRendering($xml, $expected) { $dom = new DomDocument(); $dom->loadXML($xml); $html5 = new Html5($this->getDefaultStylesheet(), array()); $result = $html5->convert($dom); $this->assertEquals($expected, trim($result)); }
/** * Get a Text from a XML * * @param XmlTextValue $value * * @return string */ protected function handleXmlTextValue(XmlTextValue $value) { return trim(strip_tags($this->html5Converter->convert($value->xml))); }