summaryrefslogtreecommitdiff
path: root/tests/UnitTests/Compiler/Delimiter/UserLiteralTest.php
blob: 70873a89cd285dfc54cacecc2175355562f5fcea (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
64
<?php
/**
 * Smarty PHPunit tests of delimiter
 *

 * @author  Uwe Tews
 */

/**
 * class for delimiter tests
 *
 * 
 * 
 * 
 */
class UserliteralTest extends PHPUnit_Smarty
{
    public function setUp(): void
    {
        $this->setUpSmarty(__DIR__);
    }


    public function testUserLiteral()
    {
        $this->smarty->setAutoLiteral(true);
        $this->assertEquals('{{ 1 }}', $this->smarty->fetch('userliteral.tpl'));
    }
    public function testUserLiteral1()
    {
        $this->smarty->setAutoLiteral(false);
        $this->smarty->setCompileId(1);
        $this->assertEquals('1', $this->smarty->fetch('userliteral.tpl'));
    }
    public function testUserLiteral2()
    {
        $this->smarty->setAutoLiteral(false);
        $this->smarty->setLiterals(array('{{','}}'));
        $this->assertEquals('{{1}}', $this->smarty->fetch('userliteral1.tpl'));
    }
    public function testUserLiteral3()
    {
        $this->smarty->setAutoLiteral(false);
        $this->smarty->setLeftDelimiter('<-');
        $this->smarty->setRightDelimiter('->');
        $this->smarty->setLiterals(array('<--','-->'));
        $this->assertEquals('1 <--1-->', $this->smarty->fetch('userliteral2.tpl'));
    }
    public function testUserLiteral4()
    {
        $this->smarty->setAutoLiteral(true);
        $this->smarty->setLeftDelimiter('<-');
        $this->smarty->setRightDelimiter('->');
        $this->smarty->setCompileId(1);
        $this->smarty->setLiterals(array('<--','-->'));
        $this->assertEquals('<- 1 -> <--1-->', $this->smarty->fetch('userliteral2.tpl'));
    }
    public function testUserLiteral5()
    {
        $this->smarty->setAutoLiteral(true);
        $this->smarty->setLiterals(array('{%'));
        $this->assertEquals(' output: double {%counter} quote', $this->smarty->fetch('userliteraldoublequote.tpl'));
    }
}