CatalystX::CRUD was a bug in that module's test suite - RT#42323
[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;
c7ded7aa 10
d258fcb2 11plan tests => 9;
c7ded7aa 12
13use_ok('Catalyst::Test');
14
15eval "get('http://localhost')";
16isnt( $@, "", "get returns an error message with no app specified");
17
18eval "request('http://localhost')";
19isnt( $@, "", "request returns an error message with no app specified");
d9d04ded 20
21sub 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.
57use_ok('Catalyst::Test', 'TestApp', 'foobar');