Bugzilla – Attachment 165479 Details for
Bug 33237
If TranslateNotices is off, use the default language includes in slips
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33237: Rearrange unit tests and ensure consistency
Bug-33237-Rearrange-unit-tests-and-ensure-consiste.patch (text/plain), 9.54 KB, created by
Martin Renvoize (ashimema)
on 2024-04-24 15:45:34 UTC
(
hide
)
Description:
Bug 33237: Rearrange unit tests and ensure consistency
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-04-24 15:45:34 UTC
Size:
9.54 KB
patch
obsolete
>From 234a852957c38e7e15742909556610bb563220ec Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 24 Apr 2024 16:38:40 +0100 >Subject: [PATCH] Bug 33237: Rearrange unit tests and ensure consistency > >This patch re-arranges the unit tests and sets them to ensure we >consistently return the notice and notice includes in the same language. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Letters.t | 158 +++++++++++++++++---------------------- > 1 file changed, 69 insertions(+), 89 deletions(-) > >diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t >index fdd97353f58..8ae4bcd3e24 100755 >--- a/t/db_dependent/Letters.t >+++ b/t/db_dependent/Letters.t >@@ -879,73 +879,11 @@ subtest 'GetPreparedLetter' => sub { > > }; > >- >- > subtest 'TranslateNotices' => sub { > plan tests => 10; > >- t::lib::Mocks::mock_preference( 'TranslateNotices', '1' ); >- >- $dbh->do( >- q| >- INSERT INTO letter (module, code, branchcode, name, title, content, message_transport_type, lang) VALUES >- ('test', 'code', '', 'test', 'a test', 'just a test', 'email', 'default'), >- ('test', 'code', '', 'test', 'una prueba', 'solo una prueba', 'email', 'es-ES'); >- | ); >- my $substitute = {}; >- my $letter = C4::Letters::GetPreparedLetter( >- module => 'test', >- tables => $tables, >- letter_code => 'code', >- message_transport_type => 'email', >- substitute => $substitute, >- ); >- is( >- $letter->{title}, >- 'a test', >- 'GetPreparedLetter should return the default one if the lang parameter is not provided' >- ); >- # Note: What about includes, which language should be assumed 'default' here? >- >- $letter = C4::Letters::GetPreparedLetter( >- module => 'test', >- tables => $tables, >- letter_code => 'code', >- message_transport_type => 'email', >- substitute => $substitute, >- lang => 'es-ES', >- ); >- is( $letter->{title}, 'una prueba', >- 'GetPreparedLetter should return the required notice if it exists' ); >- >- $letter = C4::Letters::GetPreparedLetter( >- module => 'test', >- tables => $tables, >- letter_code => 'code', >- message_transport_type => 'email', >- substitute => $substitute, >- lang => 'fr-FR', >- ); >- is( >- $letter->{title}, >- 'a test', >- 'GetPreparedLetter should return the default notice if the one required does not exist' >- ); >- >- t::lib::Mocks::mock_preference( 'TranslateNotices', '' ); >- >- $letter = C4::Letters::GetPreparedLetter( >- module => 'test', >- tables => $tables, >- letter_code => 'code', >- message_transport_type => 'email', >- substitute => $substitute, >- lang => 'es-ES', >- ); >- is( $letter->{title}, 'a test', >- 'GetPreparedLetter should return the default notice if pref disabled but additional language exists' ); >- >- t::lib::Mocks::mock_preference( 'TranslateNotices', '1' ); >+ t::lib::Mocks::mock_config( 'intrahtdocs', '/kohadevbox/koha/t/mock_templates/intranet-tmpl' ); >+ t::lib::Mocks::mock_preference( 'OPACLanguages', 'fr-CA,en' ); > > my $amount = -20; > my $accountline = $builder->build( >@@ -962,63 +900,105 @@ subtest 'TranslateNotices' => sub { > $dbh->do( > q| > INSERT INTO letter (module, code, branchcode, name, title, content, message_transport_type, lang) VALUES >- ('test', 'payment', '', 'Paiement du compte', 'Paiement du compte', "[% PROCESS 'accounts.inc' %][% PROCESS account_type_description account=credit %][% credit.description %]", 'print', 'fr-CA'), >- ('test', 'payment', '', 'Default payment notice', 'Default payment notice', "[% PROCESS 'accounts.inc' %][% PROCESS account_type_description account=credit %][% credit.description %]", 'print', 'default'); >+ ('test', 'payment', '', 'Default notice', 'Default notice', "[% PROCESS 'accounts.inc' %][% PROCESS account_type_description account=credit %][% credit.description %]", 'print', 'default'), >+ ('test', 'payment', '', 'Default notice', 'English notice', "[% PROCESS 'accounts.inc' %][% PROCESS account_type_description account=credit %][% credit.description %]", 'print', 'en'), >+ ('test', 'payment', '', 'Paiement du compte', 'Paiement du compte', "[% PROCESS 'accounts.inc' %][% PROCESS account_type_description account=credit %][% credit.description %]", 'print', 'fr-CA'); > | > ); >- >- t::lib::Mocks::mock_config( 'intrahtdocs', '/kohadevbox/koha/t/mock_templates/intranet-tmpl' ); >- > $tables = { > borrowers => $borrowernumber, > credits => $accountline->{accountlines_id}, > }; >+ my $substitute = {}; > >- $letter = C4::Letters::GetPreparedLetter( >+ t::lib::Mocks::mock_preference( 'TranslateNotices', '1' ); >+ >+ my $letter = C4::Letters::GetPreparedLetter( > module => 'test', >+ tables => $tables, > letter_code => 'payment', > message_transport_type => 'print', >+ substitute => $substitute, >+ ); >+ is( >+ $letter->{title}, >+ 'Default notice', >+ 'GetPreparedLetter should return the default one if the lang parameter is not provided' >+ ); >+ like( >+ $letter->{content}, qr/Paiement/, >+ 'Template includes match the default language from OPACLanguages (default = fr-CA)' >+ ); >+ >+ $letter = C4::Letters::GetPreparedLetter( >+ module => 'test', > tables => $tables, >+ letter_code => 'payment', >+ message_transport_type => 'print', >+ substitute => $substitute, > lang => 'fr-CA', > ); >- is( $letter->{title}, 'Paiement du compte', >- 'GetPreparedLetter should return the notice in patron\'s preferred language' ); >+ is( >+ $letter->{title}, 'Paiement du compte', >+ 'GetPreparedLetter should return the requested language notice if it exists (fr-CA = default)' >+ ); > like( > $letter->{content}, qr/Paiement/, >- 'Template includes should use the patron\'s preferred language too' >+ 'Template includes should use the requested language too (fr-CA = default)' > ); > >- my $context = Test::MockModule->new('C4::Context'); >- $context->mock( 'interface', 'intranet' ); >- >- Koha::Cache::Memory::Lite->get_instance()->clear_from_cache('getlanguage'); >- t::lib::Mocks::mock_preference( 'language', 'fr-CA,en' ); >- > $letter = C4::Letters::GetPreparedLetter( > module => 'test', >+ tables => $tables, > letter_code => 'payment', > message_transport_type => 'print', >+ substitute => $substitute, >+ lang => 'en', >+ ); >+ is( >+ $letter->{title}, 'English notice', >+ 'GetPreparedLetter should return the requested language notice if it exists (en != default)' >+ ); >+ like( >+ $letter->{content}, qr/Payment/, >+ 'Template includes should use the requested language too (en != default)' >+ ); >+ >+ $letter = C4::Letters::GetPreparedLetter( >+ module => 'test', > tables => $tables, >- lang => 'default', >+ letter_code => 'payment', >+ message_transport_type => 'print', >+ substitute => $substitute, >+ lang => 'fr-FR', >+ ); >+ is( >+ $letter->{title}, >+ 'Default notice', >+ 'GetPreparedLetter should return the default notice if the one requested language notice does not exist (default = fr-CA)' >+ ); >+ like( >+ $letter->{content}, qr/Paiement/, >+ 'Template includes should use the default language too if the requested language notice does not exist (default = fr-CA)' > ); >- is( $letter->{title}, 'Default payment notice', >- 'GetPreparedLetter should return the notice in default language' ); >- like( $letter->{content}, qr/Paiement/, 'GetPreparedLetter should return the notice in the interface language' ); > >- $context->mock( 'interface', 'cron' ); >+ t::lib::Mocks::mock_preference( 'TranslateNotices', '' ); > > $letter = C4::Letters::GetPreparedLetter( > module => 'test', >+ tables => $tables, > letter_code => 'payment', > message_transport_type => 'print', >- tables => $tables, >- lang => 'default' >+ substitute => $substitute, >+ lang => 'en', >+ ); >+ is( >+ $letter->{title}, 'Default notice', >+ 'GetPreparedLetter should return the default notice if pref disabled but additional language exists' > ); >- is( $letter->{title}, 'Default payment notice', >- 'GetPreparedLetter should return the notice in default language' ); > like( > $letter->{content}, qr/Paiement/, >- 'GetPreparedLetter should return the notice in the first language in language system preference' >+ 'Template includes should use the default language if pref disabled but additional language exists (default = fr-CA)' > ); > }; > >-- >2.44.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33237
:
148281
|
148785
|
163952
|
163953
|
164521
|
165382
|
165383
|
165384
|
165404
|
165405
|
165406
|
165455
|
165456
|
165457
|
165458
|
165459
|
165460
|
165473
|
165474
|
165475
|
165476
|
165477
|
165478
| 165479 |
165480
|
166860