This repository has been archived by the owner on Jan 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2020 from fvovan/issue-2019
add 'needed' param to smarty.load
- Loading branch information
Showing
2 changed files
with
48 additions
and
4 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,38 @@ | ||
<?php | ||
|
||
require_once CM_Util::getModulePath('CM') . 'library/CM/SmartyPlugins/function.load.php'; | ||
|
||
class smarty_function_loadTest extends CMTest_TestCase { | ||
|
||
/** | ||
* @var Smarty_Internal_Template | ||
*/ | ||
private $_template; | ||
|
||
public function setUp() { | ||
$smarty = new Smarty(); | ||
$render = new CM_Frontend_Render(); | ||
$this->_template = $smarty->createTemplate('string:'); | ||
$this->_template->assignGlobal('render', $render); | ||
} | ||
|
||
public function testRender() { | ||
$paramsFail = array( | ||
'file' => 'badFileName.tpl', | ||
); | ||
|
||
$exception = $this->catchException(function () use ($paramsFail) { | ||
smarty_function_load($paramsFail, $this->_template); | ||
}); | ||
|
||
$this->assertInstanceOf('CM_Exception_Invalid', $exception); | ||
$this->assertSame('Cannot find `badFileName.tpl` in modules `CM` and themes `default`', $exception->getMessage()); | ||
|
||
$paramsPass = array( | ||
'file' => 'badFileName.tpl', | ||
'needed' => false, | ||
); | ||
|
||
$this->assertSame('', smarty_function_load($paramsPass, $this->_template)); | ||
} | ||
} |