X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FConfig-Any.git;a=blobdiff_plain;f=t%2F61-features.t;h=c3512aa99a5d3f0f9aaf91d2d40bbebaf3ea40fc;hp=8436cc6bdf558e00b7fd69cd1cde2e4b25d12edf;hb=f0e3c2214342d0d8a8839009b8b9c7e6bfbc7ab2;hpb=e17d1736c6f94fcf7b5a1f395eaac6ead5882f6c diff --git a/t/61-features.t b/t/61-features.t index 8436cc6..c3512aa 100644 --- a/t/61-features.t +++ b/t/61-features.t @@ -1,51 +1,51 @@ -package MockApp; -use strict; -use warnings; - -$|++; - -use Test::More tests => 10; -use Scalar::Util qw(blessed reftype); - -use Config::Any; -use Config::Any::INI; - -our $cfg_file = 't/conf/conf.foo'; - -eval { Config::Any::INI->load($cfg_file); }; -SKIP: { - skip "File loading backend for INI not found", 10 if $@; - - ok( my $c_arr = Config::Any->load_files({ - files => [ $cfg_file ], - force_plugins => [qw(Config::Any::INI)] - }), "load file with parser forced" ); - - 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, $cfg_file, "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" ); - - - ok( my $c_arr_2 = Config::Any->load_files({ - files => [ $cfg_file ], - force_plugins => [qw(Config::Any::INI)], - use_ext => 1 - }), "load file with parser forced" ); -} - - - +package MockApp; +use strict; +use warnings; + +$|++; + +use Test::More tests => 10; +use Scalar::Util qw(blessed reftype); + +use Config::Any; +use Config::Any::INI; + +our $cfg_file = 't/conf/conf.foo'; + +eval { Config::Any::INI->load($cfg_file); }; +SKIP: { + skip "File loading backend for INI not found", 10 if $@; + + ok( my $c_arr = Config::Any->load_files({ + files => [ $cfg_file ], + force_plugins => [qw(Config::Any::INI)] + }), "load file with parser forced" ); + + 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, $cfg_file, "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" ); + + + ok( my $c_arr_2 = Config::Any->load_files({ + files => [ $cfg_file ], + force_plugins => [qw(Config::Any::INI)], + use_ext => 1 + }), "load file with parser forced" ); +} + + +