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