Doc for MX::E::CAF list assign bug, TODO updates incl Prefork tested
[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;
c7ded7aa 11
4348c28b 12plan tests => 11;
c7ded7aa 13
14use_ok('Catalyst::Test');
15
16eval "get('http://localhost')";
17isnt( $@, "", "get returns an error message with no app specified");
18
19eval "request('http://localhost')";
20isnt( $@, "", "request returns an error message with no app specified");
d9d04ded 21
4348c28b 22# FIXME - These vhosts in tests tests should be somewhere else...
23
d9d04ded 24sub customize { Catalyst::Test::_customize_request(@_) }
25
26{
27 my $req = Catalyst::Utils::request('/dummy');
28 customize( $req );
29 is( $req->header('Host'), undef, 'normal request is unmodified' );
30}
31
32{
33 my $req = Catalyst::Utils::request('/dummy');
34 customize( $req, { host => 'customized.com' } );
35 like( $req->header('Host'), qr/customized.com/, 'request is customizable via opts hash' );
36}
37
38{
39 my $req = Catalyst::Utils::request('/dummy');
40 local $Catalyst::Test::default_host = 'localized.com';
41 customize( $req );
42 like( $req->header('Host'), qr/localized.com/, 'request is customizable via package var' );
43}
44
45{
46 my $req = Catalyst::Utils::request('/dummy');
47 local $Catalyst::Test::default_host = 'localized.com';
48 customize( $req, { host => 'customized.com' } );
49 like( $req->header('Host'), qr/customized.com/, 'opts hash takes precedence over package var' );
50}
51
52{
53 my $req = Catalyst::Utils::request('/dummy');
54 local $Catalyst::Test::default_host = 'localized.com';
55 customize( $req, { host => '' } );
56 is( $req->header('Host'), undef, 'default value can be temporarily cleared via opts hash' );
57}
d258fcb2 58
59# Back compat test, extra args used to be ignored, now a hashref of options.
60use_ok('Catalyst::Test', 'TestApp', 'foobar');
4348c28b 61
62# Back compat test, ensure that request ignores anything which isn't a hash.
63lives_ok {
64 request(GET('/dummy'), 'foo');
65} 'scalar additional param to request method ignored';
66lives_ok {
67 request(GET('/dummy'), []);
68} 'array additional param to request method ignored';