fixes for new session and i18n APIs
This commit is contained in:
parent
441e6e1d4a
commit
d67e2cf9ed
2 changed files with 42 additions and 34 deletions
|
|
@ -36,8 +36,6 @@ plan tests => $numTests;
|
||||||
|
|
||||||
diag("Check for mandatory lables for Help table of contents");
|
diag("Check for mandatory lables for Help table of contents");
|
||||||
|
|
||||||
diag(Dumper(\@helpFileSet));
|
|
||||||
|
|
||||||
foreach my $fileSet (@helpFileSet) {
|
foreach my $fileSet (@helpFileSet) {
|
||||||
my $file = $fileSet->[1];
|
my $file = $fileSet->[1];
|
||||||
ok(WebGUI::Operation::Help::_getHelpName($session, $file), "Missing label for $file");
|
ok(WebGUI::Operation::Help::_getHelpName($session, $file), "Missing label for $file");
|
||||||
|
|
|
||||||
74
t/i18n.t
74
t/i18n.t
|
|
@ -15,6 +15,7 @@ use Text::Balanced qw(extract_codeblock);
|
||||||
use Getopt::Long;
|
use Getopt::Long;
|
||||||
use WebGUI::Operation::Help;
|
use WebGUI::Operation::Help;
|
||||||
use WebGUI::International;
|
use WebGUI::International;
|
||||||
|
use WebGUI::Session;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
use File::Find;
|
use File::Find;
|
||||||
# ---- END DO NOT EDIT ----
|
# ---- END DO NOT EDIT ----
|
||||||
|
|
@ -33,6 +34,7 @@ my $digits = qr/(\d+)/;
|
||||||
my $bareword = qr/(\w+)/;
|
my $bareword = qr/(\w+)/;
|
||||||
my $quotelike = qr/((['"])([^'"\s]+\s*)+(['"]))/;
|
my $quotelike = qr/((['"])([^'"\s]+\s*)+(['"]))/;
|
||||||
my $sub_args = qr/(($quotelike|$digits)(,\s*)?)+/;
|
my $sub_args = qr/(($quotelike|$digits)(,\s*)?)+/;
|
||||||
|
my $sess_arg = qr/(?:\$session|\$self->session)/;
|
||||||
my $subroutine = qr/
|
my $subroutine = qr/
|
||||||
WebGUI::International::get
|
WebGUI::International::get
|
||||||
\( ##Opening paren for optional arguments
|
\( ##Opening paren for optional arguments
|
||||||
|
|
@ -43,11 +45,11 @@ my $subroutine = qr/
|
||||||
|
|
||||||
my %helpTable;
|
my %helpTable;
|
||||||
|
|
||||||
my @helpFileSet = WebGUI::Operation::Help::_getHelpFilesList();
|
my @helpFileSet = WebGUI::Operation::Help::_getHelpFilesList($session);
|
||||||
|
|
||||||
foreach my $helpSet (@helpFileSet) {
|
foreach my $helpSet (@helpFileSet) {
|
||||||
my $helpName = $helpSet->[1];
|
my $helpName = $helpSet->[1];
|
||||||
my $help = WebGUI::Operation::Help::_load($helpName);
|
my $help = WebGUI::Operation::Help::_load($session, $helpName);
|
||||||
$helpTable{ $helpName } = $help;
|
$helpTable{ $helpName } = $help;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,29 +63,33 @@ foreach my $helpSet (@helpFileSet) {
|
||||||
## namespace -> which help file it is form
|
## namespace -> which help file it is form
|
||||||
## label -> which help file it is form
|
## label -> which help file it is form
|
||||||
|
|
||||||
diag("Getting Help labels");
|
my @helpLabels;
|
||||||
my @helpLabels = getHelpLabels();
|
my @sqlLabels;
|
||||||
|
|
||||||
diag("Getting SQL labels");
|
|
||||||
my @sqlLabels = getSQLLabels();
|
|
||||||
|
|
||||||
my @libLabels;
|
my @libLabels;
|
||||||
|
my @objLabels;
|
||||||
|
|
||||||
|
diag("Getting Help labels");
|
||||||
|
@helpLabels = getHelpLabels();
|
||||||
|
|
||||||
|
#diag("Getting SQL labels");
|
||||||
|
#@sqlLabels = getSQLLabels();
|
||||||
|
|
||||||
diag("Getting subroutine labels");
|
diag("Getting subroutine labels");
|
||||||
find(\&label_finder_pm, '../lib/');
|
find(\&label_finder_pm, '../lib/');
|
||||||
|
|
||||||
my @objLabels;
|
|
||||||
diag("Getting object labels");
|
diag("Getting object labels");
|
||||||
find(\&obj_finder_pm, '../lib/');
|
find(\&obj_finder_pm, '../lib/');
|
||||||
|
|
||||||
diag ("Checking ". scalar(@helpLabels). " help labels");
|
diag ("Checking ". scalar(@helpLabels). " help labels");
|
||||||
diag ("Checking ". scalar(@sqlLabels). " SQL labels");
|
#diag ("Checking ". scalar(@sqlLabels). " SQL labels");
|
||||||
diag ("Checking ". scalar(@libLabels). " library code labels");
|
diag ("Checking ". scalar(@libLabels). " library code labels");
|
||||||
diag ("Checking ". scalar(@objLabels). " library code labels via object");
|
diag ("Checking ". scalar(@objLabels). " library code labels via object");
|
||||||
|
|
||||||
$numTests = scalar(@helpLabels)
|
$numTests = scalar(@helpLabels)
|
||||||
+ scalar(@sqlLabels)
|
# + scalar(@sqlLabels)
|
||||||
+ scalar(@libLabels)
|
+ scalar(@libLabels)
|
||||||
+ scalar(@objLabels);
|
+ scalar(@objLabels)
|
||||||
|
;
|
||||||
|
|
||||||
diag("Planning on running $numTests tests\n");
|
diag("Planning on running $numTests tests\n");
|
||||||
|
|
||||||
|
|
@ -91,30 +97,33 @@ plan tests => $numTests;
|
||||||
|
|
||||||
diag("Help Label tests\n");
|
diag("Help Label tests\n");
|
||||||
|
|
||||||
foreach my $i18n ( @helpLabels ) {
|
my $i18n = WebGUI::International->new($session);
|
||||||
ok(WebGUI::International::get(@{ $i18n }{qw(label namespace )} ),
|
|
||||||
sprintf "label: %s->%s inside %s->%s->%s", @{ $i18n }{'namespace', 'label', 'topic', 'entry', 'tag', });
|
foreach my $label ( @helpLabels ) {
|
||||||
}
|
ok($i18n->get(@{ $label }{qw(label namespace )} ),
|
||||||
|
sprintf "label: %s->%s inside %s->%s->%s", @{ $label }{'namespace', 'label', 'topic', 'entry', 'tag', });
|
||||||
diag("SQL Label tests\n");
|
|
||||||
|
|
||||||
foreach my $i18n ( @sqlLabels ) {
|
|
||||||
ok(WebGUI::International::get(@{ $i18n }{qw(label namespace )} ),
|
|
||||||
sprintf "label: %s->%s inside %s", @{ $i18n }{'namespace', 'label', 'file', });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#diag("SQL Label tests\n");
|
||||||
|
#
|
||||||
|
#foreach my $label ( @sqlLabels ) {
|
||||||
|
# ok($i18n->get(@{ $label }{qw(label namespace )} ),
|
||||||
|
# sprintf "label: %s->%s inside %s", @{ $label }{'namespace', 'label', 'file', });
|
||||||
|
#}
|
||||||
|
#
|
||||||
|
##Subroutine calls are now illegal, everything must be done by object methods.
|
||||||
diag("Subroutine Call Label tests\n");
|
diag("Subroutine Call Label tests\n");
|
||||||
|
|
||||||
foreach my $i18n ( @libLabels ) {
|
foreach my $label ( @libLabels ) {
|
||||||
ok(WebGUI::International::get(@{ $i18n }{qw(label namespace )} ),
|
ok(0,
|
||||||
sprintf "label: %s->%s inside %s", @{ $i18n }{'namespace', 'label', 'file', });
|
sprintf "label: %s->%s inside %s", @{ $label }{'namespace', 'label', 'file', });
|
||||||
}
|
}
|
||||||
|
|
||||||
diag("Object Method Label tests\n");
|
diag("Object Method Label tests\n");
|
||||||
|
|
||||||
foreach my $i18n ( @objLabels ) {
|
foreach my $label ( @objLabels ) {
|
||||||
ok(WebGUI::International::get(@{ $i18n }{qw(label namespace )} ),
|
ok($i18n->get(@{ $label }{qw(label namespace )} ),
|
||||||
sprintf "label: %s->%s inside %s", @{ $i18n }{'namespace', 'label', 'file', });
|
sprintf "label: %s->%s inside %s", @{ $label }{'namespace', 'label', 'file', });
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup($session); # this line is required
|
cleanup($session); # this line is required
|
||||||
|
|
@ -151,13 +160,14 @@ sub obj_finder_pm {
|
||||||
close $pmf;
|
close $pmf;
|
||||||
##Advance pos to first subroutine
|
##Advance pos to first subroutine
|
||||||
while ( my $subBody = extract_codeblock($libFile, '{}', qr/(?ms).*?^sub (\w+)\s*/) ) {
|
while ( my $subBody = extract_codeblock($libFile, '{}', qr/(?ms).*?^sub (\w+)\s*/) ) {
|
||||||
next unless $subBody =~ /(\w+)\s*=\s*WebGUI::International->new\(($quotelike)\)/;
|
next unless $subBody =~ /(\w+)\s*=\s*WebGUI::International->new\($sess_arg(?:,\s*($quotelike))?\)/;
|
||||||
my ($obj, $namespace) = ($1,$2);
|
my ($obj, $namespace) = ($1,$2);
|
||||||
while ( $subBody =~ /$obj\->get\(($sub_args)\)/msgc ) {
|
while ( $subBody =~ /$obj\->get\(($sub_args)\)/msgc ) {
|
||||||
|
my ($label, $local_name) = split /,\s*/, $1;
|
||||||
push @objLabels, {
|
push @objLabels, {
|
||||||
file=>$File::Find::name,
|
file=>$File::Find::name,
|
||||||
label=>$1,
|
label=>$label,
|
||||||
namespace=>$namespace || 'WebGUI',
|
namespace=>$local_name || $namespace || 'WebGUI',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -233,7 +243,7 @@ sub initialize {
|
||||||
'configFile=s'=>\$configFile
|
'configFile=s'=>\$configFile
|
||||||
);
|
);
|
||||||
exit 1 unless ($configFile);
|
exit 1 unless ($configFile);
|
||||||
my $session = WebGUI::Session->open("..",$configFile);
|
return WebGUI::Session->open("..",$configFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub cleanup {
|
sub cleanup {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue