From 1aebf4f6f72becce5a8759325cecfeeb8b229642 Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Fri, 19 Jul 2024 02:30:59 +0000 Subject: [PATCH] Bug 24194: Making the qa script happy Tidied up a bunch there are still a couple of perltidy complaints, but I am running out of time today so attaching this patch so it doesn't get lost No more test fails, or failing patterns Signed-off-by: Chris Cormack --- Koha/Hold.pm | 2 +- circ/waitingreserves.pl | 3 ++- .../bug24194-add-ReserveExpiration-syspref.pl | 10 ++++++---- misc/cronjobs/holds/cancel_expired_holds.pl | 2 +- t/db_dependent/Hold.t | 8 +++++--- t/db_dependent/Reserves.t | 17 +++++++++++------ 6 files changed, 26 insertions(+), 16 deletions(-) mode change 100644 => 100755 installer/data/mysql/atomicupdate/bug24194-add-ReserveExpiration-syspref.pl diff --git a/Koha/Hold.pm b/Koha/Hold.pm index 9ca83332a54..d041dd246e7 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -252,7 +252,7 @@ sub set_waiting { $max_pickup_delay = $rule->rule_value; } - my $new_expiration_date = dt_from_string($self->waitingdate)->clone->add( days => $max_pickup_delay ); + $new_expiration_date = dt_from_string($self->waitingdate)->clone->add( days => $max_pickup_delay ); if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype; diff --git a/circ/waitingreserves.pl b/circ/waitingreserves.pl index 545835455aa..9fd139aa6c9 100755 --- a/circ/waitingreserves.pl +++ b/circ/waitingreserves.pl @@ -100,7 +100,8 @@ while ( my $hold = $holds->next ) { next unless $hold->waitingdate; my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $hold->expirationdate); - my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day ) if $hold->expirationdate; + my $calcDate; + $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day ) if $hold->expirationdate; if ($calcDate and $today > $calcDate) { if ( $op eq 'cud-cancelall' ) { diff --git a/installer/data/mysql/atomicupdate/bug24194-add-ReserveExpiration-syspref.pl b/installer/data/mysql/atomicupdate/bug24194-add-ReserveExpiration-syspref.pl old mode 100644 new mode 100755 index 82668b44ae9..f2fa5cdb188 --- a/installer/data/mysql/atomicupdate/bug24194-add-ReserveExpiration-syspref.pl +++ b/installer/data/mysql/atomicupdate/bug24194-add-ReserveExpiration-syspref.pl @@ -1,12 +1,14 @@ use Modern::Perl; return { - bug_number => "24194", + bug_number => "24194", description => "Add new system preference ReserveExpiration", - up => sub { + up => sub { my ($args) = @_; - my ($dbh, $out) = @$args{qw(dbh out)}; + my ( $dbh, $out ) = @$args{qw(dbh out)}; - $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ("ReserveExpiration", 1, NULL, "Enable the use of expiration date in holds module.", "YesNo") }); + $dbh->do( + q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ("ReserveExpiration", 1, NULL, "Enable the use of expiration date in holds module.", "YesNo") } + ); }, }; diff --git a/misc/cronjobs/holds/cancel_expired_holds.pl b/misc/cronjobs/holds/cancel_expired_holds.pl index 11774b6e9a3..77808d3f351 100755 --- a/misc/cronjobs/holds/cancel_expired_holds.pl +++ b/misc/cronjobs/holds/cancel_expired_holds.pl @@ -75,7 +75,7 @@ pod2usage(1) if $help; cronlogaction({ info => $command_line_options }); -if( C4::Context->preference('ReserveExpiration') ) { +if ( C4::Context->preference('ReserveExpiration') ) { C4::Reserves::CancelExpiredReserves($reason); } diff --git a/t/db_dependent/Hold.t b/t/db_dependent/Hold.t index 1574834c4ec..08b553c08a0 100755 --- a/t/db_dependent/Hold.t +++ b/t/db_dependent/Hold.t @@ -443,8 +443,9 @@ subtest 'ReserveExpiration syspref tests' => sub { t::lib::Mocks::mock_preference( 'ReserveExpiration', 0 ); my $expirationdate = dt_from_string->add( days => 1 ); - my $hold = $builder->build_object( - { class => 'Koha::Holds', + my $hold = $builder->build_object( + { + class => 'Koha::Holds', value => { patron_expiration_date => $expirationdate } } ); @@ -456,7 +457,8 @@ subtest 'ReserveExpiration syspref tests' => sub { t::lib::Mocks::mock_preference( 'ReserveExpiration', 1 ); $hold = $builder->build_object( - { class => 'Koha::Holds', + { + class => 'Koha::Holds', value => { patron_expiration_date => $expirationdate } } ); diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index d55ace8c9f5..bde76b04616 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -1370,8 +1370,9 @@ subtest 'ReserveExpiration syspref tests' => sub { t::lib::Mocks::mock_preference( 'ReserveExpiration', 1 ); my $expirationdate = dt_from_string->add( days => 1 ); - my $hold = $builder->build_object( - { class => 'Koha::Holds', + my $hold = $builder->build_object( + { + class => 'Koha::Holds', value => { expirationdate => $expirationdate } } ); @@ -1379,7 +1380,7 @@ subtest 'ReserveExpiration syspref tests' => sub { # Disable expiration date for reserves t::lib::Mocks::mock_preference( 'ReserveExpiration', 0 ); - my $reverted = C4::Reserves::RevertWaitingStatus({ itemnumber => $hold->itemnumber }); + my $reverted = C4::Reserves::RevertWaitingStatus( { itemnumber => $hold->itemnumber } ); is( $reverted->expirationdate, undef, "Expiration date should be removed with reserve expiration disabled" ); @@ -1387,14 +1388,18 @@ subtest 'ReserveExpiration syspref tests' => sub { t::lib::Mocks::mock_preference( 'ReserveExpiration', 1 ); $hold = $builder->build_object( - { class => 'Koha::Holds', + { + class => 'Koha::Holds', value => { expirationdate => $expirationdate } } ); - $reverted = C4::Reserves::RevertWaitingStatus({ itemnumber => $hold->itemnumber }); + $reverted = C4::Reserves::RevertWaitingStatus( { itemnumber => $hold->itemnumber } ); - is( $reverted->expirationdate, undef, "Expiration date is still removed because we can't reset to the original expiration date" ); + is( + $reverted->expirationdate, undef, + "Expiration date is still removed because we can't reset to the original expiration date" + ); }; sub count_hold_print_messages { -- 2.39.5