-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
192 additions
and
130 deletions.
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,53 @@ | ||
<?php | ||
/** | ||
* @author Gabriel Zerbib <gabriel@figdice.org> | ||
* @copyright 2004-2015, Gabriel Zerbib. | ||
* @version 2.1.2 | ||
* @package FigDice | ||
* | ||
* This file is part of FigDice. | ||
* http://figdice.org/ | ||
*/ | ||
|
||
use figdice\Filter; | ||
use figdice\View; | ||
|
||
class FilterTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function testSpecialHTMLCharacterInFigTextIsNotAltered() | ||
{ | ||
$view = new View(); | ||
$view->loadString( | ||
'<test><span fig:text="/data"/></test>' | ||
); | ||
$view->mount('data', '<TAG>'); | ||
$this->assertEquals('<test><span><TAG></span></test>', $view->render()); | ||
} | ||
|
||
public function testSpecialHTMLCharacterAfterFilter() | ||
{ | ||
$view = new View(); | ||
$view->loadString( | ||
'<test><span fig:text="/data" fig:filter="EscapeHtmlFilter"/></test>' | ||
); | ||
$view->mount('data', '<TAG>'); | ||
$this->assertEquals('<test><span><TAG></span></test>', $view->render()); | ||
} | ||
} | ||
|
||
class EscapeHtmlFilter implements Filter | ||
{ | ||
|
||
/** | ||
* Operates the transform on the input string, | ||
* returns the filtered output. | ||
* This test filter simply performs php's native HTML escapes. | ||
* | ||
* @param string $buffer | ||
* @return string | ||
*/ | ||
public function transform($buffer) | ||
{ | ||
return htmlspecialchars($buffer); | ||
} | ||
} |
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