Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 102 lines (82 sloc) 2.049 kb
3ebfa07 @abw Initial revision
authored
1 #============================================================= -*-perl-*-
2 #
3 # t/cgi.t
4 #
5 # Test the CGI plugin.
6 #
82cbea8 @abw version 2.00
authored
7 # Written by Andy Wardley <abw@kfs.org>
3ebfa07 @abw Initial revision
authored
8 #
3e45060 @abw *** empty log message ***
authored
9 # Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved.
10 # Copyright (C) 1998-2000 Canon Research Centre Europe Ltd.
3ebfa07 @abw Initial revision
authored
11 #
12 # This is free software; you can redistribute it and/or modify it
13 # under the same terms as Perl itself.
14 #
15 # $Id$
16 #
17 #========================================================================
18
19 use strict;
20 use lib qw( ../lib );
21 use Template;
22 use Template::Test;
23 $^W = 1;
24
8a49dc5 @abw *** empty log message ***
authored
25 #$Template::Parser::DEBUG = 1;
26 #$Template::Parser::PRETTY = 1;
27 #$Template::Stash::DEBUG = 1;
3ebfa07 @abw Initial revision
authored
28
29 eval "use CGI";
30 if ($@) {
039bd37 @abw * fixed numerous tests to report proper reason for skipping via skip_…
authored
31 skip_all("no CGI module");
3ebfa07 @abw Initial revision
authored
32 }
33
6ddeb78 @abw added leak.t
authored
34
8a49dc5 @abw *** empty log message ***
authored
35 my $cgi = CGI->new('');
36 $cgi = join("\n", $cgi->checkbox_group(
37 -name => 'words',
38 -values => [ 'eenie', 'meenie', 'minie', 'moe' ],
39 -defaults => [ 'eenie', 'meenie' ],
40 ));
41
42
a314819 @abw v2.00
authored
43 test_expect(\*DATA, undef, { cgicheck => $cgi, barf => \&barf });
44
45 sub barf {
46 carp('failed');
47 }
3ebfa07 @abw Initial revision
authored
48
6ddeb78 @abw added leak.t
authored
49
3ebfa07 @abw Initial revision
authored
50 __END__
51 -- test --
8a49dc5 @abw *** empty log message ***
authored
52 [% USE cgi = CGI('id=abw&name=Andy+Wardley'); global.cgi = cgi -%]
53 name: [% global.cgi.param('name') %]
54 -- expect --
55 name: Andy Wardley
56
57 -- test --
58 name: [% global.cgi.param('name') %]
59
60 -- expect --
61 name: Andy Wardley
62
63 -- test --
64 [% FOREACH key = global.cgi.param.sort -%]
65 * [% key %] : [% global.cgi.param(key) %]
66 [% END %]
67 -- expect --
68 * id : abw
69 * name : Andy Wardley
70
71 -- test --
72 [% FOREACH key = global.cgi.param().sort -%]
73 * [% key %] : [% global.cgi.param(key) %]
74 [% END %]
75 -- expect --
76 * id : abw
77 * name : Andy Wardley
3ebfa07 @abw Initial revision
authored
78
8a49dc5 @abw *** empty log message ***
authored
79 -- test --
80 [% FOREACH x = global.cgi.checkbox_group(
3ebfa07 @abw Initial revision
authored
81 name => 'words'
82 values => [ 'eenie', 'meenie', 'minie', 'moe' ]
83 defaults => [ 'eenie', 'meenie' ] ) -%]
84 [% x %]
85 [% END %]
86
87 -- expect --
8a49dc5 @abw *** empty log message ***
authored
88 -- process --
89 [% cgicheck %]
b4f721c @abw *** empty log message ***
authored
90
0497842 @abw * added test for the params() method
authored
91 -- test --
92 [% USE cgi('item=foo&items=one&items=two') -%]
93 item: [% cgi.params.item %]
94 item: [% cgi.params.item.join(', ') %]
95 items: [% cgi.params.items.join(', ') %]
96
97 -- expect --
98 item: foo
99 item: foo
100 items: one, two
a314819 @abw v2.00
authored
101
Something went wrong with that request. Please try again.