Added recursive -r flag to prove example
[catagits/Catalyst-Runtime.git] / t / engine / request / parameters.t
index 254435b..68fb7cd 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 use FindBin;
 use lib "$FindBin::Bin/../../lib";
 
-use Test::More tests => 11;
+use Test::More tests => 19;
 use Catalyst::Test 'TestApp';
 
 use Catalyst::Request;
@@ -19,6 +19,25 @@ use URI;
 
     my $parameters = { 
         'a' => [qw(A b C d E f G)],
+    };
+    
+    my $query = join( '&', map { 'a=' . $_ } @{ $parameters->{a} } );
+    
+    ok( my $response = request("http://localhost/dump/request?$query"), 'Request' );
+    ok( $response->is_success, 'Response Successful 2xx' );
+    is( $response->content_type, 'text/plain', 'Response Content-Type' );
+    like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' );
+    ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
+    isa_ok( $creq, 'Catalyst::Request' );
+    is( $creq->method, 'GET', 'Catalyst::Request method' );
+    is_deeply( $creq->parameters, $parameters, 'Catalyst::Request parameters' );
+}
+
+{
+    my $creq;
+
+    my $parameters = { 
+        'a' => [qw(A b C d E f G)],
         '%' => [ '%', '"', '& - &' ],
     };
 
@@ -29,10 +48,11 @@ use URI;
 
     # Query string. I'm not sure the order is consistent in all enviroments,
     # we need to test this with:
-    # [x] C::E::Test and C::E::Daemon
-    # [ ] MP1
-    # [ ] MP2
-    # [x] CGI::Simple
+    # [x] C::E::Test and C::E::HTTP
+    # [x] MP13
+    # [x] MP19
+    # [x] MP20
+    # [x] CGI
 
     unshift( @{ $parameters->{a} }, 1, 2, 3 );
     
@@ -48,3 +68,25 @@ use URI;
     is_deeply( $creq->uploads, {}, 'Catalyst::Request uploads' );
     is_deeply( $creq->cookies, {}, 'Catalyst::Request cookie' );
 }
+
+__END__
+# http://dev.catalyst.perl.org/ticket/37
+# multipart/form-data parameters that contain 'http://'
+# Not testing in trunk because this is an HTTP::Message bug
+# http://rt.cpan.org/NoAuth/Bug.html?id=13025
+{
+    my $creq;
+
+    my $parameters = {
+        'url' => 'http://www.google.com',
+    };
+
+    my $request = POST( 'http://localhost/dump/request',
+        'Content-Type' => 'multipart/form-data',
+        'Content'      => $parameters,
+    );
+
+    ok( my $response = request($request), 'Request' );
+    ok( eval '$creq = ' . $response->content, 'Unserialize Catalyst::Request' );
+    is_deeply( $creq->parameters, $parameters, 'Catalyst::Request parameters' );
+}