Commit | Line | Data |
f0e3c221 |
1 | package MockApp; |
2 | use strict; |
3 | use warnings; |
4 | |
5 | $|++; |
6 | |
7 | use Test::More tests => 10; |
8 | use Scalar::Util qw(blessed reftype); |
9 | |
10 | use Config::Any; |
11 | use Config::Any::INI; |
12 | |
13 | our $cfg_file = 't/conf/conf.foo'; |
14 | |
15 | eval { Config::Any::INI->load($cfg_file); }; |
16 | SKIP: { |
17 | skip "File loading backend for INI not found", 10 if $@; |
18 | |
19 | ok( my $c_arr = Config::Any->load_files({ |
20 | files => [ $cfg_file ], |
21 | force_plugins => [qw(Config::Any::INI)] |
22 | }), "load file with parser forced" ); |
23 | |
24 | ok(my $c = $c_arr->[0], "load_files returns an arrayref"); |
25 | |
26 | ok(ref $c, "load_files arrayref contains a ref"); |
27 | my $ref = blessed $c ? reftype $c : ref $c; |
28 | is(substr($ref,0,4), "HASH", "hashref"); |
29 | |
30 | my ($name, $cfg) = each %$c; |
31 | is($name, $cfg_file, "filename matches"); |
32 | |
33 | my $cfgref = blessed $cfg ? reftype $cfg : ref $cfg; |
34 | is(substr($cfgref,0,4), "HASH", "hashref cfg"); |
35 | |
36 | is( $cfg->{name}, 'TestApp', "appname parses" ); |
37 | is( $cfg->{Component}{ "Controller::Foo" }->{ foo }, 'bar', |
38 | "component->cntrlr->foo = bar" ); |
39 | is( $cfg->{Model}{ "Model::Baz" }->{ qux }, 'xyzzy', |
40 | "model->model::baz->qux = xyzzy" ); |
41 | |
42 | |
43 | ok( my $c_arr_2 = Config::Any->load_files({ |
44 | files => [ $cfg_file ], |
45 | force_plugins => [qw(Config::Any::INI)], |
46 | use_ext => 1 |
47 | }), "load file with parser forced" ); |
48 | } |
49 | |
50 | |
51 | |