french templates, updated
[koha.git] / t / output.t
1 BEGIN { $| = 1; print "1..25\n"; }
2 END {print "not ok 1\n" unless $loaded;}
3 use C4::Output;
4 $loaded = 1;
5 print "ok 1\n";
6
7 #
8 # ensure &startpage returns correct value
9 #
10 if ("<html>\n" eq startpage()) {
11     print "ok 2\n";
12 } else {
13     print "not ok 2\n";
14 }
15
16 #
17 # Check that &gotopage returns proper value
18 #
19 if ("<META HTTP-EQUIV=Refresh CONTENT=\"0;URL=http:foo\">" eq gotopage('foo')) {
20     print "ok 3\n";
21 } else {
22     print "not ok 3\n";
23 }
24
25 #
26 # skipping &startmenu for now
27 #
28
29 #
30 # skipping &endmenu for now
31
32 #
33 # ensure &mktablehdr returns a proper value
34 #
35
36 if ("<table border=0 cellspacing=0 cellpadding=5>\n" eq mktablehdr()) {
37     print "ok 4\n";
38 } else {
39     print "not ok 4\n";
40 }
41
42 #
43 # ensure &mktablerow returns a proper value
44 #
45 # 1 row, no background image
46 if ("<tr valign=top bgcolor=red><td>text</td></tr>\n" eq
47     mktablerow(1,'red','text')) {
48     print "ok 5\n";
49 } else { 
50     print "not ok 5\n";
51 }
52 # 1 row, background image
53 if ("<tr valign=top bgcolor=red><td background=\"foo.jpg\">text</td></tr>\n" eq
54     mktablerow(1,'red','text','foo.jpg')) {
55     print "ok 6\n";
56 } else {
57     print "not ok 6\n";
58 }
59 #2 rows, no background image
60 if ("<tr valign=top bgcolor=red><td>text</td><td>text</td></tr>\n" eq
61     mktablerow(2,'red','text','text')) {
62     print "ok 7\n";
63 } else {
64     print "not ok 7\n";
65 }
66
67 # 2 rows, background image
68 if ("<tr valign=top bgcolor=red><td background=\"foo.jpg\">text</td><td background=\"foo.jpg\">text</td></tr>\n" eq 
69     mktablerow(2,'red','text','text', 'foo.jpg')) {
70     print "ok 8\n";
71 } else {
72     print "not ok 8\n";
73 }
74
75 #
76 # ensure mktableft returns the proper value
77 #
78
79 if ("</table>\n" eq mktableft()) {
80     print "ok 9\n";
81 } else {
82     print "not ok 9\n";
83 }
84
85
86 #
87 # skipping mkform for now
88 #
89
90 #
91 # skipping mkform3 for now
92 #
93
94 #
95 # skipping mkform2 for now
96 #
97
98 #
99 # ensure endpage returns the proper value
100 #
101
102 if ("</body></html>\n" eq endpage()) {
103     print "ok 10\n";
104 } else {
105     print "not ok 10\n";
106 }
107
108
109 #
110 # ensure mklink returns the right value
111 #
112
113 if ("<a href=\"foo.html\">foo</a>" eq mklink('foo.html', 'foo')) {
114     print "ok 11\n";
115 } else {
116     print "not ok 11\n";
117 }
118
119 #
120 # ensure mkheadr returns the proper value
121 #
122
123 if ("<FONT SIZE=6><em>foo</em></FONT><br>" eq mkheadr(1,'foo')) {
124     print "ok 12\n";
125 } else {
126     print "not ok 12\n";
127 }
128
129 if ("<FONT SIZE=6><em>foo</em></FONT>" eq mkheadr(2,'foo')) {
130     print "ok 13\n";
131 } else {
132     print "not ok 13\n";
133 }
134
135 if ("<FONT SIZE=6><em>foo</em></FONT><p>" eq mkheadr(3,'foo')) {
136     print "ok 14\n";
137 } else {
138     print "not ok 14\n";
139 }
140
141 #
142 # test &center and &endcenter
143 #
144
145 if ("<CENTER>\n" eq center()) {
146     print "ok 15\n";
147 } else { 
148     print "not ok15\n";
149 }
150
151 if ("</CENTER>\n" eq endcenter()) {
152     print "ok 16\n";
153 } else { 
154     print "not ok 16\n";
155 }
156
157 #
158 # ensure bold returns proper value
159 #
160
161 if ("<b>foo</b>" eq bold('foo')) {
162     print "ok 17\n";
163 } else {
164     print "not ok\n";
165 }
166
167 #
168 # ensure &mkformnotable returns a valid value
169 #
170
171 @inputHidden = qw(hidden hiddenname hiddenvalue);
172 @inputRadio = qw(radio radioname radiovalue);
173 @inputText = qw(text textname textvalue);
174 @inputTextarea = qw(textarea textareaname textareavalue);
175 @inputSubmit = qw(submit submitname submitvalue);
176 @inputReset = qw(reset resetname resetvalue);
177
178 # 1 input; hidden
179 @inputs = (\@inputHidden);
180 $return ="<form action=actionurl method=post>\n";
181 $return .= "<input type=hidden name=hiddenname value=\"hiddenvalue\">\n";
182 $return .= "</form>";
183
184 if ($return eq mkformnotable('actionurl', @inputs)) {
185     print "ok 18\n";
186 } else {
187     print "not ok 18\n";
188 }
189
190 # 1 input; radio
191 @inputs = (\@inputRadio);
192 $return ="<form action=actionurl method=post>\n";
193 $return .= "<input type=radio name=radioname value=\"radiovalue\">radiovalue\n";
194 $return .= "</form>";
195
196 if ($return eq mkformnotable('actionurl', @inputs)) {
197     print "ok 19\n";
198 } else {
199     print "not ok 19\n";
200 }
201
202 # 1 input; text
203 @inputs = (\@inputText);
204 $return = "<form action=actionurl method=post>\n";
205 $return .= "<input type=text name=textname value=\"textvalue\">\n";
206 $return .= "</form>";
207
208 if ($return eq mkformnotable('actionurl', @inputs)) {
209     print "ok 20\n";
210 } else {
211     print "not ok 20\n";
212 }
213
214
215 # 1 input; textarea
216 @inputs = (\@inputTextarea);
217 $return = "<form action=actionurl method=post>\n";
218 $return .= "<textarea name=textareaname wrap=physical cols=40 rows=4>textareavalue</textarea>\n";
219 $return .= "</form>";
220
221 if ($return eq mkformnotable('actionurl', @inputs)) {
222     print "ok 21\n";
223 } else {
224     print "not ok 21\n";
225 }
226
227 # 1 input; submit
228 @inputs = (\@inputSubmit);
229 $return = "<form action=actionurl method=post>\n";
230 $return .= "<input type=submit name=submitname value=\"submitvalue\">\n";
231 $return .= "</form>";
232
233 if ($return eq mkformnotable('actionurl', @inputs)) {
234     print "ok 22\n";
235 } else {
236     print "not ok 22\n";
237 }
238
239 # 1 input; reset
240 @inputs = (\@inputReset);
241 $return = "<form action=actionurl method=post>\n";
242 $return .= "<input type=reset name=resetname value=\"resetvalue\">\n";
243 $return .= "</form>";
244
245 if ($return eq mkformnotable('actionurl', @inputs)) {
246     print "ok 23\n";
247 } else {
248     print "not ok 23\n";
249 }
250
251 # 2 inputs; hidden and submit
252 @inputs = (\@inputHidden, \@inputSubmit);
253 $return = "<form action=actionurl method=post>\n";
254 $return .= "<input type=hidden name=hiddenname value=\"hiddenvalue\">\n";
255 $return .= "<input type=submit name=submitname value=\"submitvalue\">\n";
256 $return .= "</form>";
257
258 if ($return eq mkformnotable('actionurl', @inputs)) {
259     print "ok 24\n";
260 } else {
261     print "not ok 24\n";
262 }
263
264
265 # 3 inputs; text, submit, and reset
266 @inputs = (\@inputText, \@inputSubmit, \@inputReset);
267 $return = "<form action=actionurl method=post>\n";
268 $return .= "<input type=text name=textname value=\"textvalue\">\n";
269 $return .= "<input type=submit name=submitname value=\"submitvalue\">\n";
270 $return .= "<input type=reset name=resetname value=\"resetvalue\">\n";
271 $return .= "</form>";
272
273 if ($return eq mkformnotable('actionurl', @inputs)) {
274     print "ok 25\n";
275 } else {
276     print "not ok 25\n";
277 }
278
279
280
281
282