X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FConfig-Any.git;a=blobdiff_plain;f=t%2F20-parse.t;fp=t%2F20-parse.t;h=640bb79bb3750285bec107b9909af507e28863a2;hp=0000000000000000000000000000000000000000;hb=e967a60fa6fb5adeb6ead013b0b60289b2a92e2e;hpb=59a8045203653a6f6cbccc3c24eb3884fba40ddc diff --git a/t/20-parse.t b/t/20-parse.t new file mode 100644 index 0000000..640bb79 --- /dev/null +++ b/t/20-parse.t @@ -0,0 +1,27 @@ +package MockApp; + +use Test::More tests => 54; +use Scalar::Util qw(blessed reftype); +use Config::Any; + +my @files = map { "t/conf/$_" } + qw(conf.conf conf.ini conf.json conf.pl conf.xml conf.yml); + +for my $f (@files) { + ok(my $c_arr = Config::Any->load_files({files=>[$f], use_ext=>1}), "load_files with use_ext works"); + ok(my $c = $c_arr->[0], "load_files returns an arrayref"); + ok(ref $c, "load_files arrayref contains a ref"); + my $ref = blessed $c ? reftype $c : ref $c; + is(substr($ref,0,4), "HASH", "hashref"); + my ($name, $cfg) = each %$c; + is($name, $f, "filename matches"); + my $cfgref = blessed $cfg ? reftype $cfg : ref $cfg; + is(substr($cfgref,0,4), "HASH", "hashref cfg"); + + is( $cfg->{name}, 'TestApp', "appname parses" ); + is( $cfg->{Component}{ "Controller::Foo" }->{ foo }, 'bar', + "component->cntrlr->foo = bar" ); + is( $cfg->{Model}{ "Model::Baz" }->{ qux }, 'xyzzy', + "model->model::baz->qux = xyzzy" ); +} +