lots of Config::Any fixes, brought in C::Any testsuite (refactored, partly, from...
[p5sagit/Config-Any.git] / t / 20-parse.t
diff --git a/t/20-parse.t b/t/20-parse.t
new file mode 100644 (file)
index 0000000..640bb79
--- /dev/null
@@ -0,0 +1,27 @@
+package MockApp;\r
+\r
+use Test::More tests => 54;\r
+use Scalar::Util qw(blessed reftype);\r
+use Config::Any;\r
+\r
+my @files = map { "t/conf/$_" } \r
+       qw(conf.conf conf.ini conf.json conf.pl conf.xml conf.yml);\r
+\r
+for my $f (@files) {\r
+       ok(my $c_arr = Config::Any->load_files({files=>[$f], use_ext=>1}), "load_files with use_ext works");\r
+       ok(my $c = $c_arr->[0], "load_files returns an arrayref");\r
+       ok(ref $c, "load_files arrayref contains a ref");\r
+       my $ref = blessed $c ? reftype $c : ref $c;\r
+       is(substr($ref,0,4), "HASH", "hashref");\r
+       my ($name, $cfg) = each %$c;\r
+       is($name, $f, "filename matches");\r
+       my $cfgref = blessed $cfg ? reftype $cfg : ref $cfg;\r
+       is(substr($cfgref,0,4), "HASH", "hashref cfg");\r
+\r
+       is( $cfg->{name}, 'TestApp', "appname parses" );\r
+       is( $cfg->{Component}{ "Controller::Foo" }->{ foo }, 'bar',               \r
+               "component->cntrlr->foo = bar" );\r
+       is( $cfg->{Model}{ "Model::Baz" }->{ qux },              'xyzzy',                 \r
+               "model->model::baz->qux = xyzzy" );\r
+}\r
+\r