Commit | Line | Data |
c7ded7aa |
1 | #!perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More; |
d9d04ded |
7 | use Catalyst::Utils; |
c7ded7aa |
8 | |
d9d04ded |
9 | plan tests => 8; |
c7ded7aa |
10 | |
11 | use_ok('Catalyst::Test'); |
12 | |
13 | eval "get('http://localhost')"; |
14 | isnt( $@, "", "get returns an error message with no app specified"); |
15 | |
16 | eval "request('http://localhost')"; |
17 | isnt( $@, "", "request returns an error message with no app specified"); |
d9d04ded |
18 | |
19 | sub customize { Catalyst::Test::_customize_request(@_) } |
20 | |
21 | { |
22 | my $req = Catalyst::Utils::request('/dummy'); |
23 | customize( $req ); |
24 | is( $req->header('Host'), undef, 'normal request is unmodified' ); |
25 | } |
26 | |
27 | { |
28 | my $req = Catalyst::Utils::request('/dummy'); |
29 | customize( $req, { host => 'customized.com' } ); |
30 | like( $req->header('Host'), qr/customized.com/, 'request is customizable via opts hash' ); |
31 | } |
32 | |
33 | { |
34 | my $req = Catalyst::Utils::request('/dummy'); |
35 | local $Catalyst::Test::default_host = 'localized.com'; |
36 | customize( $req ); |
37 | like( $req->header('Host'), qr/localized.com/, 'request is customizable via package var' ); |
38 | } |
39 | |
40 | { |
41 | my $req = Catalyst::Utils::request('/dummy'); |
42 | local $Catalyst::Test::default_host = 'localized.com'; |
43 | customize( $req, { host => 'customized.com' } ); |
44 | like( $req->header('Host'), qr/customized.com/, 'opts hash takes precedence over package var' ); |
45 | } |
46 | |
47 | { |
48 | my $req = Catalyst::Utils::request('/dummy'); |
49 | local $Catalyst::Test::default_host = 'localized.com'; |
50 | customize( $req, { host => '' } ); |
51 | is( $req->header('Host'), undef, 'default value can be temporarily cleared via opts hash' ); |
52 | } |