Add a test for getting the whole language property hash.

Reformat the getLanguage method according to WGBP.
This commit is contained in:
Colin Kuskie 2007-12-28 00:15:15 +00:00
parent 44162ea113
commit abf56513c7
2 changed files with 17 additions and 14 deletions

View file

@ -141,20 +141,21 @@ sub getLanguage {
$file =~ s{::}{/}g;
$file .= '.pm';
eval{require $file};
unless ($@) {
$cmd = "\$".$cmd."::LANGUAGE";
my $hashRef = eval($cmd);
$self->session->errorHandler->warn("Failed to retrieve language properties because ".$@) if ($@);
if ($property) {
return $hashRef->{$property};
}
else {
return $hashRef;
}
}
else {
if ($@) {
$self->session->errorHandler->warn("Language failed to compile: $language. ".$@);
}
return;
}
$cmd = '$'.$cmd.'::LANGUAGE';
## no critic ProhibitStringyEval
my $hashRef = eval($cmd);
## use critic;
$self->session->errorHandler->warn("Failed to retrieve language properties because ".$@) if ($@);
if ($property) {
return $hashRef->{$property};
}
else {
return $hashRef;
}
}

View file

@ -21,7 +21,7 @@ my $session = WebGUI::Test->session;
my $numTests = 1; ##For conditional load check
my $langTests = 2; ##For language look-up tests
$numTests += 10 + $langTests;
$numTests += 11 + $langTests;
plan tests => $numTests;
@ -71,6 +71,8 @@ SKIP: {
is($i18n->getLanguage('English', 'label'), 'English', 'getLanguage, specific property');
isa_ok($i18n->getLanguage('English'), 'HASH', 'getLanguage, without a specific property returns a hashref');
}
sub installPigLatin {