7 use Test::More tests => 54;
8 use Scalar::Util qw(blessed reftype);
10 use Config::Any::General;
12 use Config::Any::JSON;
13 use Config::Any::Perl;
15 use Config::Any::YAML;
18 conf => 'Config::Any::General',
19 ini => 'Config::Any::INI',
20 json => 'Config::Any::JSON',
21 pl => 'Config::Any::Perl',
22 xml => 'Config::Any::XML',
23 yml => 'Config::Any::YAML'
30 my ( $ext ) = $f =~ m{ \. ( [^\.]+ ) \z }xms;
31 my $mod = $ext_map{ $ext };
32 return !$mod->is_supported ? ( 1, $mod ) : ( 0, $mod );
35 for my $f ( map { "t/conf/conf.$_" } keys %ext_map ) {
36 my ( $skip, $mod ) = load_parser_for( $f );
38 skip "File loading backend for $mod not found", 9 if $skip;
41 = Config::Any->load_files(
42 { files => [ $f ], use_ext => 1 } ),
43 "load_files with use_ext works [$f]"
45 ok( my $c = $c_arr->[ 0 ], "load_files returns an arrayref" );
47 ok( ref $c, "load_files arrayref contains a ref" );
48 my $ref = blessed $c ? reftype $c : ref $c;
49 is( substr( $ref, 0, 4 ), "HASH", "hashref" );
51 my ( $name, $cfg ) = each %$c;
52 is( $name, $f, "filename matches" );
54 my $cfgref = blessed $cfg ? reftype $cfg : ref $cfg;
55 is( substr( $cfgref, 0, 4 ), "HASH", "hashref cfg" );
57 is( $cfg->{ name }, 'TestApp', "appname parses" );
58 is( $cfg->{ Component }{ "Controller::Foo" }->{ foo },
59 'bar', "component->cntrlr->foo = bar" );
60 is( $cfg->{ Model }{ "Model::Baz" }->{ qux },
61 'xyzzy', "model->model::baz->qux = xyzzy" );