fixed DataForm/diagnose.t

Added find() and findAndLoad() to WebGUI::Pluggable and updated sbin/preload.perl
This commit is contained in:
Doug Bell 2008-10-27 16:16:18 +00:00
parent 0c320d8c01
commit 314035912d
5 changed files with 177 additions and 18 deletions

View file

@ -10,7 +10,7 @@
use FindBin;
use strict;
use lib "$FindBin::Bin/../../lib";
use lib "$FindBin::Bin/../../../lib";
##The goal of this test is to diagnose problems in DataForms.
## Orphaned DataForms with no Asset table entries

View file

@ -17,7 +17,20 @@ use strict;
use lib "$FindBin::Bin/lib";
use Test::More;
use WebGUI::Test;
use File::Find;
use File::Spec;
use Test::Deep;
# Must load some Test::Deep modules before we start modifying @INC
use Test::Deep::Array;
use Test::Deep::ArrayLength;
use Test::Deep::ArrayLengthOnly;
use Test::Deep::ArrayElementsOnly;
use Test::Deep::RefType;
use Test::Deep::Shallow;
use Test::Deep::Blessed;
use Test::Deep::Isa;
use Test::Deep::Set;
use WebGUI::Pluggable;
@ -28,7 +41,7 @@ use WebGUI::Pluggable;
#----------------------------------------------------------------------------
# Tests
plan tests => 4; # Increment this number for each test you create
plan tests => 7; # Increment this number for each test you create
#----------------------------------------------------------------------------
# put your tests here
@ -49,6 +62,47 @@ is($dumper->Dump, q|$VAR1 = {
};
|, "Can instanciate an object.");
#----------------------------------------------------------------------------
# Test find and findAndLoad
{ # Block to localize @INC
my $lib = WebGUI::Test->lib;
local @INC = ( $lib );
# Use the i18n files to test
my @testFiles = ();
File::Find::find(
sub {
if ( !/^[.]/ && /[.]pm$/ ) {
my $name = $File::Find::name;
$name =~ s{^$lib[/]}{};
$name =~ s/[.]pm$//;
$name =~ s{/}{::}g;
push @testFiles, $name;
}
},
File::Spec->catfile( $lib, 'WebGUI', 'i18n' ),
);
cmp_deeply(
[ WebGUI::Pluggable::find( 'WebGUI::i18n' ) ],
bag( @testFiles ),
"find() finds all modules by default",
);
cmp_deeply(
[ WebGUI::Pluggable::find( 'WebGUI::i18n', { onelevel => 1 } ) ],
bag( grep { /^WebGUI::i18n::[^:]+$/ } @testFiles ),
"find() with onelevel",
);
cmp_deeply(
[ WebGUI::Pluggable::find( 'WebGUI::i18n', { exclude => [ 'WebGUI::i18n::English::WebGUI' ] } ) ],
bag( grep { $_ ne 'WebGUI::i18n::English::WebGUI' } @testFiles ),
"find() with exclude",
);
};
#----------------------------------------------------------------------------
# Cleanup