f576f47b02f47548654b469188ed9e5eaaa5b5ae
[catagits/Catalyst-Plugin-ConfigLoader.git] / t / 20-mock_load.t
1 use Test::More tests => 6;\r
2 \r
3 my $app = MockApp->new;\r
4 $app->setup;\r
5 \r
6 ok( $app->config );\r
7 is( $app->config->{ 'Controller::Foo' }->{ foo }, 'bar' );\r
8 is( $app->config->{ 'Controller::Foo' }->{ new }, 'key' );\r
9 is( $app->config->{ 'Model::Baz' }->{ qux }, 'xyzzy' );\r
10 is( $app->config->{ 'Model::Baz' }->{ another }, 'new key' );\r
11 is( $app->config->{ 'view' }, 'View::TT::New' );\r
12 \r
13 package MockApp;\r
14 \r
15 use base qw( Catalyst::Plugin::ConfigLoader );\r
16 use NEXT;\r
17 use Catalyst::Utils;\r
18 \r
19 sub new {\r
20     return bless { }, shift;\r
21 }\r
22 \r
23 sub path_to {\r
24     return 't/mockapp';\r
25 }\r
26 \r
27 sub debug {\r
28     0;\r
29 }\r
30 \r
31 sub config {\r
32     my $self = shift;\r
33     $self->{ _config } = {} unless $self->{ _config };\r
34     if (@_) {\r
35         my $config = @_ > 1 ? {@_} : $_[0];\r
36         while ( my ( $key, $val ) = each %$config ) {\r
37             $self->{ _config }->{$key} = $val;\r
38         }\r
39     }\r
40     return $self->{ _config };\r
41 }\r
42 \r
43 1;