120 lines
4.2 KiB
PHP
120 lines
4.2 KiB
PHP
<?php
|
|
|
|
class ReverseEntitiesTests extends AbstractUnitTests
|
|
{
|
|
protected function getSimpleData()
|
|
{
|
|
return 'This string contains < & >.';
|
|
}
|
|
|
|
protected function getUtf8Data()
|
|
{
|
|
return 'This data contains special chars like <, >, & and " as well as ä, ö, ß, à and ê';
|
|
}
|
|
|
|
/**
|
|
* @covers XML_Util::reverseEntities()
|
|
*/
|
|
public function testReverseEntitiesForSimpleData()
|
|
{
|
|
$expected = "This string contains < & >.";
|
|
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData()));
|
|
}
|
|
|
|
/**
|
|
* @covers XML_Util::reverseEntities()
|
|
*/
|
|
public function testReverseEntitiesForSimpleDataWithInvalidOptionReturnsOriginalData()
|
|
{
|
|
$expected = "This string contains < & >.";
|
|
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), 'INVALID_OPTION'));
|
|
}
|
|
|
|
/**
|
|
* @covers XML_Util::reverseEntities()
|
|
*/
|
|
public function testReverseEntitiesForSimpleDataWithEntitiesXml()
|
|
{
|
|
$expected = "This string contains < & >.";
|
|
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML));
|
|
}
|
|
|
|
/**
|
|
* @covers XML_Util::reverseEntities()
|
|
*/
|
|
public function testReverseEntitiesForSimpleDataWithEntitiesXmlAndEncoding()
|
|
{
|
|
$encoding = "UTF-8";
|
|
$expected = "This string contains < & >.";
|
|
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML), $encoding);
|
|
}
|
|
|
|
/**
|
|
* @covers XML_Util::reverseEntities()
|
|
*/
|
|
public function testReverseEntitiesForUtf8DataWithEntitiesXmlAndEncoding()
|
|
{
|
|
$encoding = "UTF-8";
|
|
$expected = "This data contains special chars like <, >, & and \" as well as ä, ö, ß, à and ê";
|
|
$this->assertEquals($expected, XML_Util::reverseEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_XML), $encoding);
|
|
}
|
|
|
|
/**
|
|
* @covers XML_Util::reverseEntities()
|
|
*/
|
|
public function testReverseEntitiesForSimpleDataWithEntitiesXmlRequired()
|
|
{
|
|
$expected = "This string contains < & >.";
|
|
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML_REQUIRED));
|
|
}
|
|
|
|
/**
|
|
* @covers XML_Util::reverseEntities()
|
|
*/
|
|
public function testReverseEntitiesForSimpleDataWithEntitiesXmlRequiredAndEncoding()
|
|
{
|
|
$encoding = "UTF-8";
|
|
$expected = "This string contains < & >.";
|
|
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_XML_REQUIRED, $encoding));
|
|
}
|
|
|
|
/**
|
|
* @covers XML_Util::reverseEntities()
|
|
*/
|
|
public function testReverseEntitiesForUtf8DataWithEntitiesXmlRequiredAndEncoding()
|
|
{
|
|
$encoding = "UTF-8";
|
|
$expected = "This data contains special chars like <, >, & and \" as well as ä, ö, ß, à and ê";
|
|
$this->assertEquals($expected, XML_Util::reverseEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_XML_REQUIRED, $encoding));
|
|
}
|
|
|
|
/**
|
|
* @covers XML_Util::reverseEntities()
|
|
*/
|
|
public function testReverseEntitiesForSimpleDataWithEntitiesHtml()
|
|
{
|
|
$expected = "This string contains < & >.";
|
|
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_HTML));
|
|
}
|
|
|
|
/**
|
|
* @covers XML_Util::reverseEntities()
|
|
*/
|
|
public function testReverseEntitiesForSimpleDataWithEntitiesHtmlAndEncoding()
|
|
{
|
|
$encoding = "UTF-8";
|
|
$expected = "This string contains < & >.";
|
|
$this->assertEquals($expected, XML_Util::reverseEntities($this->getSimpleData(), XML_UTIL_ENTITIES_HTML, $encoding));
|
|
}
|
|
|
|
/**
|
|
* @covers XML_Util::reverseEntities()
|
|
*/
|
|
public function testReverseEntitiesForUtf8DataWithEntitiesHtmlAndEncoding()
|
|
{
|
|
$encoding = "UTF-8";
|
|
$expected = "This data contains special chars like <, >, & and \" as well as ä, ö, ß, à and ê";
|
|
$this->assertEquals($expected, XML_Util::reverseEntities($this->getUtf8Data(), XML_UTIL_ENTITIES_HTML, $encoding));
|
|
}
|
|
}
|