summaryrefslogtreecommitdiff
path: root/tests/UnitTests/TemplateSource/ValueTests/SingleQouted/SingleQuotedStringTest.php
blob: d719e9735d9d5b31e4463acee88718c88578bfc0 (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
<?php
/**
 * Smarty PHPunit tests single quoted strings
 *

 * @author  Uwe Tews
 */

/**
 * class for single quoted string tests
 *
 * 
 * 
 * 
 */
class SingleQuotedStringTest extends PHPUnit_Smarty
{
    public function setUp(): void
    {
        $this->setUpSmarty(__DIR__);
    }


    /**
     * test simple single quoted string
     */
    public function testSimpleSingleQuotedString()
    {
        $tpl = $this->smarty->createTemplate('eval:{$foo=\'Hello World\'}{$foo}');
        $this->assertEquals('Hello World', $this->smarty->fetch($tpl));
    }

    /**
     * test that tags not interpreted in single quoted strings
     */
    public function testTagsInSingleQuotedString()
    {
        $tpl = $this->smarty->createTemplate('eval:{$foo=\'Hello {1+2} World\'}{$foo}');
        $this->assertEquals('Hello {1+2} World', $this->smarty->fetch($tpl));
    }

    /**
     * test that vars not interpreted in single quoted strings
     */
    public function testVarsInSingleQuotedString()
    {
        $tpl = $this->smarty->createTemplate('eval:{$foo=\'Hello $bar World\'}{$foo}');
        $this->assertEquals('Hello $bar World', $this->smarty->fetch($tpl));
    }

    /**
     * test double quotes in single quoted strings
     */
    public function testDoubleQuotesInSingleQuotedString()
    {
        $tpl = $this->smarty->createTemplate('eval:{$foo=\'Hello "World"\'}{$foo}');
        $this->assertEquals('Hello "World"', $this->smarty->fetch($tpl));
    }

    /**
     * test escaped single quotes in single quoted strings
     */
    public function testEscapedSingleQuotesInSingleQuotedString()
    {
        $tpl = $this->smarty->createTemplate('eval:{$foo=\'Hello \\\'World\'}{$foo}');
        $this->assertEquals("Hello 'World", $this->smarty->fetch($tpl));
    }

    /**
     * test empty single quoted strings
     */
    public function testEmptySingleQuotedString()
    {
        $tpl = $this->smarty->createTemplate('eval:{$foo=\'\'}{$foo}');
        $this->assertEquals("", $this->smarty->fetch($tpl));
    }
}