Add the original source packages to maemo, source lenny
[dh-make-perl] / dev / i386 / libwww-mechanize-perl / libwww-mechanize-perl-1.34 / t / upload.t
1 #!perl -Tw
2
3 use strict;
4 use warnings;
5 use Test::More tests => 5;
6 use URI::file;
7
8 BEGIN { delete @ENV{ qw( http_proxy HTTP_PROXY PATH IFS CDPATH ENV BASH_ENV) }; }
9 use_ok( 'WWW::Mechanize' );
10
11 my $mech = WWW::Mechanize->new( cookie_jar => undef );
12 isa_ok( $mech, 'WWW::Mechanize' );
13
14 my $uri = URI::file->new_abs( 't/upload.html' )->as_string;
15 $mech->get( $uri );
16 ok( $mech->success, $uri );
17
18 my $form = $mech->form_number(1);
19 my $reqstring = $form->click->as_string;
20 $reqstring =~ s/\r//g;
21
22 # trim off possible extra newline
23 $reqstring =~ s/^\Z\n//m;
24
25 my $wanted = <<'EOT';
26 POST http://localhost/
27 Content-Length: 77
28 Content-Type: multipart/form-data; boundary=xYzZY
29
30 --xYzZY
31 Content-Disposition: form-data; name="submit"
32
33 Submit
34 --xYzZY--
35 EOT
36
37 is( $reqstring, $wanted, 'Proper posting' );
38
39 $mech->field('upload', 'MANIFEST');
40 $reqstring = $form->click->as_string;
41 like( $reqstring, qr/Cookbook/, 'The uploaded file should be in the request');
42