|
|
@@ -18,6 +18,8 @@ class CompileAssignTest extends PHPUnit_Smarty
|
|
|
|
public function setUp()
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->setUpSmarty(dirname(__FILE__));
|
|
|
|
$this->setUpSmarty(dirname(__FILE__));
|
|
|
|
|
|
|
|
$this->smarty->addPluginsDir("./PHPunitplugins/");
|
|
|
|
|
|
|
|
$this->smarty->registerFilter('pre', array($this, 'prefilterTest'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testInit()
|
|
|
|
public function testInit()
|
|
|
@@ -34,9 +36,6 @@ class CompileAssignTest extends PHPUnit_Smarty
|
|
|
|
public function testAssignOld_001()
|
|
|
|
public function testAssignOld_001()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->assertEquals("1", $this->smarty->fetch('001_oldFormat_1.tpl'));
|
|
|
|
$this->assertEquals("1", $this->smarty->fetch('001_oldFormat_1.tpl'));
|
|
|
|
$this->assertEquals("1", $this->smarty->fetch('001_oldFormat_2.tpl'));
|
|
|
|
|
|
|
|
$this->assertEquals("1", $this->smarty->fetch('002_oldFormat_1.tpl'));
|
|
|
|
|
|
|
|
$this->assertEquals("1", $this->smarty->fetch('003_oldFormat_1.tpl'));
|
|
|
|
|
|
|
|
$this->assertEquals("bar", $this->smarty->fetch('004_oldFormat_1.tpl'));
|
|
|
|
$this->assertEquals("bar", $this->smarty->fetch('004_oldFormat_1.tpl'));
|
|
|
|
$this->assertEquals("3", $this->smarty->fetch('005_oldFormat_1.tpl'));
|
|
|
|
$this->assertEquals("3", $this->smarty->fetch('005_oldFormat_1.tpl'));
|
|
|
|
$this->assertEquals("3", $this->smarty->fetch('006_oldFormat_1.tpl'));
|
|
|
|
$this->assertEquals("3", $this->smarty->fetch('006_oldFormat_1.tpl'));
|
|
|
@@ -88,9 +87,9 @@ class CompileAssignTest extends PHPUnit_Smarty
|
|
|
|
public function testAssignArrayAppend_002()
|
|
|
|
public function testAssignArrayAppend_002()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->smarty->assign('foo', 1);
|
|
|
|
$this->smarty->assign('foo', 1);
|
|
|
|
$tpl = $this->smarty->createTemplate('002_newAppend_1.tpl', null, null, $this->smarty);
|
|
|
|
$tpl = $this->smarty->createTemplate('002_newAppend_1.tpl', null, null, $this->smarty, false);
|
|
|
|
$this->assertEquals("0112", $this->smarty->fetch($tpl));
|
|
|
|
$this->assertEquals("0112", $this->smarty->fetch($tpl));
|
|
|
|
$tpl2 = $this->smarty->createTemplate('002_newAppend_2.tpl', null, null, $this->smarty);
|
|
|
|
$tpl2 = $this->smarty->createTemplate('002_newAppend_2.tpl', null, null, $this->smarty, false);
|
|
|
|
$this->assertEquals("1", $this->smarty->fetch($tpl2));
|
|
|
|
$this->assertEquals("1", $this->smarty->fetch($tpl2));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -103,9 +102,9 @@ class CompileAssignTest extends PHPUnit_Smarty
|
|
|
|
public function testAssignArrayAppend_003()
|
|
|
|
public function testAssignArrayAppend_003()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->smarty->assign('foo', 1);
|
|
|
|
$this->smarty->assign('foo', 1);
|
|
|
|
$tpl = $this->smarty->createTemplate('003_newAppend_1.tpl', null, null, $this->smarty);
|
|
|
|
$tpl = $this->smarty->createTemplate('003_newAppend_1.tpl', null, null, $this->smarty, false);
|
|
|
|
$this->assertEquals("0112", $this->smarty->fetch($tpl));
|
|
|
|
$this->assertEquals("0112", $this->smarty->fetch($tpl));
|
|
|
|
$tpl2 = $this->smarty->createTemplate('003_newAppend_2.tpl', null, null, $this->smarty);
|
|
|
|
$tpl2 = $this->smarty->createTemplate('003_newAppend_2.tpl', null, null, $this->smarty, false);
|
|
|
|
$this->assertEquals("0112", $this->smarty->fetch($tpl2));
|
|
|
|
$this->assertEquals("0112", $this->smarty->fetch($tpl2));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -119,4 +118,153 @@ class CompileAssignTest extends PHPUnit_Smarty
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->assertEquals("1", $this->smarty->fetch('004_newNested_1.tpl'));
|
|
|
|
$this->assertEquals("1", $this->smarty->fetch('004_newNested_1.tpl'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* test no scope
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @runInSeparateProcess
|
|
|
|
|
|
|
|
* @preserveGlobalState disabled
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function testAssignNone_001()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->smarty->assign('foo', 'smarty');
|
|
|
|
|
|
|
|
$this->smarty->assign('include', '001_scope_none_1.tpl');
|
|
|
|
|
|
|
|
$this->smarty->assignGlobal('foo', 'global');
|
|
|
|
|
|
|
|
$data = $this->smarty->createData($this->smarty);
|
|
|
|
|
|
|
|
$data->assign('foo', 'data');
|
|
|
|
|
|
|
|
$tpl = $this->smarty->createTemplate('001_scope_root.tpl', $data);
|
|
|
|
|
|
|
|
$this->assertContains("template 001_scope_none_1.tpl:var =none\ntemplate 001_scope_include.tpl:var =data\ntemplate 001_scope_root.tpl:var =data\ndata:var =data\nSmarty:var =smarty\nglobal:var =global\n",
|
|
|
|
|
|
|
|
$tpl->fetch());
|
|
|
|
|
|
|
|
$this->smarty->assign('include', '001_scope_none_2.tpl');
|
|
|
|
|
|
|
|
$this->assertContains("template 001_scope_none_2.tpl:var =none\ntemplate 001_scope_include.tpl:var =data\ntemplate 001_scope_root.tpl:var =data\ndata:var =data\nSmarty:var =smarty\nglobal:var =global\n",
|
|
|
|
|
|
|
|
$tpl->fetch());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* test scope parent
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @runInSeparateProcess
|
|
|
|
|
|
|
|
* @preserveGlobalState disabled
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function testAssignParent_001()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->smarty->assign('foo', 'smarty');
|
|
|
|
|
|
|
|
$this->smarty->assign('include', '001_scope_parent_1.tpl');
|
|
|
|
|
|
|
|
$this->smarty->assignGlobal('foo', 'global');
|
|
|
|
|
|
|
|
$data = $this->smarty->createData($this->smarty);
|
|
|
|
|
|
|
|
$data->assign('foo', 'data');
|
|
|
|
|
|
|
|
$tpl = $this->smarty->createTemplate('001_scope_root.tpl', null, null, $data, false);
|
|
|
|
|
|
|
|
$this->assertContains("template 001_scope_parent_1.tpl:var =parent\ntemplate 001_scope_include.tpl:var =parent\ntemplate 001_scope_root.tpl:var =data\ndata:var =data\nSmarty:var =smarty\nglobal:var =global\n",
|
|
|
|
|
|
|
|
$tpl->fetch());
|
|
|
|
|
|
|
|
$this->smarty->assign('include', '001_scope_parent_2.tpl');
|
|
|
|
|
|
|
|
$this->assertContains("template 001_scope_parent_2.tpl:var =parent\ntemplate 001_scope_include.tpl:var =parent\ntemplate 001_scope_root.tpl:var =data\ndata:var =data\nSmarty:var =smarty\nglobal:var =global\n",
|
|
|
|
|
|
|
|
$tpl->fetch());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* test scope tpl_root
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @runInSeparateProcess
|
|
|
|
|
|
|
|
* @preserveGlobalState disabled
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function testAssignTplRoot_001()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->smarty->assign('foo', 'smarty');
|
|
|
|
|
|
|
|
$this->smarty->assign('include', '001_scope_tpl_root_1.tpl');
|
|
|
|
|
|
|
|
$this->smarty->assignGlobal('foo', 'global');
|
|
|
|
|
|
|
|
$data = $this->smarty->createData($this->smarty);
|
|
|
|
|
|
|
|
$data->assign('foo', 'data');
|
|
|
|
|
|
|
|
$tpl = $this->smarty->createTemplate('001_scope_root.tpl', null, null, $data, false);
|
|
|
|
|
|
|
|
$this->assertContains("template 001_scope_tpl_root_1.tpl:var =tpl_root\ntemplate 001_scope_include.tpl:var =tpl_root\ntemplate 001_scope_root.tpl:var =tpl_root\ndata:var =data\nSmarty:var =smarty\nglobal:var =global\n",
|
|
|
|
|
|
|
|
$tpl->fetch());
|
|
|
|
|
|
|
|
$this->smarty->assign('include', '001_scope_tpl_root_2.tpl');
|
|
|
|
|
|
|
|
$this->assertContains("template 001_scope_tpl_root_2.tpl:var =tpl_root\ntemplate 001_scope_include.tpl:var =tpl_root\ntemplate 001_scope_root.tpl:var =tpl_root\ndata:var =data\nSmarty:var =smarty\nglobal:var =global\n",
|
|
|
|
|
|
|
|
$tpl->fetch());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* test scope root
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @runInSeparateProcess
|
|
|
|
|
|
|
|
* @preserveGlobalState disabled
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function testAssignRoot_001()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->smarty->assign('foo', 'smarty');
|
|
|
|
|
|
|
|
$this->smarty->assign('include', '001_scope_root_1.tpl');
|
|
|
|
|
|
|
|
$this->smarty->assignGlobal('foo', 'global');
|
|
|
|
|
|
|
|
$data = $this->smarty->createData($this->smarty);
|
|
|
|
|
|
|
|
$data->assign('foo', 'data');
|
|
|
|
|
|
|
|
$tpl = $this->smarty->createTemplate('001_scope_root.tpl', null, null, $data, false);
|
|
|
|
|
|
|
|
$this->assertContains("template 001_scope_root_1.tpl:var =root\ntemplate 001_scope_include.tpl:var =root\ntemplate 001_scope_root.tpl:var =root\ndata:var =root\nSmarty:var =root\nglobal:var =global\n",
|
|
|
|
|
|
|
|
$tpl->fetch());
|
|
|
|
|
|
|
|
$this->smarty->assign('include', '001_scope_root_2.tpl');
|
|
|
|
|
|
|
|
$this->smarty->assign('foo', 'smarty');
|
|
|
|
|
|
|
|
$data->assign('foo', 'data');
|
|
|
|
|
|
|
|
$this->assertContains("template 001_scope_root_2.tpl:var =root\ntemplate 001_scope_include.tpl:var =root\ntemplate 001_scope_root.tpl:var =root\ndata:var =root\nSmarty:var =root\nglobal:var =global\n",
|
|
|
|
|
|
|
|
$tpl->fetch());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* test scope root data object
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @runInSeparateProcess
|
|
|
|
|
|
|
|
* @preserveGlobalState disabled
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function testAssignRoot_002()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->smarty->assign('foo', 'smarty');
|
|
|
|
|
|
|
|
$this->smarty->assignGlobal('foo', 'global');
|
|
|
|
|
|
|
|
$data = $this->smarty->createData();
|
|
|
|
|
|
|
|
$data->assign('foo', 'data');
|
|
|
|
|
|
|
|
$data->assign('include', '001_scope_root_1.tpl');
|
|
|
|
|
|
|
|
$tpl = $this->smarty->createTemplate('001_scope_root.tpl', null, null, $data, false);
|
|
|
|
|
|
|
|
$this->assertContains("template 001_scope_root_1.tpl:var =root\ntemplate 001_scope_include.tpl:var =root\ntemplate 001_scope_root.tpl:var =root\ndata:var =root\nSmarty:var =smarty\nglobal:var =global\n",
|
|
|
|
|
|
|
|
$tpl->fetch());
|
|
|
|
|
|
|
|
$this->smarty->assign('foo', 'smarty');
|
|
|
|
|
|
|
|
$data->assign('foo', 'data');
|
|
|
|
|
|
|
|
$data->assign('include', '001_scope_root_2.tpl');
|
|
|
|
|
|
|
|
$this->assertContains("template 001_scope_root_2.tpl:var =root\ntemplate 001_scope_include.tpl:var =root\ntemplate 001_scope_root.tpl:var =root\ndata:var =root\nSmarty:var =smarty\nglobal:var =global\n",
|
|
|
|
|
|
|
|
$tpl->fetch());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* test scope global
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @runInSeparateProcess
|
|
|
|
|
|
|
|
* @preserveGlobalState disabled
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function testAssignGlobal_001()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->smarty->assign('include', '001_scope_global_1.tpl');
|
|
|
|
|
|
|
|
$this->smarty->assignGlobal('foo', 'global');
|
|
|
|
|
|
|
|
$data = $this->smarty->createData($this->smarty);
|
|
|
|
|
|
|
|
$tpl = $this->smarty->createTemplate('001_scope_root.tpl', null, null, $data, false);
|
|
|
|
|
|
|
|
$this->assertContains("template 001_scope_global_1.tpl:var =new global\ntemplate 001_scope_include.tpl:var =new global\ntemplate 001_scope_root.tpl:var =new global\ndata:var =null\nSmarty:var =null\nglobal:var =new global\n",
|
|
|
|
|
|
|
|
$tpl->fetch());
|
|
|
|
|
|
|
|
$this->smarty->assign('include', '001_scope_global_2.tpl');
|
|
|
|
|
|
|
|
$this->assertContains("template 001_scope_global_2.tpl:var =new global\ntemplate 001_scope_include.tpl:var =new global\ntemplate 001_scope_root.tpl:var =new global\ndata:var =null\nSmarty:var =null\nglobal:var =new global\n",
|
|
|
|
|
|
|
|
$tpl->fetch());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* test scope global
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @runInSeparateProcess
|
|
|
|
|
|
|
|
* @preserveGlobalState disabled
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function testAssignGlobal_002()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->smarty->assign('foo', 'smarty');
|
|
|
|
|
|
|
|
$this->smarty->assign('include', '001_scope_global_1.tpl');
|
|
|
|
|
|
|
|
$this->smarty->assignGlobal('foo', 'global');
|
|
|
|
|
|
|
|
$data = $this->smarty->createData($this->smarty);
|
|
|
|
|
|
|
|
$tpl = $this->smarty->createTemplate('001_scope_root.tpl', null, null, $data, false);
|
|
|
|
|
|
|
|
$this->assertContains("template 001_scope_global_1.tpl:var =new global\ntemplate 001_scope_include.tpl:var =smarty\ntemplate 001_scope_root.tpl:var =smarty\ndata:var =null\nSmarty:var =smarty\nglobal:var =new global\n",
|
|
|
|
|
|
|
|
$tpl->fetch());
|
|
|
|
|
|
|
|
$this->smarty->assign('include', '001_scope_global_2.tpl');
|
|
|
|
|
|
|
|
$this->smarty->assign('foo', 'smarty');
|
|
|
|
|
|
|
|
$this->assertContains("template 001_scope_global_2.tpl:var =new global\ntemplate 001_scope_include.tpl:var =smarty\ntemplate 001_scope_root.tpl:var =smarty\ndata:var =null\nSmarty:var =smarty\nglobal:var =new global\n",
|
|
|
|
|
|
|
|
$tpl->fetch());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|