X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Funit_load_catalyst_test.t;h=1b4d86325cd09df53d97b704cda03aa4e3bbb7e9;hb=df3ea11bb1ad740663f2a4c909fba71612aa6a48;hp=0dbf8e3989f27986866debe6c009bba44b06e265;hpb=c7ded7aaf69e506924a5406349fd665c7717acb8;p=catagits%2FCatalyst-Runtime.git diff --git a/t/unit_load_catalyst_test.t b/t/unit_load_catalyst_test.t index 0dbf8e3..1b4d863 100644 --- a/t/unit_load_catalyst_test.t +++ b/t/unit_load_catalyst_test.t @@ -4,8 +4,11 @@ use strict; use warnings; use Test::More; +use FindBin qw/$Bin/; +use lib "$Bin/lib"; +use Catalyst::Utils; -plan tests => 3; +plan tests => 9; use_ok('Catalyst::Test'); @@ -14,3 +17,41 @@ isnt( $@, "", "get returns an error message with no app specified"); eval "request('http://localhost')"; isnt( $@, "", "request returns an error message with no app specified"); + +sub customize { Catalyst::Test::_customize_request(@_) } + +{ + my $req = Catalyst::Utils::request('/dummy'); + customize( $req ); + is( $req->header('Host'), undef, 'normal request is unmodified' ); +} + +{ + my $req = Catalyst::Utils::request('/dummy'); + customize( $req, { host => 'customized.com' } ); + like( $req->header('Host'), qr/customized.com/, 'request is customizable via opts hash' ); +} + +{ + my $req = Catalyst::Utils::request('/dummy'); + local $Catalyst::Test::default_host = 'localized.com'; + customize( $req ); + like( $req->header('Host'), qr/localized.com/, 'request is customizable via package var' ); +} + +{ + my $req = Catalyst::Utils::request('/dummy'); + local $Catalyst::Test::default_host = 'localized.com'; + customize( $req, { host => 'customized.com' } ); + like( $req->header('Host'), qr/customized.com/, 'opts hash takes precedence over package var' ); +} + +{ + my $req = Catalyst::Utils::request('/dummy'); + local $Catalyst::Test::default_host = 'localized.com'; + customize( $req, { host => '' } ); + is( $req->header('Host'), undef, 'default value can be temporarily cleared via opts hash' ); +} + +# Back compat test, extra args used to be ignored, now a hashref of options. +use_ok('Catalyst::Test', 'TestApp', 'foobar');