Debian Codegraph @

t/19-value-multi.t

raw
1 #!/usr/bin/perl -w
2 use strict;
3
4 use lib './inc';
5 use IO::Catch;
6
7 # pre-5.8.0's warns aren't caught by a tied STDERR.
8 $SIG{__WARN__} = sub { $main::_STDERR_ .= join '', @_; };
9 tie *STDERR, 'IO::Catch', '_STDERR_' or die $!;
10 tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
11
12 use Test::More tests => 1 +3;
13
14 BEGIN {
15 # Disable all ReadLine functionality
16 $ENV{PERL_RL} = 0;
17 use_ok('WWW::Mechanize::Shell');
18 };
19
20 TODO: {
21 local $TODO = "Implement passing of multiple values";
22
23 my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
24 $s->agent->{content} = join "", <DATA>;
25 $s->agent->{forms} = [ HTML::Form->parse($s->agent->{content}, 'http://localhost/test/') ];
26 $s->agent->{form} = @{$s->agent->{forms}} ? $s->agent->{forms}->[0] : undef;
27 $s->cmd('value cat cat_foo cat_bar cat_baz');
28 is_deeply([$s->agent->current_form->find_input('cat')->form_name_value],[qw[cat cat_foo cat cat_bar cat cat_baz]])
29 or diag $s->agent->current_form->find_input('cat')->form_name_value;
30 $s->cmd('value cat ""');
31 is_deeply([$s->agent->current_form->find_input('cat')],[]);
32 $s->cmd('value cat "cat_bar"');
33 is_deeply([$s->agent->current_form->find_input('cat')],[qw[cat_bar]]);
34 };
35 __DATA__
36 <html>
37 <head>WWW::Mechanize::Shell test page</head>
38 <body>
39 <h1>Location: %s</h1>
40 <p>
41 <a href="/test">Link /test</a>
42 <a href="/foo">Link /foo</a>
43 <a href="/slash_end">Link /</a>
44 <a href="/slash_front">/Link </a>
45 <a href="/slash_both">/Link in slashes/</a>
46 <a href="/foo1.save_log_server_test.tmp">Link foo1.save_log_server_test.tmp</a>
47 <a href="/foo2.save_log_server_test.tmp">Link foo2.save_log_server_test.tmp</a>
48 <a href="/foo3.save_log_server_test.tmp">Link foo3.save_log_server_test.tmp</a>
49 <table>
50 <tr><th>Col1</th><th>Col2</th><th>Col3</th></tr>
51 <tr><td>A1</td><td>A2</td><td>A3</td></tr>
52 <tr><td>B1</td><td>B2</td><td>B3</td></tr>
53 <tr><td>C1</td><td>C2</td><td>C3</td></tr>
54 </table>
55 <form action="/formsubmit">
56 <input type="hidden" name="session" value="%s"/>
57 <input type="text" name="query" value="%s"/>
58 <input type="submit" name="submit" value="Go"/>
59 <input type="checkbox" name="cat" value="cat_foo" %s />
60 <input type="checkbox" name="cat" value="cat_bar" %s />
61 <input type="checkbox" name="cat" value="cat_baz" %s />
62 </form>
63 </p>
64 </body>
65 </html>