Debian lenny version packages
[pkg-perl] / deb-src / libwww-perl / libwww-perl-5.813 / t / html / form-multi-select.t
1 #!/usr/bin/perl
2
3 # Test for case when multiple forms are on a page with same-named <select> fields. 
4
5 use strict;
6 use Test::More tests => 2;
7 use HTML::Form;
8
9
10     my $test = "the settings of a previous form should not interfere with a latter form (control test with one form)";
11     my @forms = HTML::Form->parse( FakeResponse::One->new );
12     my $cat_form = $forms[0];
13     my @vals = $cat_form->param('age');
14     is_deeply(\@vals,[''], $test);
15 }
16
17     my $test = "the settings of a previous form should not interfere with a latter form (test with two forms)";
18     my @forms = HTML::Form->parse( FakeResponse::TwoForms->new );
19     my $cat_form = $forms[1];
20
21     my @vals = $cat_form->param('age');
22     is_deeply(\@vals,[''], $test);
23 }
24
25 ####
26 package FakeResponse::One;
27 sub new {
28     bless {}, shift;
29 }
30 sub base {
31     return "http://foo.com"
32 }
33 sub decoded_content {
34     my $html = qq{
35     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
36     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
37     <html xmlns="http://www.w3.org/1999/xhtml">
38     <head>
39     <title></title>
40     </head>
41     <body>
42
43     <form name="search_cats">
44     <select name="age" onChange="jumpTo(this)" class="sap-form-item">
45     <option value="" selected="selected">Any</option>
46     <option value="young">Young</option>
47     <option value="adult">Adult</option>
48     <option value="senior">Senior</option>
49     <option value="puppy">Puppy </option>
50     </select>
51     </form>
52     </body></html>
53     };
54     return \$html;
55 }
56
57 #####
58 package FakeResponse::TwoForms;
59 sub new {
60     bless {}, shift;
61 }
62 sub base {
63     return "http://foo.com"
64 }
65 sub decoded_content {
66     my $html = qq{
67     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
68     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
69     <html xmlns="http://www.w3.org/1999/xhtml">
70     <head>
71     <title></title>
72     </head>
73     <body>
74     <form name="search_dogs" >
75     <select name="age" onChange="jumpTo(this)" class="sap-form-item">
76     <option value="" selected="selected">Any</option>
77     <option value="young">Young</option>
78     <option value="adult">Adult</option>
79     <option value="senior">Senior</option>
80     <option value="puppy">Puppy </option>
81     </select>
82     </form>
83
84
85     <form name="search_cats">
86     <select name="age" onChange="jumpTo(this)" class="sap-form-item">
87     <option value="" selected="selected">Any</option>
88     <option value="young">Young</option>
89     <option value="adult">Adult</option>
90     <option value="senior">Senior</option>
91     <option value="puppy">Puppy </option>
92     </select>
93     </form>
94     </body></html>
95     };
96     return \$html;
97 }