Don't run the moose controller test if Moose isn't available
[catagits/Catalyst-Runtime.git] / t / live_engine_request_body.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 tests => 18;
10 use Catalyst::Test 'TestApp';
11
12 use Catalyst::Request;
13 use HTTP::Headers;
14 use HTTP::Request::Common;
15
16 {
17     my $creq;
18
19     my $request = POST(
20         'http://localhost/dump/request/',
21         'Content-Type' => 'text/plain',
22         'Content'      => 'Hello Catalyst'
23     );
24
25     ok( my $response = request($request), 'Request' );
26     ok( $response->is_success, 'Response Successful 2xx' );
27     is( $response->content_type, 'text/plain', 'Response Content-Type' );
28     like( $response->content, qr/'Catalyst::Request'/,
29         'Content is a serialized Catalyst::Request' );
30
31     {
32         no strict 'refs';
33         ok(
34             eval '$creq = ' . $response->content,
35             'Unserialize Catalyst::Request'
36         );
37     }
38
39     isa_ok( $creq, 'Catalyst::Request' );
40     is( $creq->method,       'POST',       'Catalyst::Request method' );
41     is( $creq->content_type, 'text/plain', 'Catalyst::Request Content-Type' );
42     is( $creq->content_length, $request->content_length,
43         'Catalyst::Request Content-Length' );
44 }
45
46 {
47     my $creq;
48
49     my $request = POST(
50         'http://localhost/dump/request/',
51         'Content-Type' => 'text/plain',
52         'Content'      => 'x' x 100_000
53     );
54
55     ok( my $response = request($request), 'Request' );
56     ok( $response->is_success, 'Response Successful 2xx' );
57     is( $response->content_type, 'text/plain', 'Response Content-Type' );
58     like(
59         $response->content,
60         qr/^bless\( .* 'Catalyst::Request' \)$/s,
61         'Content is a serialized Catalyst::Request'
62     );
63
64     {
65         no strict 'refs';
66         ok(
67             eval '$creq = ' . $response->content,
68             'Unserialize Catalyst::Request'
69         );
70     }
71
72     isa_ok( $creq, 'Catalyst::Request' );
73     is( $creq->method,       'POST',       'Catalyst::Request method' );
74     is( $creq->content_type, 'text/plain', 'Catalyst::Request Content-Type' );
75     is( $creq->content_length, $request->content_length,
76         'Catalyst::Request Content-Length' );
77 }