public function setUp() { parent::setUp(); $this->smarty->security_policy = null; \Box\Brainy\Brainy::$assignment_compat = \Box\Brainy\Brainy::ASSIGN_COMPAT; $this->smarty->error_reporting = error_reporting() & ~(E_NOTICE | E_USER_NOTICE); }
public function setUp() { $this->smarty = new \Box\Brainy\Brainy(); $this->setUpInstance($this->smarty); $this->smartyBC = new \Box\Brainy\SmartyBC(); $this->setUpInstance($this->smartyBC); \Box\Brainy\Brainy::$default_assign_scope = \Box\Brainy\Brainy::SCOPE_LOCAL; \Box\Brainy\Brainy::$enforce_expression_modifiers = array(); \Box\Brainy\Brainy::$global_tpl_vars = array(); \Box\Brainy\Resources\Resource::reset(); $this->clearFiles(); parent::setUp(); }
public static function _init($smarty) { \Box\Brainy\Brainy::$enforce_expression_modifiers = array(); $smarty->setTemplateDir(realpath('test' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR)); $smarty->setCompileDir(realpath('test' . DIRECTORY_SEPARATOR . 'compiled' . DIRECTORY_SEPARATOR)); $smarty->setPluginsDir(SMARTY_PLUGINS_DIR); $smarty->template_objects = array(); \Box\Brainy\Brainy::$global_tpl_vars = array(); $smarty->template_functions = array(); $smarty->tpl_vars = array(); $smarty->force_compile = false; $smarty->auto_literal = true; $smarty->registered_plugins = array(); $smarty->default_modifiers = array(); $smarty->escape_html = false; $smarty->use_sub_dirs = false; $smarty->security_policy = null; $smarty->left_delimiter = '{'; $smarty->right_delimiter = '}'; $smarty->enableSecurity(); $smarty->error_unassigned = false; $smarty->compile_id = null; $smarty->safe_lookups = \Box\Brainy\Brainy::LOOKUP_UNSAFE; }
public function testRootScopeGivesAccessToVarsForCapture() { \Box\Brainy\Brainy::$default_assign_scope = \Box\Brainy\Brainy::SCOPE_ROOT; $this->smarty->fetch('eval:{capture assign="foo"}captured{/capture}'); $this->assertEquals($this->smarty->getTemplateVars('foo'), 'captured', 'Should have access to vars'); }
/** * @dataProvider dataProviderSwitch */ public function testMultipleStripsAroundCapture($x, $result, $modifiers) { \Box\Brainy\Brainy::$enforce_expression_modifiers = $modifiers; $this->smarty->assign('x', $x); $this->assertEquals($result, $this->smarty->fetch('eval:{strip}{strip}{capture assign="foo"}{if $x && true}success{else}fail{/if}{/capture}<{$foo|escape}>{/strip}{/strip}')); }
public function testTernaryStatic() { $this->expectOutputString('x'); \Box\Brainy\Brainy::$enforce_expression_modifiers = array('escape'); $this->smarty->display('eval:{(true)?"x":"y"}'); }
/** * @dataProvider failing_example_provider * @expectedException BrainyModifierEnforcementException */ public function testFailingExamples($example, $modifiers) { $this->smarty->assign('integer', 123); \Box\Brainy\Brainy::$enforce_expression_modifiers = $modifiers; $this->smarty->display('eval:' . $example); }