From 4e18cb4af881d436f4f0a2f968803af6ebc810d1 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 2 Sep 2025 12:39:36 +0200 Subject: [PATCH] Bug 40680: Fix C4::Calendar imports Attempt to call undefined import method with arguments (new ...) via package C4::Calendar (Perhaps you forgot to load the package?) at t/db_dependent/Hold.t line 25. --- t/db_dependent/Circulation.t | 22 +++++++++++----------- t/db_dependent/Circulation/CalcDateDue.t | 2 +- t/db_dependent/Hold.t | 20 +++++++++++++------- t/db_dependent/HoldsQueue.t | 2 +- t/db_dependent/Koha/Charges/Fees.t | 2 +- t/db_dependent/Koha/ItemTypes.t | 2 +- 6 files changed, 28 insertions(+), 22 deletions(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index dda4983a4a2..1e90807128a 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -34,7 +34,7 @@ use t::lib::Mocks; use t::lib::TestBuilder; use C4::Accounts; -use C4::Calendar qw( new insert_single_holiday insert_week_day_holiday delete_holiday ); +use C4::Calendar; use C4::Circulation qw( AddIssue AddReturn CanBookBeRenewed GetIssuingCharges AddRenewal GetSoonestRenewDate GetLatestAutoRenewDate LostItem GetUpcomingDueIssues CanBookBeIssued AddIssuingCharge MarkIssueReturned ProcessOfflinePayment transferbook ); use C4::Biblio; @@ -1183,7 +1183,7 @@ subtest "CanBookBeRenewed tests" => sub { ); my $ten_days_before = dt_from_string->add( days => -10 ); - my $ten_days_ahead = dt_from_string->add( days => 10 ); + my $ten_days_ahead = dt_from_string->add( days => 10 ); my $issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } @@ -1333,7 +1333,7 @@ subtest "CanBookBeRenewed tests" => sub { ); my $ten_days_before = dt_from_string->add( days => -10 ); - my $ten_days_ahead = dt_from_string->add( days => 10 ); + my $ten_days_ahead = dt_from_string->add( days => 10 ); my $issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } @@ -1443,7 +1443,7 @@ subtest "CanBookBeRenewed tests" => sub { ); my $ten_days_before = dt_from_string->add( days => -10 ); - my $ten_days_ahead = dt_from_string->add( days => 10 ); + my $ten_days_ahead = dt_from_string->add( days => 10 ); # Patron is expired and BlockExpiredPatronOpacActions='' # => auto renew is allowed @@ -1495,7 +1495,7 @@ subtest "CanBookBeRenewed tests" => sub { ); my $ten_days_before = dt_from_string->add( days => -10 ); - my $ten_days_ahead = dt_from_string->add( days => 10 ); + my $ten_days_ahead = dt_from_string->add( days => 10 ); my $issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } @@ -1616,7 +1616,7 @@ subtest "CanBookBeRenewed tests" => sub { ); my $ten_days_before = dt_from_string->add( days => -10 ); - my $ten_days_ahead = dt_from_string->add( days => 10 ); + my $ten_days_ahead = dt_from_string->add( days => 10 ); my $issue = AddIssue( $renewing_borrower_obj, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } @@ -1967,7 +1967,7 @@ subtest "GetUpcomingDueIssues" => sub { my $a_borrower = Koha::Patrons->find($a_borrower_borrowernumber); my $yesterday = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 ); - my $two_days_ahead = DateTime->today( time_zone => C4::Context->tz() )->add( days => 2 ); + my $two_days_ahead = DateTime->today( time_zone => C4::Context->tz() )->add( days => 2 ); my $today = DateTime->today( time_zone => C4::Context->tz() ); my $issue = AddIssue( $a_borrower, $item_1->barcode, $yesterday ); @@ -3879,7 +3879,7 @@ subtest 'AddReturn | is_overdue' => sub { is( $line->status, 'RETURNED', "Overdue fine is fixed" ); $line = $lines->next; is( $line->amount + 0, -2, "Original payment amount remains as 2" ); - is( $line->amountoutstanding + 0, 0, "Original payment remains applied" ); + is( $line->amountoutstanding + 0, 0, "Original payment remains applied" ); $line = $lines->next; is( $line->amount + 0, -1, "Refund amount correctly set to 1" ); is( $line->amountoutstanding + 0, -1, "Refund amount outstanding unspent" ); @@ -4833,7 +4833,7 @@ subtest '_FixOverduesOnReturn' => sub { my $credit = $offset->credit; is( ref $credit, "Koha::Account::Line", "Found matching credit for fine forgiveness" ); is( $credit->amount + 0, -99, "Credit amount is set correctly" ); - is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" ); + is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" ); # Bug 25417 - Only forgive fines where there is an amount outstanding to forgive $accountline->set( @@ -7584,7 +7584,7 @@ subtest 'NoRefundOnLostFinesPaidAge' => sub { { borrowernumber => $patron->id, date => '1970-01-01 14:00:01', - amountoutstanding => 0, + amountoutstanding => 0, amount => -5, interface => 'commandline', credit_type_code => 'PAYMENT' @@ -7640,7 +7640,7 @@ subtest 'NoRefundOnLostFinesPaidAge' => sub { borrowernumber => $patron2->id, date => '1970-01-01 14:00:01', amount => -5, - amountoutstanding => 0, + amountoutstanding => 0, interface => 'commandline', credit_type_code => 'PAYMENT' } diff --git a/t/db_dependent/Circulation/CalcDateDue.t b/t/db_dependent/Circulation/CalcDateDue.t index 00e3c99a2ca..485b15b8181 100755 --- a/t/db_dependent/Circulation/CalcDateDue.t +++ b/t/db_dependent/Circulation/CalcDateDue.t @@ -9,7 +9,7 @@ use DBI; use DateTime; use t::lib::Mocks; use t::lib::TestBuilder; -use C4::Calendar qw( new insert_single_holiday delete_holiday insert_week_day_holiday ); +use C4::Calendar; use Koha::DateUtils qw( dt_from_string ); use Koha::Library::Hours; use Koha::CirculationRules; diff --git a/t/db_dependent/Hold.t b/t/db_dependent/Hold.t index a6267393fdc..5ceb0aa7816 100755 --- a/t/db_dependent/Hold.t +++ b/t/db_dependent/Hold.t @@ -22,7 +22,7 @@ use C4::Context; use C4::Biblio qw( AddBiblio ); use Koha::Database; use Koha::Libraries; -use C4::Calendar qw( new insert_single_holiday ); +use C4::Calendar; use Koha::Patrons; use Koha::Holds; use Koha::Item; @@ -356,8 +356,10 @@ subtest "delete() tests" => sub { "Koha::Hold->delete should have deleted the hold" ); - my $number_of_logs = $schema->resultset('ActionLog') - ->search( { module => 'HOLDS', action => 'DELETE', object => $hold->{reserve_id} } )->count; + my $number_of_logs = + $schema->resultset('ActionLog') + ->search( { module => 'HOLDS', action => 'DELETE', object => $hold->{reserve_id} } ) + ->count; is( $number_of_logs, 0, 'With HoldsLogs, Koha::Hold->delete shouldn\'t have been logged' ); # Enable logging @@ -376,8 +378,10 @@ subtest "delete() tests" => sub { "Koha::Hold->delete should have deleted the hold" ); - $number_of_logs = $schema->resultset('ActionLog') - ->search( { module => 'HOLDS', action => 'DELETE', object => $hold->{reserve_id} } )->count; + $number_of_logs = + $schema->resultset('ActionLog') + ->search( { module => 'HOLDS', action => 'DELETE', object => $hold->{reserve_id} } ) + ->count; is( $number_of_logs, 1, 'With HoldsLogs, Koha::Hold->delete should have been logged' ); $schema->storage->txn_rollback(); @@ -469,7 +473,8 @@ subtest 'suspend() tests' => sub { t::lib::Mocks::mock_preference( 'HoldsLog', 1 ); my $logs_count = - $schema->resultset('ActionLog')->search( { module => 'HOLDS', action => 'SUSPEND', object => $hold->id } ) + $schema->resultset('ActionLog') + ->search( { module => 'HOLDS', action => 'SUSPEND', object => $hold->id } ) ->count; $hold = $builder->build_object( @@ -481,7 +486,8 @@ subtest 'suspend() tests' => sub { $hold->suspend_hold; my $new_logs_count = - $schema->resultset('ActionLog')->search( { module => 'HOLDS', action => 'SUSPEND', object => $hold->id } ) + $schema->resultset('ActionLog') + ->search( { module => 'HOLDS', action => 'SUSPEND', object => $hold->id } ) ->count; is( $new_logs_count, $logs_count + 1, 'If logging is enabled, suspending a hold gets logged' ); diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t index 0d516da3407..b4db63abfe3 100755 --- a/t/db_dependent/HoldsQueue.t +++ b/t/db_dependent/HoldsQueue.t @@ -12,7 +12,7 @@ use Test::NoWarnings; use Test::More tests => 65; use Data::Dumper; -use C4::Calendar qw( new insert_single_holiday ); +use C4::Calendar; use C4::Context; use C4::Members; use C4::Circulation qw( AddIssue AddReturn ); diff --git a/t/db_dependent/Koha/Charges/Fees.t b/t/db_dependent/Koha/Charges/Fees.t index b32b915f4db..00227828171 100755 --- a/t/db_dependent/Koha/Charges/Fees.t +++ b/t/db_dependent/Koha/Charges/Fees.t @@ -29,7 +29,7 @@ use t::lib::TestBuilder; use t::lib::Dates; use Time::Fake; -use C4::Calendar qw( new insert_week_day_holiday delete_holiday ); +use C4::Calendar; use Koha::DateUtils qw(dt_from_string); BEGIN { diff --git a/t/db_dependent/Koha/ItemTypes.t b/t/db_dependent/Koha/ItemTypes.t index 9ba7b64dea6..c9791e91a77 100755 --- a/t/db_dependent/Koha/ItemTypes.t +++ b/t/db_dependent/Koha/ItemTypes.t @@ -25,7 +25,7 @@ use Test::More tests => 19; use t::lib::Mocks; use t::lib::TestBuilder; -use C4::Calendar qw( new ); +use C4::Calendar; use Koha::Biblioitems; use Koha::Libraries; use Koha::Database; -- 2.34.1