|
Lines 876-882
subtest 'GetPreparedLetter' => sub {
Link Here
|
| 876 |
|
876 |
|
| 877 |
|
877 |
|
| 878 |
subtest 'TranslateNotices' => sub { |
878 |
subtest 'TranslateNotices' => sub { |
| 879 |
plan tests => 7; |
879 |
plan tests => 10; |
| 880 |
|
880 |
|
| 881 |
t::lib::Mocks::mock_preference( 'TranslateNotices', '1' ); |
881 |
t::lib::Mocks::mock_preference( 'TranslateNotices', '1' ); |
| 882 |
|
882 |
|
|
Lines 938-943
subtest 'TranslateNotices' => sub {
Link Here
|
| 938 |
is( $letter->{title}, 'a test', |
938 |
is( $letter->{title}, 'a test', |
| 939 |
'GetPreparedLetter should return the default notice if pref disabled but additional language exists' ); |
939 |
'GetPreparedLetter should return the default notice if pref disabled but additional language exists' ); |
| 940 |
|
940 |
|
|
|
941 |
t::lib::Mocks::mock_preference( 'TranslateNotices', '1' ); |
| 942 |
|
| 941 |
my $amount = -20; |
943 |
my $amount = -20; |
| 942 |
my $accountline = $builder->build( |
944 |
my $accountline = $builder->build( |
| 943 |
{ |
945 |
{ |
|
Lines 953-977
subtest 'TranslateNotices' => sub {
Link Here
|
| 953 |
$dbh->do( |
955 |
$dbh->do( |
| 954 |
q| |
956 |
q| |
| 955 |
INSERT INTO letter (module, code, branchcode, name, title, content, message_transport_type, lang) VALUES |
957 |
INSERT INTO letter (module, code, branchcode, name, title, content, message_transport_type, lang) VALUES |
| 956 |
('test_payment', 'code', '', 'Account payment', 'Account payment', "[% PROCESS 'accounts.inc' %][% PROCESS account_type_description account=credit %][% credit.description %]", 'print', 'default'); |
958 |
('test', 'payment', '', 'Paiement du compte', 'Paiement du compte', "[% PROCESS 'accounts.inc' %][% PROCESS account_type_description account=credit %][% credit.description %]", 'print', 'fr-CA'), |
|
|
959 |
('test', 'payment', '', 'Default payment notice', 'Default payment notice', "[% PROCESS 'accounts.inc' %][% PROCESS account_type_description account=credit %][% credit.description %]", 'print', 'default'); |
| 957 |
| |
960 |
| |
| 958 |
); |
961 |
); |
| 959 |
|
962 |
|
|
|
963 |
# Note: How can we mock the above used includes being installed in fr-CA language so we don't have to actually install |
| 964 |
# them for the tests to run :S |
| 965 |
|
| 960 |
$tables = { |
966 |
$tables = { |
| 961 |
borrowers => $borrowernumber, |
967 |
borrowers => $borrowernumber, |
| 962 |
credits => $accountline->{accountlines_id}, |
968 |
credits => $accountline->{accountlines_id}, |
| 963 |
}; |
969 |
}; |
| 964 |
|
970 |
|
| 965 |
$letter = C4::Letters::GetPreparedLetter( |
971 |
$letter = C4::Letters::GetPreparedLetter( |
| 966 |
module => 'test_payment', |
972 |
module => 'test', |
| 967 |
letter_code => 'code', |
973 |
letter_code => 'payment', |
| 968 |
message_transport_type => 'print', |
974 |
message_transport_type => 'print', |
| 969 |
tables => $tables, |
975 |
tables => $tables, |
| 970 |
lang => 'fr-CA', |
976 |
lang => 'fr-CA', |
| 971 |
); |
977 |
); |
|
|
978 |
is( $letter->{title}, 'Paiement du compte', |
| 979 |
'GetPreparedLetter should return the notice in patron\'s preferred language' ); |
| 972 |
like( |
980 |
like( |
| 973 |
$letter->{content}, qr/Paiement/, |
981 |
$letter->{content}, qr/Paiement/, |
| 974 |
'GetPreparedLetter should return the notice in patron\'s preferred language' |
982 |
'Template includes should use the patron\'s preferred language too' |
| 975 |
); |
983 |
); |
| 976 |
|
984 |
|
| 977 |
my $context = Test::MockModule->new('C4::Context'); |
985 |
my $context = Test::MockModule->new('C4::Context'); |
|
Lines 981-1007
subtest 'TranslateNotices' => sub {
Link Here
|
| 981 |
t::lib::Mocks::mock_preference( 'language', 'fr-CA,en' ); |
989 |
t::lib::Mocks::mock_preference( 'language', 'fr-CA,en' ); |
| 982 |
|
990 |
|
| 983 |
$letter = C4::Letters::GetPreparedLetter( |
991 |
$letter = C4::Letters::GetPreparedLetter( |
| 984 |
module => 'test_payment', |
992 |
module => 'test', |
| 985 |
letter_code => 'code', |
993 |
letter_code => 'payment', |
| 986 |
message_transport_type => 'print', |
994 |
message_transport_type => 'print', |
| 987 |
tables => $tables, |
995 |
tables => $tables, |
| 988 |
lang => 'default', |
996 |
lang => 'default', |
| 989 |
); |
997 |
); |
|
|
998 |
is( $letter->{title}, 'Default payment notice', |
| 999 |
'GetPreparedLetter should return the notice in default language' ); |
| 990 |
like( $letter->{content}, qr/Paiement/, 'GetPreparedLetter should return the notice in the interface language' ); |
1000 |
like( $letter->{content}, qr/Paiement/, 'GetPreparedLetter should return the notice in the interface language' ); |
| 991 |
|
1001 |
|
| 992 |
$context->mock( 'interface', 'cron' ); |
1002 |
$context->mock( 'interface', 'cron' ); |
| 993 |
|
1003 |
|
| 994 |
$letter = C4::Letters::GetPreparedLetter( |
1004 |
$letter = C4::Letters::GetPreparedLetter( |
| 995 |
module => 'test_payment', |
1005 |
module => 'test', |
| 996 |
letter_code => 'code', |
1006 |
letter_code => 'payment', |
| 997 |
message_transport_type => 'print', |
1007 |
message_transport_type => 'print', |
| 998 |
tables => $tables, |
1008 |
tables => $tables, |
| 999 |
lang => 'default' |
1009 |
lang => 'default' |
| 1000 |
); |
1010 |
); |
|
|
1011 |
is( $letter->{title}, 'Default payment notice', |
| 1012 |
'GetPreparedLetter should return the notice in default language' ); |
| 1001 |
like( |
1013 |
like( |
| 1002 |
$letter->{content}, qr/Paiement/, |
1014 |
$letter->{content}, qr/Paiement/, |
| 1003 |
'GetPreparedLetter should return the notice in the first language in language system preference' |
1015 |
'GetPreparedLetter should return the notice in the first language in language system preference' |
| 1004 |
); |
1016 |
); |
|
|
1017 |
|
| 1018 |
t::lib::Mocks::mock_preference( 'TranslateNotices', '0' ); |
| 1019 |
|
| 1020 |
# Note: What should happen when TranslateNotices is disabled? The default might be translated and thus we need to ensure we're |
| 1021 |
# using the right template + includes consistently again |
| 1005 |
}; |
1022 |
}; |
| 1006 |
|
1023 |
|
| 1007 |
subtest 'Test SMS handling in SendQueuedMessages' => sub { |
1024 |
subtest 'Test SMS handling in SendQueuedMessages' => sub { |
| 1008 |
- |
|
|