From f2953c44cd40d78f9a6390614c2698802fe27f70 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Tue, 25 Feb 2020 00:28:36 +0000 Subject: [PATCH] Bug 24718: Ensuring tests pass Confirm these tests pass before and after applying patches t/db_dependent/Holds.t t/db_dependent/Circulation.t t/db_dependent/Circulation/issue.t t/db_dependent/Holds/HoldFulfillmentPolicy.t t/db_dependent/Holds/LocalHoldsPriority.t t/db_dependent/Holds/HoldItemtypeLimit.t t/db_dependent/Holds/RevertWaitingStatus.t t/db_dependent/HoldsQueue.t t/db_dependent/Reserves/CancelExpiredReserves.t Signed-off-by: David Nind --- C4/HoldsQueue.pm | 4 ++-- C4/Reserves.pm | 8 ++++++-- Koha/Item.pm | 2 +- t/db_dependent/Holds.t | 4 ++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index 4950522726..cb061b6856 100644 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -239,7 +239,7 @@ sub GetBibsWithPendingHoldRequests { FROM reserves WHERE found IS NULL AND priority > 0 - AND reservedate <= CURRENT_DATE() + AND reservedate <= CURRENT_TIMESTAMP() AND suspend = 0 "; my $sth = $dbh->prepare($bib_query); @@ -283,7 +283,7 @@ sub GetPendingHoldRequestsForBib { WHERE biblionumber = ? AND found IS NULL AND priority > 0 - AND reservedate <= CURRENT_DATE() + AND reservedate <= CURRENT_TIMESTAMP() AND suspend = 0 ORDER BY priority"; my $sth = $dbh->prepare($request_query); diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 4156b4c856..7232dccbe6 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -448,9 +448,13 @@ sub CanItemBeReserved { return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; } + my $dtf = Koha::Database->new->schema->storage->datetime_parser; + my $fromdate = dt_from_string->set({ hour => 00, minute => 00, second => 00 }); + my $todate = dt_from_string->set({ hour => 23, minute => 59, second => 59 }); + my $today_holds = Koha::Holds->search({ borrowernumber => $borrowernumber, - reservedate => dt_from_string->date + reservedate => [ -and => { '>=' => $dtf->format_datetime($fromdate) }, { '<=' => $dtf->format_datetime($todate) } ] }); if ( defined $holds_per_day && $holds_per_day ne '' @@ -922,7 +926,7 @@ sub CancelExpiredReserves { my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay'); my $dtf = Koha::Database->new->schema->storage->datetime_parser; - my $params = { expirationdate => { '<', $today } }; + my $params = { expirationdate => { '<', $dtf->format_datetime($today) } }; $params->{found} = [ { '!=', 'W' }, undef ] unless $expireWaiting; # FIXME To move to Koha::Holds->search_expired (?) diff --git a/Koha/Item.pm b/Koha/Item.pm index 8dffac4db5..349cf651a4 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -648,7 +648,7 @@ sub current_holds { itemnumber => $self->itemnumber, suspend => 0, -or => [ - reservedate => { '<=' => $dtf->format_date(dt_from_string) }, + reservedate => { '<=' => $dtf->format_datetime(dt_from_string) }, waitingdate => { '!=' => undef }, ], }; diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t index 0cffe1501a..57191df336 100755 --- a/t/db_dependent/Holds.t +++ b/t/db_dependent/Holds.t @@ -102,7 +102,7 @@ my $reservedate = $first_hold->reservedate; my $borrowernumber = $first_hold->borrowernumber; my $branch_1code = $first_hold->branchcode; my $reserve_id = $first_hold->reserve_id; -is( $reservedate, output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), "holds_placed_today should return a valid reserve date"); +is( dt_from_string( $reservedate ), dt_from_string, "holds_placed_today should return a valid reserve date"); is( $borrowernumber, $borrowernumbers[0], "holds_placed_today should return a valid borrowernumber"); is( $branch_1code, $branch_1, "holds_placed_today should return a valid branchcode"); ok($reserve_id, "Test holds_placed_today()"); @@ -715,7 +715,7 @@ subtest 'CanItemBeReserved / holds_per_day tests' => sub { is_deeply( CanItemBeReserved( $patron->borrowernumber, $itemnumber_2 ), { status => 'tooManyReservesToday', limit => 2 }, - 'Patron cannot a third item with 2 reserves daily cap' + 'Patron cannot reserve a third item with 2 reserves daily cap' ); # Update last hold so reservedate is in the past, so 2 holds, but different day -- 2.11.0