Ready for 7.10.29 development.

This commit is contained in:
Colin Kuskie 2013-03-20 21:38:23 -07:00
commit c806f99b7b
4236 changed files with 1217679 additions and 0 deletions

48
t/i18n/adminConsole.t Normal file
View file

@ -0,0 +1,48 @@
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use FindBin;
use strict;
use warnings;
use lib "$FindBin::Bin/../lib"; ##t/lib
use WebGUI::Test;
use WebGUI::International;
use WebGUI::Session;
use WebGUI::Macro;
#The goal of this test is to verify all the i18n labels in
#the Admin Console functions
use Test::More; # increment this value for each test you create
my $numTests = 0;
my $session = WebGUI::Test->session;
my $lib = WebGUI::Test->lib;
# put your tests here
my %consoleFuncs = %{ $session->config->get("adminConsole") };
$numTests = scalar keys %consoleFuncs;
plan tests => $numTests;
my $i18n = WebGUI::International->new($session);
my ($label, $func);
foreach my $key (keys %consoleFuncs ) {
my $label = $consoleFuncs{$key}{title};
WebGUI::Macro::process($session, \$label);
isnt($label,'', "admin console func $key: ".$consoleFuncs{$key}{title});
}

38
t/i18n/critic_labels.t Normal file
View file

@ -0,0 +1,38 @@
# vim:syntax=perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------
# Write a little about what this script tests.
#
#
use Path::Class;
use FindBin;
use strict;
use lib "$FindBin::Bin/../lib";
use Test::More;
plan skip_all => 'set CODE_COP to enable this test' unless $ENV{CODE_COP};
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
##Delay this so that the skip_all can work the way it should
eval { require Test::Perl::Critic; };
if ($@) {
plan skip_all => "Test::Perl::Critic not installed";
}
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
my $label_profile = Path::Class::File->new( WebGUI::Test->root , 't', 'i18n', 'perlcriticrc');
Test::Perl::Critic->import(-profile => $label_profile->stringify);
all_critic_ok(WebGUI::Test->lib);

145
t/i18n/help.t Normal file
View file

@ -0,0 +1,145 @@
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use FindBin;
use strict;
use warnings;
use lib "$FindBin::Bin/../lib"; ##t/lib
use WebGUI::Test;
use WebGUI::Operation::Help;
use WebGUI::International;
use WebGUI::Session;
use Data::Dumper;
#The goal of this test is to verify all the i18n labels in
#the help files. It used to be glommed into the same test as
#the code scanner, but was broken out due to speed issues.
use Test::More; # increment this value for each test you create
my $numTests = 0;
my $session = WebGUI::Test->session;
my @helpFileSet = WebGUI::Operation::Help::_getHelpFilesList($session);
my %helpTable;
foreach my $helpSet (@helpFileSet) {
my $helpName = $helpSet->[1];
my $help = WebGUI::Operation::Help::_load($session, $helpName);
$helpTable{ $helpName } = $help;
}
##Scan #1, find all labels in the help system. body, title, @fields
## Array of hashes
## each hash will have:
## topic -> which help file it is from
## entry -> which entry in the help file
## tag -> which tag in the entry in the help file
## namespace -> which help file it is form
## label -> which help file it is form
my @helpLabels;
my @sqlLabels;
my @libLabels;
my @objLabels;
@helpLabels = getHelpLabels();
$numTests = scalar(@helpLabels);
plan tests => $numTests;
my $i18n = WebGUI::International->new($session);
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', });
}
sub getHelpLabels {
my %seenLabel = ();
my @helpLabels = ();
foreach my $topic ( keys %helpTable ) {
foreach my $entry ( keys %{ $helpTable{$topic} }) {
##Check the title and body data
push @helpLabels, {
topic=>$topic,
entry=>$entry,
tag=>'title',
namespace=>$topic, ##default
label=>$helpTable{$topic}{$entry}{'title'},
} unless $seenLabel{$topic}{$helpTable{$topic}{$entry}{'title'}}++;
if ($helpTable{$topic}{$entry}{'body'} and ref $helpTable{$topic}{$entry}{'body'} ne 'CODE') {
push @helpLabels, {
topic=>$topic,
entry=>$entry,
tag=>'body',
namespace=>$topic, ##default
label=>$helpTable{$topic}{$entry}{'body'},
} unless $seenLabel{$topic}{$helpTable{$topic}{$entry}{'title'}}++;
}
##Add all labels in the fields array
foreach my $field (@{ $helpTable{$topic}{$entry}{fields} }) {
push @helpLabels, {
topic=>$topic,
entry=>$entry,
tag=>'fields',
namespace=>$field->{namespace},
label=>$field->{title},
} unless $seenLabel{$field->{namespace}}{$field->{title}}++;
push @helpLabels, {
topic=>$topic,
entry=>$entry,
tag=>'fields',
namespace=>$field->{namespace},
label=>$field->{description},
} unless $seenLabel{$field->{namespace}}{$field->{description}}++;
}
my $variableEntries = getHelpVariables($helpTable{$topic}{$entry}{variables});
foreach my $variable ( @{ $variableEntries } ) {
my $namespace = exists $variable->{namespace} ? $variable->{namespace} : $topic;
my $one = {
topic=>$topic,
entry=>$entry,
tag=>'variables',
namespace=>$namespace,
};
if ($variable->{description}) {
$one->{label} = $variable->{description},
}
else {
$one->{label} = $variable->{name},
}
push @helpLabels, $one
unless $seenLabel{$namespace}{$one->{label}}++;
}
}
}
return @helpLabels;
}
sub getHelpVariables {
my ($variables) = @_; ##An arrayref of variables, possibly with nested variables in loops
my $tmplVars = [];
foreach my $var ( @{ $variables } ) {
if ( exists $var->{variables} ) {
push @{ $tmplVars }, @{ getHelpVariables($var->{variables}) };
delete $var->{variables};
}
push @{ $tmplVars }, $var;
}
return $tmplVars;
}

