mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 12:48:24 +01:00
Test for toRss()
This commit is contained in:
parent
741d91a76b
commit
661fd6fb2c
@ -2428,6 +2428,9 @@ class e_parse extends e_parser
|
||||
|
||||
$text = $this->ampEncode($text);
|
||||
|
||||
// if CDATA happens to be quoted in the text.
|
||||
$text = str_replace(['<![CDATA', ']]>'], ['<![CDATA', ']]>'], $text);
|
||||
|
||||
if($tags == true && ($text))
|
||||
{
|
||||
$text = '<![CDATA[' .$text. ']]>';
|
||||
|
@ -536,12 +536,53 @@ while($row = $sql->fetch())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
public function testToRss()
|
||||
{
|
||||
$tests = array(
|
||||
'[html]<pre class="prettyprint linenums" style="unicode-bidi: embed; direction: ltr;"></p><p><core name="e_jslib_plugin"><![CDATA[Array]]></core></p><p><core name="e_jslib_theme"><![CDATA[Array]]></core></pre>[/html]',
|
||||
'<div class="something">One & Two < and > " or \'</div>',
|
||||
);
|
||||
|
||||
foreach($tests as $html)
|
||||
{
|
||||
|
||||
$result = $this->tp->toRss($html, true);
|
||||
$valid = $this->isValidXML($result);
|
||||
|
||||
$this->assertTrue($valid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function isValidXML($xmlContent)
|
||||
{
|
||||
if (trim($xmlContent) == '')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$xmlContent = '<?xml version="1.0" encoding="utf-8"?>'."\n".'<description>'.$xmlContent.'</description>';
|
||||
|
||||
libxml_use_internal_errors(true);
|
||||
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
$doc->loadXML($xmlContent);
|
||||
|
||||
$errors = libxml_get_errors();
|
||||
|
||||
if(!empty($errors))
|
||||
{
|
||||
var_dump($errors);
|
||||
}
|
||||
|
||||
libxml_clear_errors();
|
||||
|
||||
return empty($errors);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public function testPreFilter()
|
||||
{
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user