-
Notifications
You must be signed in to change notification settings - Fork 715
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throw deprecation notice about unregistered functions without changin…
- Loading branch information
Showing
2 changed files
with
79 additions
and
11 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
67 changes: 67 additions & 0 deletions
67
tests/UnitTests/TemplateSource/_Issues/ArgumentMustBePassedByReference961Test.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,67 @@ | ||
<?php | ||
|
||
class ArgumentMustBePassedByReference961Test extends PHPUnit_Smarty | ||
{ | ||
|
||
/** | ||
* @group issue961 | ||
*/ | ||
public function testReset() | ||
{ | ||
$smarty = new Smarty(); | ||
$smarty->registerPlugin('modifier', 'reset', 'reset'); | ||
$templateStr = "string:{reset(\$ar)}"; | ||
$smarty->assign('ar', [1,2,3]); | ||
$this->assertEquals( | ||
'1', | ||
$smarty->fetch($templateStr) | ||
); | ||
} | ||
|
||
/** | ||
* @group issue961 | ||
* @deprecated | ||
*/ | ||
public function testResetAsModifier() | ||
{ | ||
$smarty = new Smarty(); | ||
try { | ||
$templateStr = "string:{\$ar|reset}"; | ||
$smarty->assign('ar', [1,2,3]); | ||
$this->assertEquals( | ||
'1', | ||
$smarty->fetch($templateStr) | ||
); | ||
} catch (Exception $e) { | ||
} | ||
} | ||
|
||
/** | ||
* @group issue961 | ||
*/ | ||
public function testResetInExpression() | ||
{ | ||
$smarty = new Smarty(); | ||
$smarty->registerPlugin('modifier', 'reset', 'reset'); | ||
$templateStr = "string:{if reset(\$ar)}ok{/if}"; | ||
$smarty->assign('ar', [1,2,3]); | ||
$this->assertEquals( | ||
'ok', | ||
$smarty->fetch($templateStr) | ||
); | ||
} | ||
|
||
/** | ||
* @group issue961 | ||
*/ | ||
public function testMatch() | ||
{ | ||
$smarty = new Smarty(); | ||
$smarty->registerPlugin('modifier', 'preg_match', 'preg_match'); | ||
$templateStr = 'string:{assign var="match" value=null}{if preg_match(\'/([a-z]{4})/\', "a test", $match)}{$match.1}{/if}'; | ||
$this->assertEquals( | ||
'test', | ||
$smarty->fetch($templateStr) | ||
); | ||
} | ||
} |