2
t/i18n/perlcriticrc Normal file
View file

@ -0,0 +1,2 @@
only = 1
include = NoIllegalI18NLabels

88
t/i18n/template.t Normal file
View file

@ -0,0 +1,88 @@
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use FindBin;
use strict;
use warnings;
use lib "$FindBin::Bin/../lib"; ##t/lib
use WebGUI::Test;
use WebGUI::Operation::Help;
use WebGUI::International;
use WebGUI::Session;
use Data::Dumper;
use WebGUI::Asset::Template;
use WebGUI::Macro::Callback;
#The goal of this test is to locate all of the international labels that it
#can and verify that they exist in all loaded language models
use Test::More; # increment this value for each test you create
my $numTests = 0;
my $session = WebGUI::Test->session;
my $lib = WebGUI::Test->lib;
## Remove all macros but International, and set them to call WebGUI::Macro::Callback
WebGUI::Test->originalConfig('macros');
my $originalMacros = $session->config->get('macros');
my $configFileMacros = {};
for my $macro (keys %$originalMacros) {
if ($originalMacros->{$macro} eq 'International') {
$configFileMacros->{$macro} = 'Callback';
}
}
$session->config->set('macros', $configFileMacros);
# put your tests here
my $getATemplate = WebGUI::Asset::Template->getIsa($session);
my @templateLabels;
my @questionableTemplates;
while (my $templateAsset = $getATemplate->()) {
my $template = $templateAsset->get('template');
if (!$template) {
push @questionableTemplates, {
url => $templateAsset->getUrl,
id => $templateAsset->getId,
title => $templateAsset->getTitle,
};
}
WebGUI::Macro::Callback::setCallback(sub {
my ($session, $label, $namespace) = @_;
push @templateLabels, {
label => $label,
namespace => $namespace,
url => $templateAsset->getUrl,
id => $templateAsset->getId,
title => $templateAsset->getTitle,
};
});
WebGUI::Macro::process($session, \$template);
}
$numTests = scalar @templateLabels + scalar @questionableTemplates;
plan tests => $numTests;
my $i18n = WebGUI::International->new($session);
foreach my $label ( @templateLabels ) {
ok($i18n->get(@{ $label }{qw(label namespace )} ),
sprintf "label: %s->%s inside %s, id: %s, url: %s", @{ $label }{qw/namespace label title id url/});
}
foreach my $label ( @questionableTemplates ) {
fail(
sprintf "Empty template: %s, id: %s, url: %s", @{ $label }{qw/title id url/}
);
}