-
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…
…g the compilation flow. Fixes #964
- Loading branch information
Showing
2 changed files
with
86 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
74 changes: 74 additions & 0 deletions
74
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,74 @@ | ||
<?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(); | ||
|
||
// $previousErrorReporting = $smarty->error_reporting; | ||
// $smarty->setErrorReporting($previousErrorReporting | E_USER_DEPRECATED); | ||
// $smarty->registerPlugin('modifier', 'reset', 'reset'); | ||
// $this->expectDeprecation(); | ||
try { | ||
$templateStr = "string:{\$ar|reset}"; | ||
$smarty->assign('ar', [1,2,3]); | ||
$this->assertEquals( | ||
'1', | ||
$smarty->fetch($templateStr) | ||
); | ||
} catch (Exception $e) { | ||
} | ||
|
||
// $smarty->setErrorReporting($previousErrorReporting); | ||
} | ||
|
||
/** | ||
* @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) | ||
); | ||
} | ||
} |