Fix my retardedness with ::MVC:: warning having no conditional. Pull all the stuff...
[catagits/Catalyst-Runtime.git] / t / unit_load_catalyst_test.t
CommitLineData
c7ded7aa 1#!perl
2
3use strict;
4use warnings;
5
6use Test::More;
d258fcb2 7use FindBin qw/$Bin/;
8use lib "$Bin/lib";
d9d04ded 9use Catalyst::Utils;
4348c28b 10use HTTP::Request::Common;
6f8be318 11use Test::Exception;
c7ded7aa 12
4348c28b 13plan tests => 11;
c7ded7aa 14
15use_ok('Catalyst::Test');
16
17eval "get('http://localhost')";
18isnt( $@, "", "get returns an error message with no app specified");
19
20eval "request('http://localhost')";
21isnt( $@, "", "request returns an error message with no app specified");
d9d04ded 22
4348c28b 23# FIXME - These vhosts in tests tests should be somewhere else...
24
d9d04ded 25sub customize { Catalyst::Test::_customize_request(@_) }
26
27{
28 my $req = Catalyst::Utils::request('/dummy');
29 customize( $req );
30 is( $req->header('Host'), undef, 'normal request is unmodified' );
31}
32
33{
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' );
37}
38
39{
40 my $req = Catalyst::Utils::request('/dummy');
41 local $Catalyst::Test::default_host = 'localized.com';
42 customize( $req );
43 like( $req->header('Host'), qr/localized.com/, 'request is customizable via package var' );
44}
45
46{
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' );
51}
52
53{
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' );
58}
d258fcb2 59
60# Back compat test, extra args used to be ignored, now a hashref of options.
61use_ok('Catalyst::Test', 'TestApp', 'foobar');
4348c28b 62
63# Back compat test, ensure that request ignores anything which isn't a hash.
64lives_ok {
65 request(GET('/dummy'), 'foo');
66} 'scalar additional param to request method ignored';
67lives_ok {
68 request(GET('/dummy'), []);
69} 'array additional param to request method ignored';