5 3_conf_00_base.t - Test for the basic functionality of CGI::Ex::Conf
10 use Test::More tests => 24;
12 use_ok('CGI::Ex::Conf');
15 $dir =~ tr|\\|/|; # should probably use File::Spec
16 $dir =~ s|[^/]+$|../samples| || die "Couldn't determine dir";
17 $dir =~ s|^t/|./t/|; # to satisfy conf
19 my $obj = CGI::Ex::Conf->new({
20 paths => ["$dir/conf_path_1", "$dir/conf_path_3"],
23 ### most test for the reading of files
24 ### are actually performed in the validation tests
28 my $hash = $obj->read('apples.pl');
30 ok($hash->{quantity});
32 $hash = $obj->read('apples.pl');
34 ok($hash->{quantity});
37 local $CGI::Ex::Conf::DIRECTIVE = 'FIRST';
38 $hash = $obj->read('apples.pl');
40 ok($hash->{quantity} == 20);
41 ok($hash->{foo} eq 'file1');
43 local $CGI::Ex::Conf::DIRECTIVE = 'LAST';
44 $hash = $obj->read('apples.pl');
46 ok($hash->{quantity} == 30);
47 ok($hash->{foo} eq 'file2');
49 $hash = $obj->read('apples.pl', {directive => 'MERGE'});
51 ok($hash->{quantity} == 30);
52 ok($hash->{foo} eq 'file1'); # has immutable value
55 local $obj->{directive} = 'FIRST';
56 $hash = $obj->read('oranges.pl');
58 ok($hash->{quantity} == 20);
59 ok($hash->{foo} eq 'file1');
61 local $obj->{directive} = 'LAST';
62 $hash = $obj->read('oranges.pl');
64 ok($hash->{quantity} == 30);
65 ok($hash->{foo} eq 'file2');
67 local $obj->{directive} = 'MERGE';
68 $hash = $obj->read('oranges.pl');
70 ok($hash->{quantity} == 20); # has immutable key so all values are immutable
71 ok($hash->{foo} eq 'file1'); # has immutable key so all values are immutable