summaryrefslogtreecommitdiff
path: root/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Cookie/CookieTest.php
blob: f54cd12cefc933f9d2d86f13e997cac9198160b4 (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 {$smarty.cookies.foo}
 *

 * @author  Uwe Tews
 */

/**
 * class for $smarty.cookies.foo} tests
 *
 *
 * 
 * 
 */
class CookieTest extends PHPUnit_Smarty
{
    public function setUp(): void
    {
        $this->setUpSmarty(__DIR__);
    }

    public function testInit()
    {
        $this->cleanDirs();
    }
    /**
     * test cookies
     *
     * 
     * 
     * @dataProvider dataProvider
     */
    public function testCookie($caching, $value) {
        $_COOKIE['fooBar'] = $value;
        $this->smarty->caching = $caching;
        $this->assertEquals($value, $this->smarty->fetch('cookie.tpl'));
    }
    /**
     * test variable cookies
     *
      */
    public function testCookieVariable() {
        $_COOKIE['fooBarVar'] = 'fooBarVarValue';
        $this->smarty->assign('foo', 'fooBarVar');
        $this->assertEquals('fooBarVarValue', $this->smarty->fetch('cookie_variable.tpl'));
    }

    /**
     * test cookies with modifier
     *
     * 
     * 
     * @dataProvider dataProviderModifier
     */
    public function testCookieModifier($caching, $value, $result) {
        $_COOKIE['fooBar'] = $value;
        $this->smarty->caching = $caching;
        $this->assertEquals($result, $this->smarty->fetch('cookie_modifier.tpl'));
    }

    /**
     * data provider
     */
    public function dataProvider()
    {
        return array(
            'compile' => array(false, 'buh'),
            'compiled' => array(false, 'bar'),
            'create cache' => array(true, 'cached buh'),
            'cacheded' => array(true, 'cached bar'),
        );
    }
    public function dataProviderModifier()
    {
        return array(
            'compile' => array(false, 'buh', 3),
            'compiled' => array(false, 'bar1', 4),
            'create cache' => array(true, 'cached buh', 10),
            'cacheded' => array(true, 'cached bar1', 11),
        );
    }

}