* Used ENT_DISALLOWED when escaping a string. * Added workaround for environments where ENT_DISALLOWED is not defined
43 lines
999 B
PHP
43 lines
999 B
PHP
<?php
|
|
|
|
namespace Box\Spout\Common\Escaper;
|
|
|
|
/**
|
|
* Class ODSTest
|
|
*
|
|
* @package Box\Spout\Common\Escaper
|
|
*/
|
|
class ODSTest extends \PHPUnit_Framework_TestCase
|
|
{
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function dataProviderForTestEscape()
|
|
{
|
|
return [
|
|
['test', 'test'],
|
|
['carl\'s "pokemon"', 'carl's "pokemon"'],
|
|
["\n", "\n"],
|
|
["\r", "\r"],
|
|
["\t", "\t"],
|
|
["\v", "�"],
|
|
["\f", "�"],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider dataProviderForTestEscape
|
|
*
|
|
* @param string $stringToEscape
|
|
* @param string $expectedEscapedString
|
|
* @return void
|
|
*/
|
|
public function testEscape($stringToEscape, $expectedEscapedString)
|
|
{
|
|
$escaper = \Box\Spout\Common\Escaper\ODS::getInstance();
|
|
$escapedString = $escaper->escape($stringToEscape);
|
|
|
|
$this->assertEquals($expectedEscapedString, $escapedString, 'Incorrect escaped string');
|
|
}
|
|
}
|