OldTest.php
5.78 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<?php
/**
* PHPTAL templating engine
*
* PHP Version 5
*
* @category HTML
* @package PHPTAL
* @author Laurent Bedubourg <lbedubourg@motion-twin.com>
* @author Kornel Lesiński <kornel@aardvarkmedia.co.uk>
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
* @version SVN: $Id: OldTest.php 596 2009-05-02 18:05:35Z kornel $
* @link http://phptal.org/
*/
require_once dirname(__FILE__)."/config.php";
class OldTest extends PHPTAL_TestCase
{
function test03()
{
$tpl = $this->newPHPTAL('input/old-03.html');
$tpl->title = 'My dynamic title';
$tpl->content = '<p>my content</p>';
$res = trim_string($tpl->execute());
$exp = trim_file('output/old-03.html');
$this->assertEquals($exp, $res);
}
function test06()
{
$tpl = $this->newPHPTAL('input/old-06.html');
$tpl->title = 'my title';
$res = $tpl->execute();
$res = trim_string($res);
$exp = trim_file('output/old-06.html');
$this->assertEquals($exp, $res);
}
function test08()
{
$tpl = $this->newPHPTAL('input/old-08.html');
$res = trim_string($tpl->execute());
$exp = trim_file('output/old-08.html');
$this->assertEquals($exp, $res);
}
function test11()
{
$tpl = $this->newPHPTAL('input/old-11.html');
$res = trim_string($tpl->execute());
$exp = trim_file('output/old-11.html');
$this->assertEquals($exp, $res);
}
function test12()
{
$tpl = $this->newPHPTAL('input/old-12.html');
$res = trim_string($tpl->execute());
$exp = trim_file('output/old-12.html');
$this->assertEquals($exp, $res);
}
function test13() // default keyword
{
$tpl = $this->newPHPTAL('input/old-13.html');
$l = new StdClass(); // DummyTag();
$l->href= "http://www.example.com";
$l->title = "example title";
$l->name = "my link content";
$tpl->a2 = "a value";
$tpl->link2 = $l;
$res = trim_string($tpl->execute());
$exp = trim_file('output/old-13.html');
$this->assertEquals($exp, $res);
}
function test15() // boolean attributes
{
$tpl = $this->newPHPTAL('input/old-15.html');
$tpl->checked = true;
$tpl->notchecked = false;
$res = $tpl->execute();
$res = trim_string($res);
$exp = trim_file('output/old-15.html');
$this->assertEquals($exp, $res);
}
function test16() // default in attributes
{
$tpl = $this->newPHPTAL('input/old-16.html');
$res = $tpl->execute();
$res = trim_string($res);
$exp = trim_file('output/old-16.html');
$this->assertEquals($exp, $res);
}
function test17() // test indents
{
$tpl = $this->newPHPTAL('input/old-17.html');
$res = $tpl->execute();
$res = trim_string($res);
$exp = trim_file('output/old-17.html');
$this->assertEquals($exp, $res);
}
function test19() // attribute override
{
$tpl = $this->newPHPTAL('input/old-19.html');
$res = $tpl->execute();
$res = trim_string($res);
$exp = trim_file('output/old-19.html');
$this->assertEquals($exp, $res);
}
function test20() // remove xmlns:tal, xmlns:phptal, xmlns:metal, xmlns:i18n
{
$tpl = $this->newPHPTAL('input/old-20.html');
$res = $tpl->execute();
$res = trim_string($res);
$exp = trim_file('output/old-20.html');
$this->assertEquals($exp, $res);
}
function test21() // ensure xhtml reduced tags are reduced
{
$tpl = $this->newPHPTAL('input/old-21.html');
$res = trim_string($tpl->execute());
$exp = trim_file('output/old-21.html');
$this->assertEquals($res, $exp);
}
function test23() // test custom modifier
{
$tpl = $this->newPHPTAL('input/old-23.html');
$res = trim_string($tpl->execute());
$exp = trim_file('output/old-23.html');
$this->assertEquals($res, $exp);
}
function test29() // test doctype inherited from macro
{
$tpl = $this->newPHPTAL('input/old-29.html');
$res = trim_string($tpl->execute());
$exp = trim_file('output/old-29.html');
$this->assertEquals($exp, $res);
}
function test30() // test blocks
{
$tpl = $this->newPHPTAL('input/old-30.html');
$res = $tpl->execute();
$res = trim_string($res);
$exp = trim_file('output/old-30.html');
$this->assertEquals($exp, $res);
}
function test31() // test path evals
{
$a = new stdclass;
$a->fooval = new stdclass;
$a->fooval->b = new stdclass;
$a->fooval->b->barval = "it's working";
$tpl = $this->newPHPTAL('input/old-31.html');
$tpl->a = $a;
$tpl->foo = 'fooval';
$tpl->bar = 'barval';
$res = $tpl->execute();
$res = trim_string($res);
$exp = trim_file('output/old-31.html');
$this->assertEquals($exp, $res);
}
function test32() // recursion
{
$o = array(
'title' => 'my object',
'children' => array(
array('title' => 'o.1', 'children'=>array(
array('title'=>'o.1.1', 'children'=>array()),
array('title'=>'o.1.2', 'children'=>array()),
)),
array('title' => 'o.2', 'children'=>array()),
)
);
$tpl = $this->newPHPTAL('input/old-32.html');
$tpl->object = $o;
$res = trim_string($tpl->execute());
$exp = trim_file('output/old-32.html');
$this->assertEquals($exp, $res);
}
}
function phptal_tales_my_modifier( $arg, $nothrow )
{
return "strtoupper('$arg')";
}