summaryrefslogtreecommitdiff
path: root/tests/UnitTests/Compiler/Delimiter/AutoLiteralTest.php
blob: 40d21653a8b3a3bbc60859b30242bfda09afdc0b (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/**
 * Smarty PHPunit tests of delimiter
 *

 * @author  Uwe Tews
 */

/**
 * class for delimiter tests
 *
 * 
 * 
 */
class AutoliteralTest extends PHPUnit_Smarty
{
    public function setUp(): void
    {
        $this->setUpSmarty(__DIR__);
        $this->smarty->addPluginsDir("../../__shared/PHPunitplugins/");
    }

    public function testInit()
    {
        $this->cleanDirs();
    }

    /**
     * test '{ ' delimiter
     */
    public function testSetAutoliteral()
    {
        $this->smarty->setAutoLiteral(true);
        $this->smarty->assign('i','foo');
        $this->assertEquals('{ $i}foo', $this->smarty->fetch('autoliteral.tpl'));
    }

    public function testSetAutoliteral2()
    {
        $this->smarty->setAutoLiteral(false);
        $this->smarty->setCompileId(1);
        $this->smarty->assign('i','bar');
        $this->assertEquals('barbar', $this->smarty->fetch('autoliteral.tpl'));
    }
    /**
     * test '{ ' delimiter in double quotes auto_literal true
     */
    public function testSetAutoliteralDoublequote()
    {
        $this->smarty->setAutoLiteral(true);
        $this->assertEquals(' output: double { counter} 1 quote', $this->smarty->fetch('autoliteraldoublequote.tpl'));
    }
    /**
     * test '{ ' delimiter in double quotes auto_literal false
     */
    public function testSetAutoliteralDoublequote2()
    {
        $this->smarty->setAutoLiteral(false);
        $this->smarty->setCompileId(1);
        $this->assertEquals(' output: double 1 2 quote', $this->smarty->fetch('autoliteraldoublequote.tpl'));
    }

    /**
     * test '{{ ' delimiter in double quotes auto_literal true
     */
    public function testSetAutoliteralDoublequote3()
    {
        $this->smarty->setAutoLiteral(true);
        $this->assertEquals(' output: double {{ counter} {{ counter}}  quote', $this->smarty->fetch('autoliteraldoublequote2.tpl'));
    }

    public function testSetAutoliteralBlock()
    {
        $this->smarty->setAutoLiteral(true);
        $this->assertEquals('{ dummyblock}foo{ /dummyblock}', $this->smarty->fetch('autoliteralblock.tpl'));
    }
    public function testSetAutoliteralBlock1()
    {
        $this->smarty->setAutoLiteral(false);
        $this->smarty->setCompileId(1);
        $this->assertEquals('foo', $this->smarty->fetch('autoliteralblock.tpl'));
    }

}