Bugzilla – Attachment 170600 Details for
Bug 34440
Add warm-up and cool-down periods to bookings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34440: Unit test for change to Koha::Item
Bug-34440-Unit-test-for-change-to-KohaItem.patch (text/plain), 3.43 KB, created by
Martin Renvoize (ashimema)
on 2024-08-22 10:09:03 UTC
(
hide
)
Description:
Bug 34440: Unit test for change to Koha::Item
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-08-22 10:09:03 UTC
Size:
3.43 KB
patch
obsolete
>From 5ea115e9e47168fb2a1b185f997595655d6145f8 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 22 Aug 2024 11:02:58 +0100 >Subject: [PATCH] Bug 34440: Unit test for change to Koha::Item > >This adds a unit test for the new preparation_period handling introduced >into the find_booking method of Koha::Item. > >Sponsored-by: Cuyahoga County Public Library <https://cuyahogalibrary.org/> >--- > Koha/Item.pm | 4 ++- > t/db_dependent/Koha/Item.t | 50 +++++++++++++++++++++++++++++++++++++- > 2 files changed, 52 insertions(+), 2 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index d2e475df022..4b9ce313ed3 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -586,7 +586,9 @@ sub bookings { > > my $booking = $item->find_booking( { checkout_date => $now, due_date => $future_date } ); > >-Find the first booking that would conflict with the passed checkout dates for this item. >+Find the first booking that would conflict with the passed checkout dates for this item. If a booking >+lead period is configured for the itemtype we will also take that into account here, counting bookings >+that fall in that lead period as conflicts too. > > FIXME: This can be simplified, it was originally intended to iterate all biblio level bookings > to catch cases where this item may be the last available to satisfy a biblio level only booking. >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index 9e3824842aa..5d3d780f352 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -2600,7 +2600,7 @@ subtest 'bookings' => sub { > }; > > subtest 'find_booking' => sub { >- plan tests => 6; >+ plan tests => 7; > > $schema->storage->txn_begin; > >@@ -2707,6 +2707,54 @@ subtest 'find_booking' => sub { > "Koha::Item->find_booking returns the current booking not a future one" > ); > >+ subtest "Preparation period handling" => sub { >+ plan tests => 3; >+ >+ # Delete current booking, is the future booking returned? >+ $booking2->delete(); >+ $found_booking = $item->find_booking( >+ { >+ checkout_date => dt_from_string(), >+ due_date => dt_from_string()->add( days => 7 ), >+ } >+ ); >+ >+ is( >+ $found_booking, >+ undef, >+ "Koha::Item->find_booking returns undefined when the current booking is deleted and the future booking is out of range and there's no lead period rule" >+ ); >+ >+ # Adding lead period rule >+ Koha::CirculationRules->set_rules( >+ { >+ branchcode => '*', >+ itemtype => $item->effective_itemtype, >+ rules => { >+ bookings_lead_period => 3, >+ }, >+ } >+ ); >+ >+ $found_booking = $item->find_booking( >+ { >+ checkout_date => dt_from_string(), >+ due_date => dt_from_string()->add( days => 7 ), >+ } >+ ); >+ >+ is( >+ ref($found_booking), >+ 'Koha::Booking', >+ "Koha::Item->find_booking returns a Koha::Booking if one exists that would clash with the passed dates including lead period" >+ ); >+ is( >+ $found_booking->booking_id, $booking3->booking_id, >+ "Koha::Item->find_booking returns the future booking when lead period is included" >+ ); >+ >+ }; >+ > $schema->storage->txn_rollback; > }; > >-- >2.46.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34440
:
167948
|
167949
|
167950
|
167951
|
167952
|
167953
|
167954
|
167955
|
168941
|
168942
|
168943
|
168944
|
168945
|
168946
|
168947
|
168948
|
168949
|
168998
|
168999
|
169000
|
169001
|
169002
|
169003
|
169004
|
169005
|
169006
|
169007
|
169571
|
169572
|
169573
|
169574
|
169575
|
169576
|
169577
|
169578
|
169579
|
169580
|
169581
|
169587
|
169588
|
170032
|
170033
|
170034
|
170035
|
170036
|
170037
|
170038
|
170039
|
170040
|
170041
|
170042
|
170046
|
170047
|
170048
|
170049
|
170050
|
170051
|
170052
|
170053
|
170054
|
170055
|
170056
|
170589
|
170590
|
170591
|
170592
|
170593
|
170594
|
170595
|
170596
|
170597
|
170598
|
170599
|
170600
|
170603
|
170610
|
170951