blob: 997a342a4ecac53e5a31d24ae66bea63ec9c248a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
<?php
/**
* Smarty PHPunit tests variable variables
*
* @author Uwe Tews
*/
/**
* class for variable variables tests
*
*
*
*
*/
class VariableVariableTest extends PHPUnit_Smarty
{
public function setUp(): void
{
$this->setUpSmarty(__DIR__);
}
public function testInit()
{
$this->cleanDirs();
}
/**
* test variable name in variable
*/
public function testVariableVariable1()
{
$tpl = $this->smarty->createTemplate('eval:{$foo=\'bar\'}{$bar=123}{${$foo}}');
$this->assertEquals('123', $this->smarty->fetch($tpl));
}
/**
* test part of variable name in variable
*/
public function testVariableVariable2()
{
$tpl = $this->smarty->createTemplate('eval:{$foo=\'a\'}{$bar=123}{$b{$foo}r}');
$this->assertEquals('123', $this->smarty->fetch($tpl));
}
/**
* test several parts of variable name in variable
*/
public function testVariableVariable3()
{
$tpl = $this->smarty->createTemplate('eval:{$foo=\'a\'}{$foo2=\'r\'}{$bar=123}{$b{$foo}{$foo2}}');
$this->assertEquals('123', $this->smarty->fetch($tpl));
}
/**
* test nesed parts of variable name in variable
*/
public function testVariableVariable4()
{
$tpl = $this->smarty->createTemplate('eval:{$foo=\'ar\'}{$foo2=\'oo\'}{$bar=123}{$b{$f{$foo2}}}');
$this->assertEquals('123', $this->smarty->fetch($tpl));
}
}
|