Authentication back compat fail due to ::ClassData not behaving like C::D::I, not...
[catagits/Catalyst-Runtime.git] / t / unit_load_catalyst_test.t
CommitLineData
c7ded7aa 1#!perl
2
3use strict;
4use warnings;
5
6use Test::More;
d9d04ded 7use Catalyst::Utils;
c7ded7aa 8
d9d04ded 9plan tests => 8;
c7ded7aa 10
11use_ok('Catalyst::Test');
12
13eval "get('http://localhost')";
14isnt( $@, "", "get returns an error message with no app specified");
15
16eval "request('http://localhost')";
17isnt( $@, "", "request returns an error message with no app specified");
d9d04ded 18
19sub 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}