~ubuntu-branches/ubuntu/intrepid/libcgi-formbuilder-perl/intrepid

« back to all changes in this revision

Viewing changes to t/2a-template-html.t

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-28 20:29:04 UTC
  • mfrom: (2.1.7 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080628202904-81kzjon8e8silx88
Tags: 3.05.01-6
Set urgency=medium as 3.05.01-6 included a FTBFS bugfix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl -Ilib -I../lib
 
1
#!/usr/bin/perl 
2
2
 
3
3
# Copyright (c) 2000-2006 Nathan Wiger <nate@wiger.org>.
4
4
# All Rights Reserved. If you're reading this, you're bored.
5
5
# 2a-template-html.t - test HTML::Template support
6
6
 
7
7
use strict;
8
 
use vars qw($TESTING $DEBUG $SKIP);
9
 
$TESTING = 1;
10
 
$DEBUG = $ENV{DEBUG} || 0;
 
8
 
 
9
our $TESTING = 1;
 
10
our $DEBUG = $ENV{DEBUG} || 0;
 
11
our $VERSION;
 
12
BEGIN { $VERSION = '3.0501'; }
 
13
 
11
14
use Test;
 
15
use FindBin;
12
16
 
13
17
# use a BEGIN block so we print our plan before CGI::FormBuilder is loaded
 
18
our $SKIP;
14
19
BEGIN {
15
 
    my $numtests = 4;
 
20
    my $numtests = 5;
 
21
    unshift @INC, "$FindBin::Bin/../lib";
16
22
 
17
23
    plan tests => $numtests;
18
24
 
32
38
$ENV{REQUEST_METHOD} = 'GET';
33
39
$ENV{QUERY_STRING}   = 'ticket=111&user=pete&replacement=TRUE';
34
40
 
35
 
use CGI::FormBuilder;
 
41
use CGI::FormBuilder 3.0501;
36
42
use CGI::FormBuilder::Test;
37
43
 
38
44
# Grab our template from our test00.html file
39
45
my $template = outfile(0);
 
46
my $kurtlidl = outfile(99);
40
47
 
41
48
# What options we want to use, and what we expect to see
42
49
my @test = (
76
83
               },
77
84
 
78
85
    },
 
86
    {
 
87
        opt => { fields => [qw/field1 field2/], method => 'post',
 
88
                 title => 'test form page', header => 0,
 
89
                 template => { scalarref => \$kurtlidl },
 
90
               },
 
91
        mod => {
 
92
            field1 => { value => 109, comment => '<i>Hello</i>' },
 
93
            field2 => { type => 'submit', value => "1 < 2 < 3", label => "Reefer", comment => '<i>goodbyE@</i>' },
 
94
            field3 => { type => 'button', value => "<<PUSH>>", comment => '<i>onSubmit</i>' },
 
95
        },
 
96
    },
79
97
);
80
98
 
81
99
# Perl 5 is sick sometimes.
105
123
    # (since render is called regardless of whether $SKIP is set)
106
124
    #
107
125
    my $out = outfile($seq++);
108
 
    my $ren;
109
 
    eval '$ren = $form->render';
 
126
    my $ren = $SKIP ? '' : $form->render;
110
127
    my $ok = skip($SKIP, $ren, $out);
111
128
 
112
129
    if (! $ok && $ENV{LOGNAME} eq 'nwiger') {
113
 
        open(O, ">/tmp/fb.1.out");
 
130
        #use Data::Dumper;
 
131
        #die Dumper($form);
 
132
        open(O, ">/tmp/fb.1.html");
114
133
        print O $out;
115
134
        close O;
116
135
 
117
 
        open(O, ">/tmp/fb.2.out");
 
136
        open(O, ">/tmp/fb.2.html");
118
137
        print O $ren;
119
138
        close O;
120
139
 
121
 
        system "diff /tmp/fb.1.out /tmp/fb.2.out";
 
140
        system "diff /tmp/fb.1.html /tmp/fb.2.html";
122
141
        exit 1;
123
142
    }
124
143
}