more tests in output.t and a cleanup for testKoha.pl
[koha.git] / output.t
1 BEGIN { $| = 1; print "1..17\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 mkformnotable for now
96 #
97
98 #
99 # skipping mkform2 for now
100 #
101
102 #
103 # ensure endpage returns the proper value
104 #
105
106 if ("</body></html>\n" eq endpage()) {
107     print "ok 10\n";
108 } else {
109     print "not ok 10\n";
110 }
111
112
113 #
114 # ensure mklink returns the right value
115 #
116
117 if ("<a href=\"foo.html\">foo</a>" eq mklink('foo.html', 'foo')) {
118     print "ok 11\n";
119 } else {
120     print "not ok 11\n";
121 }
122
123 #
124 # ensure mkheadr returns the proper value
125 #
126
127 if ("<FONT SIZE=6><em>foo</em></FONT><br>" eq mkheadr(1,'foo')) {
128     print "ok 12\n";
129 } else {
130     print "not ok 12\n";
131 }
132
133 if ("<FONT SIZE=6><em>foo</em></FONT>" eq mkheadr(2,'foo')) {
134     print "ok 13\n";
135 } else {
136     print "not ok 13\n";
137 }
138
139 if ("<FONT SIZE=6><em>foo</em></FONT><p>" eq mkheadr(3,'foo')) {
140     print "ok 14\n";
141 } else {
142     print "not ok 14\n";
143 }
144
145 #
146 # test &center and &endcenter
147 #
148
149 if ("<CENTER>\n" eq center()) {
150     print "ok 15\n";
151 } else { 
152     print "not ok15\n";
153 }
154
155 if ("</CENTER>\n" eq endcenter()) {
156     print "ok 16\n";
157 } else { 
158     print "not ok 16\n";
159 }
160
161 #
162 # ensure bold returns proper value
163 #
164
165 if ("<b>foo</b>" eq bold('foo')) {
166     print "ok 17\n";
167 } else {
168     print "not ok\n";
169 }