Merge branch 'pr/157' into release-candidates/rc-5.90116
[catagits/Catalyst-Runtime.git] / t / live_catalyst_test.t
1 use strict;
2 use warnings;
3
4 use FindBin;
5 use lib "$FindBin::Bin/lib";
6 use Catalyst::Test 'TestApp', {default_host => 'default.com'};
7 use Catalyst::Request;
8 use HTTP::Request::Common;
9
10 use Test::More;
11
12 content_like('/',qr/root/,'content check');
13 action_ok('/','Action ok ok','normal action ok');
14 action_redirect('/engine/response/redirect/one','redirect check');
15 action_notfound('/engine/response/status/s404','notfound check');
16
17 # so we can see the default test name
18 action_ok('/');
19
20 contenttype_is('/action/local/one','text/plain','Contenttype check');
21
22 ### local_request() was not setting response base from base href
23 {
24     my $response = request('/base_href_test');
25     is( $response->base, 'http://www.example.com/', 'response base set from base href');
26 }
27
28 my $creq;
29 my $req = '/dump/request';
30
31 {
32     eval '$creq = ' . request($req)->content;
33     is( $creq->uri->host, 'default.com', 'request targets default host set via import' );
34 }
35
36 {
37     local $Catalyst::Test::default_host = 'localized.com';
38     eval '$creq = ' . request($req)->content;
39     is( $creq->uri->host, 'localized.com', 'target host is mutable via package var' );
40 }
41
42 {
43     my %opts = ( host => 'opthash.com' );
44     eval '$creq = ' . request($req, \%opts)->content;
45     is( $creq->uri->host, $opts{host}, 'target host is mutable via options hashref' );
46 }
47
48 {
49         my $response = request( POST( '/bodyparams', { override => 'this' } ) )->content;
50     is($response, 'that', 'body param overridden');
51 }
52
53 {
54         my $response = request( POST( '/bodyparams/no_params' ) )->content;
55     is($response, 'HASH', 'empty body param is hashref');
56 }
57
58 done_testing;
59