summaryrefslogtreecommitdiff
path: root/tests/UnitTests/ResourceTests/Custom/DemoPluginExtendsAll/ResourceExtendsAllPluginTest.php
blob: 0cbbfce0f41762b2235a0d9822d3bbdeb393e711 (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
/**
 * Smarty PHPUnit tests demo resource plugin extendsall
 *

 * @author  Uwe Tews
 */

require_once __DIR__ . '/../../../__shared/resources/resource.extendsall.php';

/**
 * class for demo resource plugin extendsall tests
 *
 * 
 * @preserveGlobalState    disabled
 * 
 */
class ResourceExtendsAllPluginTest extends PHPUnit_Smarty
{
    public function setUp(): void
    {
        $this->setUpSmarty(__DIR__);
    }

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

    /**
     * test  extendsall
     */
    public function testResourcePluginExtendsall()
    {
		$this->smarty->registerResource('extendsall', new My_Resource_Extendsall());
        $this->smarty->setTemplateDir(array('root' => './templates', './templates_2', './templates_3',
                                            './templates_4',));

        $expected = "templatestemplates_3templatestemplates_4";
        $this->assertEquals($expected, $this->smarty->fetch('extendsall:extendsall.tpl'));
    }

    /**
     * test  extendsall
     * changed tepmplate_setting
     */

    public function testResourcePluginExtendsall2()
    {
	    $this->smarty->registerResource('extendsall', new My_Resource_Extendsall());
		$this->smarty->setMergeCompiledIncludes(true);
        $this->smarty->setTemplateDir(array('./templates_3', './templates_4',));

        $expected = "templates_3templates_3templates_3templates_4";
        $this->assertEquals($expected, $this->smarty->fetch('extendsall:extendsall.tpl'));
    }

    public function testResourcePluginExtendsallOne()
    {
	    $this->smarty->registerResource('extendsall', new My_Resource_Extendsall());
        $this->smarty->setTemplateDir(array('root' => './templates', './templates_2', './templates_3',
                                            './templates_4',));

        $expected = "templatestemplates";
        $this->assertEquals($expected, $this->smarty->fetch('extendsall:extendsall2.tpl'));
    }

    /**
     * test  extendsall special application
     */
    public function testResourcePluginExtendsallSpecialApplication()
    {
	    $this->smarty->registerResource('extendsall', new My_Resource_Extendsall());
        $this->smarty->setTemplateDir(array('./templates_2', './templates_1',));
        $this->smarty->setDefaultResourceType('extendsall');
        $this->assertEquals('<p>data1 from templates1</p><p>data1 from templates2</p><p>data2 from templates1</p>',
                            $this->smarty->fetch('template.tpl'));
    }

    /**
     * test  extendsall special application
     */
    public function testResourcePluginExtendsallSpecialApplication2()
    {
	    $this->smarty->registerResource('extendsall', new My_Resource_Extendsall());
        $this->smarty->setTemplateDir(array('./templates_3', './templates_2', './templates_1',));
        $this->smarty->setDefaultResourceType('extendsall');
        $this->assertEquals('<p>data1 from templates1</p><p>data1 from templates3</p><p>data1 from templates2</p><p>data2 from templates1</p>',
                            $this->smarty->fetch('template.tpl'));
    }

    /**
     * test  extendsall special application
     */
    public function testResourcePluginExtendsallSpecialApplication3()
    {
        $this->smarty->setMergeCompiledIncludes(true);
	    $this->smarty->registerResource('extendsall', new My_Resource_Extendsall());
        $this->smarty->setTemplateDir(array('./templates_2', './templates_1',));
        $this->smarty->setDefaultResourceType('extendsall');
        $this->assertEquals('<p>data1 from templates1</p><p>data1 from templates2</p><p>data2 from templates1</p>',
                            $this->smarty->fetch('template.tpl'));
    }

    /**
     * test  extendsall special application
     */
    public function testResourcePluginExtendsallSpecialApplication4()
    {
        $this->smarty->setMergeCompiledIncludes(true);
	    $this->smarty->registerResource('extendsall', new My_Resource_Extendsall());
        $this->smarty->setTemplateDir(array('./templates_2', './templates_1',));
        $this->smarty->setDefaultResourceType('extendsall');
        $this->assertEquals('<p>data1 from templates1</p><p>data1 from templates2</p><p>data2 from templates1</p>',
                            $this->smarty->fetch('template.tpl'));
    }

    /**
     * test  extendsall special application
     */
    public function testResourcePluginExtendsallSpecialApplication5()
    {
        $this->smarty->setMergeCompiledIncludes(true);
	    $this->smarty->registerResource('extendsall', new My_Resource_Extendsall());
        $this->smarty->setTemplateDir(array('./templates_3', './templates_2', './templates_1',));
        $this->smarty->setDefaultResourceType('extendsall');
        $this->assertEquals('<p>data1 from templates1</p><p>data1 from templates3</p><p>data1 from templates2</p><p>data2 from templates1</p>',
                            $this->smarty->fetch('template.tpl'));
    }

    /**
     * test  extendsall special application
     */
    public function testResourcePluginExtendsallSpecialApplication6()
    {
        $this->smarty->setMergeCompiledIncludes(true);
	    $this->smarty->registerResource('extendsall', new My_Resource_Extendsall());
        $this->smarty->setTemplateDir(array('./templates_3', './templates_2', './templates_1',));
        $this->smarty->setDefaultResourceType('extendsall');
        $this->assertEquals('<p>data1 from templates1</p><p>data1 from templates3</p><p>data1 from templates2</p><p>data2 from templates1</p>',
                            $this->smarty->fetch('template.tpl'));
    }
}