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