From 1c323b647c871143d49514b01157a5be24959a72 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 16 Sep 2024 14:03:20 -0400 Subject: [PATCH] Bug 26282: (QA follow-up) Tidy code for qa script --- misc/cronjobs/holds/cancel_expired_holds.pl | 2 +- reserve/modrequest.pl | 29 +++++++++------------ t/db_dependent/Koha/Hold.t | 25 ++++++++++-------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/misc/cronjobs/holds/cancel_expired_holds.pl b/misc/cronjobs/holds/cancel_expired_holds.pl index 81921dab910..7c7b67d2295 100755 --- a/misc/cronjobs/holds/cancel_expired_holds.pl +++ b/misc/cronjobs/holds/cancel_expired_holds.pl @@ -81,6 +81,6 @@ pod2usage(1) if $help; cronlogaction({ info => $command_line_options }); -C4::Reserves::CancelExpiredReserves($reason, $notify); +C4::Reserves::CancelExpiredReserves( $reason, $notify ); cronlogaction({ action => 'End', info => "COMPLETED" }); diff --git a/reserve/modrequest.pl b/reserve/modrequest.pl index 648fae89a46..c24f504b544 100755 --- a/reserve/modrequest.pl +++ b/reserve/modrequest.pl @@ -51,31 +51,31 @@ my $count=@rank; @biblionumber = uniq @biblionumber; # Cancel or modify the queue list of reserves (without item linked) -if( $op eq 'cud-cancelall' || $op eq 'cud-modifyall' ) { - for (my $i=0;$i<$count;$i++){ +if ( $op eq 'cud-cancelall' || $op eq 'cud-modifyall' ) { + for ( my $i = 0 ; $i < $count ; $i++ ) { undef $itemnumber[$i] if !$itemnumber[$i]; - my $suspend_until = $query->param( "suspend_until_" . $reserve_id[$i] ); - my $cancellation_reason = $query->param("cancellation-reason"); + my $suspend_until = $query->param( "suspend_until_" . $reserve_id[$i] ); + my $cancellation_reason = $query->param("cancellation-reason"); my $cancellation_notify_patron = $query->param("cancellation-notify-patron"); my $params = { - rank => $rank[$i], - reserve_id => $reserve_id[$i], + rank => $rank[$i], + reserve_id => $reserve_id[$i], expirationdate => $expirationdates[$i] || undef, - branchcode => $branch[$i], - itemnumber => $itemnumber[$i], + branchcode => $branch[$i], + itemnumber => $itemnumber[$i], defined $suspend_until ? ( suspend_until => $suspend_until ) : (), cancellation_reason => $cancellation_reason, - notify_patron => $cancellation_notify_patron, + notify_patron => $cancellation_notify_patron, }; - if (C4::Context->preference('AllowHoldDateInFuture')) { + if ( C4::Context->preference('AllowHoldDateInFuture') ) { $params->{reservedate} = $reservedates[$i] || undef; } try { ModReserve($params); } catch { - if ($_->isa('Koha::Exceptions::ObjectNotFound')){ + if ( $_->isa('Koha::Exceptions::ObjectNotFound') ) { warn $_; } else { $_->rethrow; @@ -97,11 +97,8 @@ if( $op eq 'cud-cancelall' || $op eq 'cud-modifyall' ) { } } my @biblio_ids = uniq @biblionumber; - Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( - { - biblio_ids => \@biblio_ids - } - ) if C4::Context->preference('RealTimeHoldsQueue'); + Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => \@biblio_ids } ) + if C4::Context->preference('RealTimeHoldsQueue'); } my $from=$query->param('from'); diff --git a/t/db_dependent/Koha/Hold.t b/t/db_dependent/Koha/Hold.t index 44988e9ff85..fc9e1a6d95f 100755 --- a/t/db_dependent/Koha/Hold.t +++ b/t/db_dependent/Koha/Hold.t @@ -1101,10 +1101,13 @@ subtest 'cancel() tests' => sub { # Mock GetPreparedLetter so it raises a warning we can look for # and returns undef, so no call to EnqueueLetter happens my $mocked_letter = Test::MockModule->new("C4::Letters"); - $mocked_letter->mock( 'GetPreparedLetter', sub { - $get_prepared_letter_called = 1; - return; - }); + $mocked_letter->mock( + 'GetPreparedLetter', + sub { + $get_prepared_letter_called = 1; + return; + } + ); my $hold = $builder->build_object( { @@ -1119,7 +1122,7 @@ subtest 'cancel() tests' => sub { # leave this things out of the test t::lib::Mocks::mock_preference( 'ExpireReservesMaxPickUpDelayCharge', 0 ); - t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); + t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); $hold = $builder->build_object( { @@ -1133,11 +1136,11 @@ subtest 'cancel() tests' => sub { ); $get_prepared_letter_called = 0; - $hold->cancel({ cancellation_reason => 'Some reason' }); + $hold->cancel( { cancellation_reason => 'Some reason' } ); ok( !$get_prepared_letter_called, 'GetPreparedLetter not called' ); isnt( $hold->cancellationdate, undef, 'cancellationdate gets set to the passed value' ); - is( $hold->priority, 0, 'priority gets set to 0' ); + is( $hold->priority, 0, 'priority gets set to 0' ); is( $hold->cancellation_reason, 'Some reason', 'cancellation_reason is set to the passed value' ); $hold = $builder->build_object( @@ -1152,11 +1155,11 @@ subtest 'cancel() tests' => sub { ); $get_prepared_letter_called = 0; - $hold->cancel({ cancellation_reason => 'Some reason', notify_patron => 1 }); + $hold->cancel( { cancellation_reason => 'Some reason', notify_patron => 1 } ); ok( $get_prepared_letter_called, 'GetPreparedLetter called if notify_patron and cancellation_reason passed' ); isnt( $hold->cancellationdate, undef, 'cancellationdate gets set to the passed value' ); - is( $hold->priority, 0, 'priority gets set to 0' ); + is( $hold->priority, 0, 'priority gets set to 0' ); is( $hold->cancellation_reason, 'Some reason', 'cancellation_reason is set to the passed value' ); $hold = $builder->build_object( @@ -1171,9 +1174,9 @@ subtest 'cancel() tests' => sub { ); $get_prepared_letter_called = 0; - $hold->cancel({ notify_patron => 1 }); + $hold->cancel( { notify_patron => 1 } ); isnt( $hold->cancellationdate, undef, 'cancellationdate gets set to the passed value' ); - is( $hold->priority, 0, 'priority gets set to 0' ); + is( $hold->priority, 0, 'priority gets set to 0' ); is( $hold->cancellation_reason, undef, 'cancellation_reason not passed' ); $schema->storage->txn_rollback; -- 2.39.3 (Apple Git-146)