Commit | Line | Data |
4b22d4c6 |
1 | package MockAppEnv; |
ffc0b0d8 |
2 | |
2a3587a2 |
3 | use Test::More; |
ffc0b0d8 |
4 | use Cwd; |
5 | |
6 | # Remove all relevant env variables to avoid accidental fail |
2a3587a2 |
7 | foreach my $name ( grep { m{^(CATALYST|MOCKAPPENV)} } keys %ENV ) { |
8 | delete $ENV{ $name }; |
9 | } |
ffc0b0d8 |
10 | |
2a3587a2 |
11 | $ENV{ CATALYST_HOME } = cwd . '/t/lib/MockAppConfigLoader'; |
12 | $ENV{ MOCKAPPENV_CONFIG } = $ENV{ CATALYST_HOME } . '/mockapp.pl'; |
ffc0b0d8 |
13 | |
2a3587a2 |
14 | use_ok( 'Catalyst' ); |
ffc0b0d8 |
15 | |
2a3587a2 |
16 | __PACKAGE__->config->{substitutions} = { |
17 | foo => sub { shift; join( '-', @_ ); } |
18 | }; |
ffc0b0d8 |
19 | |
2a3587a2 |
20 | __PACKAGE__->setup; |
ffc0b0d8 |
21 | |
663a4f34 |
22 | ok( my $conf = __PACKAGE__->config, 'config loads' ); |
ffc0b0d8 |
23 | is( $conf->{ 'Controller::Foo' }->{ foo }, 'bar' ); |
24 | is( $conf->{ 'Controller::Foo' }->{ new }, 'key' ); |
25 | is( $conf->{ 'Model::Baz' }->{ qux }, 'xyzzy' ); |
26 | is( $conf->{ 'Model::Baz' }->{ another }, 'new key' ); |
27 | is( $conf->{ 'view' }, 'View::TT::New' ); |
28 | is( $conf->{ 'foo_sub' }, 'x-y' ); |
663a4f34 |
29 | is( $conf->{ 'literal_macro' }, '__DATA__', 'literal macro' ); |
30 | is( $conf->{ 'environment_macro' }, $ENV{ CATALYST_HOME }.'/mockapp.pl', 'environment macro' ); |
2a3587a2 |
31 | |
32 | done_testing; |