X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Flive_catalyst_test.t;h=82485276d4f23e092eaef5f176c796e5311d834f;hp=6f1bacc3bc1b2998f10b2130496749868d04f178;hb=c5949002f09dbace88d6e2cb34fa9ce5f6bb5cad;hpb=38007d99db1774891d373242c86382e6f5cb083a diff --git a/t/live_catalyst_test.t b/t/live_catalyst_test.t index 6f1bacc..8248527 100644 --- a/t/live_catalyst_test.t +++ b/t/live_catalyst_test.t @@ -1,11 +1,59 @@ +use strict; +use warnings; + use FindBin; use lib "$FindBin::Bin/lib"; -use Catalyst::Test 'TestApp'; +use Catalyst::Test 'TestApp', {default_host => 'default.com'}; +use Catalyst::Request; +use HTTP::Request::Common; -use Test::More tests => 5; +use Test::More; content_like('/',qr/root/,'content check'); action_ok('/','Action ok ok','normal action ok'); action_redirect('/engine/response/redirect/one','redirect check'); action_notfound('/engine/response/status/s404','notfound check'); -contenttype_is('/action/local/one','text/plain','Contenttype check'); \ No newline at end of file + +# so we can see the default test name +action_ok('/'); + +contenttype_is('/action/local/one','text/plain','Contenttype check'); + +### local_request() was not setting response base from base href +{ + my $response = request('/base_href_test'); + is( $response->base, 'http://www.example.com/', 'response base set from base href'); +} + +my $creq; +my $req = '/dump/request'; + +{ + eval '$creq = ' . request($req)->content; + is( $creq->uri->host, 'default.com', 'request targets default host set via import' ); +} + +{ + local $Catalyst::Test::default_host = 'localized.com'; + eval '$creq = ' . request($req)->content; + is( $creq->uri->host, 'localized.com', 'target host is mutable via package var' ); +} + +{ + my %opts = ( host => 'opthash.com' ); + eval '$creq = ' . request($req, \%opts)->content; + is( $creq->uri->host, $opts{host}, 'target host is mutable via options hashref' ); +} + +{ + my $response = request( POST( '/bodyparams', { override => 'this' } ) )->content; + is($response, 'that', 'body param overridden'); +} + +{ + my $response = request( POST( '/bodyparams/no_params' ) )->content; + is($response, 'HASH', 'empty body param is hashref'); +} + +done_testing; +