-
Notifications
You must be signed in to change notification settings - Fork 716
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'support/4.3' into warn_when_using_unregistered_function
- Loading branch information
Showing
12 changed files
with
125 additions
and
12 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
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
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
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
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 |
---|---|---|
|
@@ -30,4 +30,36 @@ public function testAutoEscape() | |
$tpl->assign('foo', '<[email protected]>'); | ||
$this->assertEquals("<[email protected]>", $this->smarty->fetch($tpl)); | ||
} | ||
|
||
|
||
/** | ||
* test 'escapeHtml' property | ||
* @group issue906 | ||
*/ | ||
public function testAutoEscapeDoesNotEscapeFunctionPlugins() | ||
{ | ||
$this->smarty->registerPlugin( | ||
Smarty::PLUGIN_FUNCTION, | ||
'horizontal_rule', | ||
function ($params, $smarty) { return "<hr>"; } | ||
); | ||
$tpl = $this->smarty->createTemplate('eval:{horizontal_rule}'); | ||
$this->assertEquals("<hr>", $this->smarty->fetch($tpl)); | ||
} | ||
|
||
/** | ||
* test 'escapeHtml' property | ||
* @group issue906 | ||
*/ | ||
public function testAutoEscapeDoesNotEscapeBlockPlugins() | ||
{ | ||
$this->smarty->registerPlugin( | ||
Smarty::PLUGIN_BLOCK, | ||
'paragraphify', | ||
function ($params, $content) { return $content == null ? null : "<p>".$content."</p>"; } | ||
); | ||
$tpl = $this->smarty->createTemplate('eval:{paragraphify}hi{/paragraphify}'); | ||
$this->assertEquals("<p>hi</p>", $this->smarty->fetch($tpl)); | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStripTagsTest.php
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,46 @@ | ||
<?php | ||
/** | ||
* Smarty PHPunit tests of modifier | ||
*/ | ||
|
||
namespace UnitTests\TemplateSource\TagTests\PluginModifier; | ||
use PHPUnit_Smarty; | ||
|
||
/** | ||
* class for modifier tests | ||
* | ||
* @runTestsInSeparateProcess | ||
* @preserveGlobalState disabled | ||
* @backupStaticAttributes enabled | ||
*/ | ||
class PluginModifierStripTagsTest extends PHPUnit_Smarty { | ||
|
||
public function setUp(): void { | ||
$this->setUpSmarty(__DIR__); | ||
} | ||
|
||
public function testDefault() { | ||
$tpl = $this->smarty->createTemplate('string:{$x|strip_tags}'); | ||
$tpl->assign('x', '<b>hi</b>'); | ||
$this->assertEquals(" hi ", $this->smarty->fetch($tpl)); | ||
} | ||
|
||
public function testParam1() { | ||
$tpl = $this->smarty->createTemplate('string:{$x|strip_tags:false}'); | ||
$tpl->assign('x', '<b>hi</b>'); | ||
$this->assertEquals("hi", $this->smarty->fetch($tpl)); | ||
} | ||
|
||
public function testInputIsFalsy0() { | ||
$tpl = $this->smarty->createTemplate('string:{$x|strip_tags}'); | ||
$tpl->assign('x', 0); | ||
$this->assertEquals("0", $this->smarty->fetch($tpl)); | ||
} | ||
|
||
public function testInputIsFalsy1() { | ||
$tpl = $this->smarty->createTemplate('string:{$x|strip_tags}'); | ||
$tpl->assign('x', ''); | ||
$this->assertEquals("", $this->smarty->fetch($tpl)); | ||
} | ||
|
||
} |
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