7 use Test::More tests => 14;
8 use Scalar::Util qw(blessed reftype);
13 our $cfg_file = 't/conf/conf.foo';
15 eval { Config::Any::INI->load( $cfg_file ); };
18 skip "File loading backend for INI not found", 14 if $@;
20 my $struct; # used to make sure parsing works for arrays and hashes
24 my $result = Config::Any->load_files(
25 { files => [ $cfg_file ],
26 force_plugins => [ qw(Config::Any::INI) ]
30 ok( $result, 'load file with parser forced' );
32 ok( my $first = $result->[ 0 ], 'load_files returns an arrayref' );
33 ok( ref $first, 'load_files arrayref contains a ref' );
35 my $ref = blessed $first ? reftype $first : ref $first;
36 is( substr( $ref, 0, 4 ), 'HASH', 'hashref' );
40 my ( $name, $cfg ) = %$first;
41 is( $name, $cfg_file, 'filenames match' );
43 my $cfgref = blessed $cfg ? reftype $cfg : ref $cfg;
44 is( substr( $cfgref, 0, 4 ), 'HASH', 'hashref cfg' );
46 is( $cfg->{ name }, 'TestApp', 'appname parses' );
47 is( $cfg->{ Component }{ "Controller::Foo" }->{ foo },
48 'bar', 'component->cntrlr->foo = bar' );
49 is( $cfg->{ Model }{ "Model::Baz" }->{ qux },
50 'xyzzy', 'model->model::baz->qux = xyzzy' );
55 my $result = Config::Any->load_files(
56 { files => [ $cfg_file ],
57 force_plugins => [ qw(Config::Any::INI) ],
62 ok( $result, 'load file with parser forced, flatten to hash' );
63 ok( ref $result, 'load_files hashref contains a ref' );
65 my $ref = blessed $result ? reftype $result : ref $result;
66 is( substr( $ref, 0, 4 ), 'HASH', 'hashref' );
68 is_deeply( $result, $struct,
69 'load_files return an hashref (flatten_to_hash)' );
74 ok( my $result = Config::Any->load_files(
75 { files => [ $cfg_file ],
76 force_plugins => [ qw(Config::Any::INI) ],
80 "load file with parser forced"