initial commit
[chaz/p5-HTTP-AnyUA] / t / 03-post_form.t
1 #!perl
2
3 use warnings;
4 use strict;
5
6 use lib 't/lib';
7
8 use HTTP::AnyUA;
9 use Test::More tests => 4;
10
11 HTTP::AnyUA->register_backend(Mock => '+MockBackend');
12
13 my $any_ua = HTTP::AnyUA->new(ua => 'Mock');
14 my $backend = $any_ua->backend;
15
16 my $url = 'http://acme.tld/';
17 my $form = {
18 foo => 'bar',
19 baz => 42,
20 };
21 my $resp = $any_ua->post_form($url, $form);
22
23 my $request = ($backend->requests)[-1];
24
25 is $request->[0], 'POST', 'post_form request method is POST';
26 is $request->[1], $url, 'post_form request URL is correct';
27 is $request->[2]{content}, 'baz=42&foo=bar', 'post_form request body is correct';
28 is $request->[2]{headers}{'content-type'}, 'application/x-www-form-urlencoded', 'post_form request content-type header is correct';
29
This page took 0.03585 seconds and 4 git commands to generate.