File: 04fillform3.t

package info (click to toggle)
libcatalyst-plugin-fillinform-perl 0.12-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 176 kB
  • ctags: 117
  • sloc: perl: 1,266; makefile: 4
file content (41 lines) | stat: -rw-r--r-- 900 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main;

#
# Default behavior, EXCEPT:
#    target => 'form2'
#

use Test::More tests => 3;
use lib 't/lib';
use Catalyst::Test 'TestApp3';

use HTML::Parser ();
my $p = HTML::Parser->new(
   start_h => [\&html_parser_start, "self,tagname,attr"],
);

my $url = '/?aaa=one&bbb=two&ccc=three&ddd=four';

my $parsed_html;
{
    ok( my $response = request($url), 'Normal Request'  );
    is( $response->code, 200,         'OK status code'  );
    $p->parse($response->content);
    is( $parsed_html,
        "form1:aaa||bbb||ccc||ddd||" .
        "form2:aaa|one|bbb|two|ccc|three|ddd|four|",
                                      'Re-Parsed HTML'  );
}


sub html_parser_start {
    my($self, $tag, $attr) = @_;
    if ($tag eq "form") {
       $parsed_html .= $attr->{name} . ":";
    } elsif ($tag eq "input") {
       $parsed_html .= sprintf("%s|%s|", $attr->{name}, $attr->{value});
    }
}