Finish 4.13.2

This commit is contained in:
4Giedrius committed 2015-01-21 14:40:48 +02:00
commit 349cc38ea9
3 files changed
+30 -6

No files matched your search

+1 -1
View File
@@ -71,7 +71,7 @@ class Payment_Adapter_Custom
'_tpl' => ($subscription) ? $this->config['recurrent'] : $this->config['single'],
);
$systemService = $this->di['mod_service']('System');
return $systemService->renderString($vars['_tpl'], false, $vars);
return $systemService->renderString($vars['_tpl'], true, $vars);
}
public function process($tx)
+1 -5
View File
@@ -313,11 +313,7 @@ class Service
$parsed = $template->render($vars);
} catch (\Exception $e) {
$parsed = $tpl;
if ($e instanceof \Twig_Error_Syntax || $e instanceof \Twig_Error_Loader) {
if (!$try_render) {
throw $e;
}
} else {
if (!$try_render) {
throw $e;
}
}
+28
View File
@@ -282,6 +282,34 @@ class ServiceTest extends \PHPUnit_Framework_TestCase {
$this->service->renderString('test', false, $vars);
}
public function testrenderStringTemplate()
{
$vars = array(
'_client_id' => 1
);
$twigMock = $this->getMockBuilder('\Twig_Environment')->disableOriginalConstructor()->getMock();
$twigMock->expects($this->atLeastOnce())
->method('addGlobal');
$twigMock->expects($this->atLeastOnce())
->method('loadTemplate')
->willThrowException(new \Twig_Error_Syntax('Exception created with PHPUNIT'));
$dbMock = $this->getMockBuilder('\Box_Database')->getMock();
$dbMock->expects($this->atLeastOnce())
->method('load')
->will($this->returnValue(new \Model_Client()));
$di = new \Box_Di();
$di['db'] = $dbMock;
$di['twig'] = $twigMock;
$di['api_client'] = new \Model_Client();
$this->service->setDi($di);
$string = $this->service->renderString('test', true, $vars);
$this->assertEquals($string, 'test');
}
public function testclearCache()
{
$toolsMock = $this->getMockBuilder('\Box_Tools')->getMock();