added test configs
[p5sagit/Config-Any.git] / t / 20-parse.t
CommitLineData
e967a60f 1package MockApp;\r
2\r
3use Test::More tests => 54;\r
4use Scalar::Util qw(blessed reftype);\r
5use Config::Any;\r
6\r
7my @files = map { "t/conf/$_" } \r
8 qw(conf.conf conf.ini conf.json conf.pl conf.xml conf.yml);\r
9\r
10for my $f (@files) {\r
11 ok(my $c_arr = Config::Any->load_files({files=>[$f], use_ext=>1}), "load_files with use_ext works");\r
12 ok(my $c = $c_arr->[0], "load_files returns an arrayref");\r
13 ok(ref $c, "load_files arrayref contains a ref");\r
14 my $ref = blessed $c ? reftype $c : ref $c;\r
15 is(substr($ref,0,4), "HASH", "hashref");\r
16 my ($name, $cfg) = each %$c;\r
17 is($name, $f, "filename matches");\r
18 my $cfgref = blessed $cfg ? reftype $cfg : ref $cfg;\r
19 is(substr($cfgref,0,4), "HASH", "hashref cfg");\r
20\r
21 is( $cfg->{name}, 'TestApp', "appname parses" );\r
22 is( $cfg->{Component}{ "Controller::Foo" }->{ foo }, 'bar', \r
23 "component->cntrlr->foo = bar" );\r
24 is( $cfg->{Model}{ "Model::Baz" }->{ qux }, 'xyzzy', \r
25 "model->model::baz->qux = xyzzy" );\r
26}\r
27\r