lemonldap-ng/modules/lemonldap-ng-portal/t/10-Lemonldap-NG-Portal-i18n.t

51 lines
1.5 KiB
Perl
Raw Normal View History

2008-06-06 05:53:14 +02:00
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Lemonldap-NG-Portal.t'
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
BEGIN {
2010-09-29 09:24:56 +02:00
our %tr_err = (
2008-06-06 05:53:14 +02:00
fr => 'French',
2010-10-14 12:25:50 +02:00
# Not yet maintained
2010-09-29 09:24:56 +02:00
ro => 'Romanian',
2008-06-06 05:53:14 +02:00
);
2010-09-29 09:24:56 +02:00
our %tr_msg = ( fr => 'French', );
2008-06-06 05:53:14 +02:00
}
2010-09-29 09:24:56 +02:00
use Test::More tests => 7 + ( keys(%tr_err) * 2 ) + ( keys(%tr_msg) * 2 );
2008-06-06 05:53:14 +02:00
2010-09-29 09:24:56 +02:00
BEGIN { use_ok('Lemonldap::NG::Portal::Simple') }
2008-06-06 05:53:14 +02:00
ok( my @en = @{&Lemonldap::NG::Portal::_i18n::error_en},
'English translation' );
ok( $#en > 21, 'Translation count' );
2010-09-29 09:24:56 +02:00
foreach ( keys %tr_err ) {
my @tmp;
ok( @tmp = @{ &{"Lemonldap::NG::Portal::_i18n::error_$_"} },
"$tr_err{$_} translation" );
2010-10-14 12:25:50 +02:00
ok( $#tmp == $#en, "$tr_err{$_} translation count (" . scalar(@tmp) . ')' );
2008-06-06 05:53:14 +02:00
}
my $p = bless {}, 'Lemonldap::NG::Portal::Simple';
$p->{error} = 10;
$ENV{HTTP_ACCEPT_LANGUAGE} = 'fr';
ok( $p->error() eq $p->error('fr'), 'HTTP_ACCEPT_LANGUAGE mechanism 1' );
ok( $p->error() ne $p->error('ro'), 'HTTP_ACCEPT_LANGUAGE mechanism 2' );
2010-09-29 09:24:56 +02:00
ok( @en = @{&Lemonldap::NG::Portal::_i18n::msg_en},
'English messages translation' );
ok( $#en > 19, 'Messages translation count' );
foreach ( keys %tr_msg ) {
my @tmp;
ok( @tmp = @{ &{"Lemonldap::NG::Portal::_i18n::msg_$_"} },
"$tr_msg{$_} messages translation" );
2010-10-14 12:25:50 +02:00
ok( $#tmp == $#en,
"$tr_msg{$_} messages translation count (" . scalar(@tmp) . ')' );
2010-09-29 09:24:56 +02:00
}