From 520de088de9a5defa1738aba58719661a3b80f69 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Fri, 25 Apr 2025 11:46:09 +0200 Subject: [PATCH] Bug 39745: Fix wrong system preference 'language' in test suite (mock_preference) Bug 27490 renamed system preference language to StaffInterfaceLanguages. Needs to be done in test suite on mock_preference calls Test by running impacted tests Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart Signed-off-by: Lucas Gass (cherry picked from commit 15345742574432f52b4010c942d82099a04ea125) Signed-off-by: Jacob O'Mara --- t/db_dependent/Auth.t | 12 ++++++------ t/db_dependent/Koha/ItemTypes.t | 4 ++-- t/db_dependent/Koha/SharedContent.t | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t index 502838b91c..8e7ebf7fca 100755 --- a/t/db_dependent/Auth.t +++ b/t/db_dependent/Auth.t @@ -527,8 +527,8 @@ subtest 'get_template_and_user' => sub { # Tests for the language URL paramet t::lib::Mocks::mock_preference( 'EnableOpacSearchHistory', 1 ); # Enable es-ES for the OPAC and staff interfaces - t::lib::Mocks::mock_preference( 'OPACLanguages', 'en,es-ES' ); - t::lib::Mocks::mock_preference( 'language', 'en,es-ES' ); + t::lib::Mocks::mock_preference( 'OPACLanguages', 'en,es-ES' ); + t::lib::Mocks::mock_preference( 'StaffInterfaceLanguages', 'en,es-ES' ); # we need a session cookie $ENV{"SERVER_PORT"} = 80; @@ -1192,7 +1192,7 @@ subtest 'checkpw() return values tests' => sub { $password_expired = 1; @return = checkpw( $patron->userid, $password, undef, ); - is( scalar @return, 2, "Two results on expired password scenario" ); + is( scalar @return, 2, "Two results on expired password scenario" ); is( $return[0], -2, '-2 returned' ); is( ref( $return[1] ), 'Koha::Patron' ); is( $return[1]->id, $patron->id, 'Patron matched correctly' ); @@ -1200,7 +1200,7 @@ subtest 'checkpw() return values tests' => sub { t::lib::Mocks::mock_preference( 'AnonymousPatron', $patron->id ); @return = checkpw( $patron->userid, $password, undef, ); - is( scalar @return, 2, "Two results on expired password scenario" ); + is( scalar @return, 2, "Two results on expired password scenario" ); is( $return[0], -3, '-3 returned' ); is( ref( $return[1] ), 'Koha::Patron' ); is( $return[1]->id, $patron->id, 'Patron matched correctly' ); @@ -1284,14 +1284,14 @@ subtest 'checkpw() return values tests' => sub { $password_expired = 1; @return = checkpw( $patron->userid, $password, $query, ); - is( scalar @return, 2, "Two results on expired password scenario" ); + is( scalar @return, 2, "Two results on expired password scenario" ); is( $return[0], -2, '-2 returned' ); is( ref( $return[1] ), 'Koha::Patron' ); is( $return[1]->id, $patron->id, 'Patron matched correctly' ); t::lib::Mocks::mock_preference( 'AnonymousPatron', $patron->id ); @return = checkpw( $patron->userid, $password, undef, ); - is( scalar @return, 2, "Two results on expired password scenario" ); + is( scalar @return, 2, "Two results on expired password scenario" ); is( $return[0], -3, '-3 returned' ); is( ref( $return[1] ), 'Koha::Patron' ); is( $return[1]->id, $patron->id, 'Patron matched correctly' ); diff --git a/t/db_dependent/Koha/ItemTypes.t b/t/db_dependent/Koha/ItemTypes.t index 63852bceba..0970ab6200 100755 --- a/t/db_dependent/Koha/ItemTypes.t +++ b/t/db_dependent/Koha/ItemTypes.t @@ -107,8 +107,8 @@ $type = Koha::ItemTypes->find( $child2->itemtype ); ok( defined($type), 'second result' ); is_deeply( $type->unblessed, $child2->unblessed, "We got back the same object" ); -t::lib::Mocks::mock_preference( 'language', 'en' ); -t::lib::Mocks::mock_preference( 'OPACLanguages', 'en' ); +t::lib::Mocks::mock_preference( 'StaffInterfaceLanguages', 'en' ); +t::lib::Mocks::mock_preference( 'OPACLanguages', 'en' ); my $itemtypes = Koha::ItemTypes->search_with_localization; is( $itemtypes->count, $initial_count1 + 4, 'We added 4 item types' ); my $first_itemtype = $itemtypes->next; diff --git a/t/db_dependent/Koha/SharedContent.t b/t/db_dependent/Koha/SharedContent.t index 1267984571..296df375fa 100755 --- a/t/db_dependent/Koha/SharedContent.t +++ b/t/db_dependent/Koha/SharedContent.t @@ -153,7 +153,7 @@ my $subscription = $builder->build( t::lib::Mocks::mock_userenv( { patron => $loggedinuser } ); -t::lib::Mocks::mock_preference( 'language', 'en' ); +t::lib::Mocks::mock_preference( 'StaffInterfaceLanguages', 'en' ); $post_request = 1; $result = Koha::SharedContent::send_entity(