pod updates and more tests
[catagits/Catalyst-Plugin-ConfigLoader.git] / t / 20-mock_load.t
1 use Test::More tests => 5;\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 \r
12 package MockApp;\r
13 \r
14 use base qw( Catalyst::Plugin::ConfigLoader );\r
15 use NEXT;\r
16 use Catalyst::Utils;\r
17 \r
18 sub new {\r
19     return bless { }, shift;\r
20 }\r
21 \r
22 sub path_to {\r
23     return 't/mockapp';\r
24 }\r
25 \r
26 sub debug {\r
27     0;\r
28 }\r
29 \r
30 sub config {\r
31     my $self = shift;\r
32     $self->{ _config } = {} unless $self->{ _config };\r
33     if (@_) {\r
34         my $config = @_ > 1 ? {@_} : $_[0];\r
35         while ( my ( $key, $val ) = each %$config ) {\r
36             $self->{ _config }->{$key} = $val;\r
37         }\r
38     }\r
39     return $self->{ _config };\r
40 }\r
41 \r
42 1;