From b823ddddb9dbc6528d07d7aeaf12283cf73f35b4 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 21 Mar 2025 07:00:22 -0400 Subject: [PATCH] Bug 39407: Add unit test to prove no active currency crashes SIP Signed-off-by: Magnus Enger --- t/db_dependent/SIP/Patron.t | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/SIP/Patron.t b/t/db_dependent/SIP/Patron.t index fc6e03bd28..5ed96417a9 100755 --- a/t/db_dependent/SIP/Patron.t +++ b/t/db_dependent/SIP/Patron.t @@ -12,6 +12,7 @@ use t::lib::TestBuilder; use C4::SIP::ILS::Patron; use Koha::Account::Lines; +use Koha::Acquisition::Currencies; use Koha::Database; use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Patron::Attributes; @@ -35,7 +36,7 @@ is( $sip_patron2, undef, "Patron is not valid (anymore)" ); subtest "new tests" => sub { - plan tests => 5; + plan tests => 6; my $patron = $builder->build( { source => 'Borrower' } ); @@ -53,6 +54,11 @@ subtest "new tests" => sub { is( ref($ils_patron), 'C4::SIP::ILS::Patron', 'Found patron via cardnumber hashref' ); $ils_patron = C4::SIP::ILS::Patron->new( { userid => $userid } ); is( ref($ils_patron), 'C4::SIP::ILS::Patron', 'Found patron via userid hashref' ); + + # Verify that having no active currency does not crash C4::SIP::ILS::Patron::new + Koha::Acquisition::Currencies->get_active->active(0)->store(); + $ils_patron = C4::SIP::ILS::Patron->new( { userid => $userid } ); + is( ref($ils_patron), 'C4::SIP::ILS::Patron', 'Found patron when no active currency is defined' ); }; subtest "OverduesBlockCirc tests" => sub { -- 2.34.1