new test suit
[catagits/Catalyst-Runtime.git] / t / engine / request / parameters.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use FindBin;
7 use lib "$FindBin::Bin/../../lib";
8
9 use Test::More no_plan => 1;
10 use Catalyst::Test 'TestApp';
11
12 use Catalyst::Request;
13 use HTTP::Headers;
14 use HTTP::Request::Common;
15 use URI;
16
17 {
18     my $creq;
19
20     my $parameters = { 
21         'a' => [qw(A b C d E f G)],
22         '%' => [ '%', '"', '& - &' ],
23     };
24
25     my $request = POST( 'http://localhost/dump/request/a/b?a=1&a=2&a=3', 
26         'Content'      => $parameters,
27         'Content-Type' => 'application/x-www-form-urlencoded'
28     );
29
30     # Query string. I'm not sure the order is consistent in all enviroments,
31     # we need to test this with:
32     # [x] C::E::Test and C::E::Daemon
33     # [ ] MP1
34     # [ ] MP2
35     # [x] CGI::Simple
36
37     unshift( @{ $parameters->{a} }, 1, 2, 3 );
38     
39     ok( my $response = request($request), 'Request' );
40     ok( $response->is_success, 'Response Successful 2xx' );
41     is( $response->content_type, 'text/plain', 'Response Content-Type' );
42     like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' );
43     ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
44     isa_ok( $creq, 'Catalyst::Request' );
45     is( $creq->method, 'POST', 'Catalyst::Request method' );
46     is_deeply( $creq->parameters, $parameters, 'Catalyst::Request parameters' );
47     is_deeply( $creq->arguments, [qw(a b)], 'Catalyst::Request arguments' );
48     is_deeply( $creq->uploads, {}, 'Catalyst::Request uploads' );
49     is_deeply( $creq->cookies, {}, 'Catalyst::Request cookie' );
50 }