fixed bug: [rt.cpan.org #25143] make tests fails
[p5sagit/Config-Any.git] / t / 61-features.t
1 package MockApp;\r
2 use strict;\r
3 use warnings;\r
4 \r
5 $|++;\r
6 \r
7 use Test::More tests => 10;\r
8 use Scalar::Util qw(blessed reftype);\r
9 \r
10 use Config::Any;\r
11 use Config::Any::INI;\r
12 \r
13 our $cfg_file = 't/conf/conf.foo';\r
14 \r
15 eval { Config::Any::INI->load($cfg_file); };\r
16 SKIP: {\r
17     skip "File loading backend for INI not found", 10 if $@;\r
18 \r
19     ok( my $c_arr = Config::Any->load_files({ \r
20             files           => [ $cfg_file ], \r
21             force_plugins   => [qw(Config::Any::INI)] \r
22         }), "load file with parser forced" );\r
23 \r
24     ok(my $c = $c_arr->[0], "load_files returns an arrayref");\r
25     \r
26     ok(ref $c, "load_files arrayref contains a ref");\r
27     my $ref = blessed $c ? reftype $c : ref $c;\r
28     is(substr($ref,0,4), "HASH", "hashref");\r
29 \r
30     my ($name, $cfg) = each %$c;\r
31     is($name, $cfg_file, "filename matches");\r
32     \r
33     my $cfgref = blessed $cfg ? reftype $cfg : ref $cfg;\r
34     is(substr($cfgref,0,4), "HASH", "hashref cfg");\r
35 \r
36     is( $cfg->{name}, 'TestApp', "appname parses" );\r
37     is( $cfg->{Component}{ "Controller::Foo" }->{ foo }, 'bar',                   \r
38         "component->cntrlr->foo = bar" );\r
39     is( $cfg->{Model}{ "Model::Baz" }->{ qux },                  'xyzzy',                 \r
40         "model->model::baz->qux = xyzzy" );\r
41 \r
42 \r
43     ok( my $c_arr_2 = Config::Any->load_files({ \r
44             files           => [ $cfg_file ], \r
45             force_plugins   => [qw(Config::Any::INI)],\r
46             use_ext         => 1\r
47         }), "load file with parser forced" );\r
48 }\r
49 \r
50 \r
51 \r