10 use HTTP::Request::Common;
14 use_ok('Catalyst::Test');
16 eval "get('http://localhost')";
17 isnt( $@, "", "get returns an error message with no app specified");
19 eval "request('http://localhost')";
20 isnt( $@, "", "request returns an error message with no app specified");
22 # FIXME - These vhosts in tests tests should be somewhere else...
24 sub customize { Catalyst::Test::_customize_request(@_) }
27 my $req = Catalyst::Utils::request('/dummy');
29 is( $req->header('Host'), undef, 'normal request is unmodified' );
33 my $req = Catalyst::Utils::request('/dummy');
34 customize( $req, { host => 'customized.com' } );
35 like( $req->header('Host'), qr/customized.com/, 'request is customizable via opts hash' );
39 my $req = Catalyst::Utils::request('/dummy');
40 local $Catalyst::Test::default_host = 'localized.com';
42 like( $req->header('Host'), qr/localized.com/, 'request is customizable via package var' );
46 my $req = Catalyst::Utils::request('/dummy');
47 local $Catalyst::Test::default_host = 'localized.com';
48 customize( $req, { host => 'customized.com' } );
49 like( $req->header('Host'), qr/customized.com/, 'opts hash takes precedence over package var' );
53 my $req = Catalyst::Utils::request('/dummy');
54 local $Catalyst::Test::default_host = 'localized.com';
55 customize( $req, { host => '' } );
56 is( $req->header('Host'), undef, 'default value can be temporarily cleared via opts hash' );
59 # Back compat test, extra args used to be ignored, now a hashref of options.
60 use_ok('Catalyst::Test', 'TestApp', 'foobar');
62 # Back compat test, ensure that request ignores anything which isn't a hash.
64 request(GET('/dummy'), 'foo');
65 } 'scalar additional param to request method ignored';
67 request(GET('/dummy'), []);
68 } 'array additional param to request method ignored';