View | Details | Raw Unified | Return to bug 33237
Collapse All | Expand All

(-)a/t/db_dependent/Letters.t (-2 / +65 lines)
Lines 882-888 subtest 'GetPreparedLetter' => sub { Link Here
882
882
883
883
884
subtest 'TranslateNotices' => sub {
884
subtest 'TranslateNotices' => sub {
885
    plan tests => 4;
885
    plan tests => 7;
886
886
887
    t::lib::Mocks::mock_preference( 'TranslateNotices', '1' );
887
    t::lib::Mocks::mock_preference( 'TranslateNotices', '1' );
888
888
Lines 944-949 subtest 'TranslateNotices' => sub { Link Here
944
    is( $letter->{title}, 'a test',
944
    is( $letter->{title}, 'a test',
945
        'GetPreparedLetter should return the default notice if pref disabled but additional language exists' );
945
        'GetPreparedLetter should return the default notice if pref disabled but additional language exists' );
946
946
947
    my $amount      = -20;
948
    my $accountline = $builder->build(
949
        {
950
            source => 'Accountline',
951
            value  => {
952
                borrowernumber    => $borrowernumber,
953
                amount            => $amount,
954
                amountoutstanding => $amount,
955
                credit_type_code  => 'PAYMENT',
956
            }
957
        }
958
    );
959
    $dbh->do(
960
        q|
961
        INSERT INTO letter (module, code, branchcode, name, title, content, message_transport_type, lang) VALUES
962
        ('test_payment', 'code', '', 'Account payment', 'Account payment', "[% PROCESS 'accounts.inc' %][% PROCESS account_type_description account=credit %][% credit.description %]", 'print', 'default');
963
    |
964
    );
965
966
    $tables = {
967
        borrowers => $borrowernumber,
968
        credits   => $accountline->{accountlines_id},
969
    };
970
971
    $letter = C4::Letters::GetPreparedLetter(
972
        module                 => 'test_payment',
973
        letter_code            => 'code',
974
        message_transport_type => 'print',
975
        tables                 => $tables,
976
        lang                   => 'fr-CA',
977
    );
978
    like(
979
        $letter->{content}, qr/Paiement/,
980
        'GetPreparedLetter should return the notice in patron\'s preferred language'
981
    );
982
983
    my $context = Test::MockModule->new('C4::Context');
984
    $context->mock( 'interface', 'intranet' );
985
986
    Koha::Cache::Memory::Lite->get_instance()->clear_from_cache('getlanguage');
987
    t::lib::Mocks::mock_preference( 'language', 'fr-CA,en' );
988
989
    $letter = C4::Letters::GetPreparedLetter(
990
        module                 => 'test_payment',
991
        letter_code            => 'code',
992
        message_transport_type => 'print',
993
        tables                 => $tables,
994
        lang                   => 'default',
995
    );
996
    like( $letter->{content}, qr/Paiement/, 'GetPreparedLetter should return the notice in the interface language' );
997
998
    $context->mock( 'interface', 'cron' );
999
1000
    $letter = C4::Letters::GetPreparedLetter(
1001
        module                 => 'test_payment',
1002
        letter_code            => 'code',
1003
        message_transport_type => 'print',
1004
        tables                 => $tables,
1005
        lang                   => 'default'
1006
    );
1007
    like(
1008
        $letter->{content}, qr/Paiement/,
1009
        'GetPreparedLetter should return the notice in the first language in language system preference'
1010
    );
947
};
1011
};
948
1012
949
subtest 'Test SMS handling in SendQueuedMessages' => sub {
1013
subtest 'Test SMS handling in SendQueuedMessages' => sub {
950
- 

Return to bug 33237