-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Used ENT_DISALLOWED when escaping a string. * Added workaround for environments where ENT_DISALLOWED is not defined
- Loading branch information
Showing
2 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?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'); | ||
} | ||
} |