5 use lib "$FindBin::Bin/lib";
11 # Remove all relevant env variables to avoid accidental fail
12 foreach my $name ( grep { m{^(CATALYST|MOCKAPP)} } keys %ENV ) {
16 eval { require Catalyst; Catalyst->VERSION( '5.80001' ); };
18 plan skip_all => 'Catalyst 5.80001 required' if $@;
21 require_ok 'Catalyst::Test';
25 ## TestApp1: a .conf config file exists but should not be loaded
28 Catalyst::Test->import('TestApp1');
32 ok my ( $res, $c ) = ctx_request( '/' ), 'context object';
34 isa_ok( $c, "TestApp1" );
36 subtest "normal config loaded" => sub {
38 is( get( '/appconfig/foo' ), "bar1", "config var foo ok" );
40 ## a config var not set will give a blank web page hence ""
41 is( get( '/appconfig/bar' ), "", "config var in custom config" );
44 is( get( '/appconfig/bar' ), "", "custom config not loaded" );
47 ## TestApp2: config points to a file in addition to normal config and
50 Catalyst::Test->import('TestApp2');
54 ok my ( $res, $c ) = ctx_request( '/' ), 'context object';
56 isa_ok( $c, "TestApp2" );
58 subtest "normal config loaded" => sub {
60 is( get( '/appconfig/foo' ), "bar2", "config var foo" );
62 is( get( '/appconfig/unspecified_variable' ), "", "unknown config var" );
66 is( get( '/appconfig/bar' ), "baz2", "custom config loaded" );
69 ## TestApp3: config points to a directory
71 Catalyst::Test->import('TestApp3');
75 ok my ( $res, $c ) = ctx_request( '/' ), 'context object';
77 isa_ok( $c, "TestApp3" );
79 subtest "normal config loaded" => sub {
81 is( get( '/appconfig/foo' ), "bar3", "config var foo" );
83 is( get( '/appconfig/unspecified_variable' ), "", "unknown config var" );
87 is( get( '/appconfig/test3_conf1' ), "a_value", "custom config var1 set" );
88 is( get( '/appconfig/test3_conf2' ), "a_value", "custom config var2 set" );
89 is( get( '/appconfig/test3_conf3' ), "a_value", "custom config var3 set" );
90 is( get( '/appconfig/test3_conf4' ), "", "custom config var4 not set" );
94 ## TestApp4: config points to a directory with a suffix
96 Catalyst::Test->import('TestApp4');
100 ok my ( $res, $c ) = ctx_request( '/' ), 'context object';
102 isa_ok( $c, "TestApp4" );
104 subtest "normal config loaded" => sub {
106 is( get( '/appconfig/foo' ), "bar4", "config var foo" );
108 is( get( '/appconfig/unspecified_variable' ), "", "unknown config var" );
112 is( get( '/appconfig/test4_conf1' ), "a_value", "custom config var1 set" );
113 is( get( '/appconfig/test4_conf2' ), "a_value", "custom config var2 set" );
114 is( get( '/appconfig/test4_conf3' ), "a_value", "custom config var3 set" );
115 is( get( '/appconfig/test4_conf4' ), "", "custom config var4 not set" );