Bugzilla – Attachment 173201 Details for
Bug 38175
Improve bookings behavior with new status field
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38175: Unit tests for assign_item_for_booking
Bug-38175-Unit-tests-for-assignitemforbooking.patch (text/plain), 3.33 KB, created by
Martin Renvoize (ashimema)
on 2024-10-23 10:10:59 UTC
(
hide
)
Description:
Bug 38175: Unit tests for assign_item_for_booking
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-10-23 10:10:59 UTC
Size:
3.33 KB
patch
obsolete
>From a0f6747ff4699df58cf052112dabc93ee2e88289 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 23 Oct 2024 11:07:52 +0100 >Subject: [PATCH] Bug 38175: Unit tests for assign_item_for_booking > >This patch adds more comprehensive tests to the item autoassignment for >'Any item' handling in bookings. > >We check for both random assignment, which was missing before now but >always intended, and that we take cancelled status into account. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Koha/Booking.t | 49 ++++++++++++++++++++++++++++++++--- > 1 file changed, 46 insertions(+), 3 deletions(-) > >diff --git a/t/db_dependent/Koha/Booking.t b/t/db_dependent/Koha/Booking.t >index 1c4ec2debca..19aa536b12a 100755 >--- a/t/db_dependent/Koha/Booking.t >+++ b/t/db_dependent/Koha/Booking.t >@@ -314,13 +314,56 @@ subtest 'store() tests' => sub { > ok( $booking->item_id, 'An item was assigned to the booking' ); > > subtest '_assign_item_for_booking() tests' => sub { >- plan tests => 1; >- is( $booking->item_id, $item_1->itemnumber, "Item 1 was assigned to the booking" ); >+ plan tests => 5; > > # Bookings > # â Item 1 |----| > # â Item 2 |--| >- # â Any (1) |--| >+ # â Any (X) |--| >+ my $valid_items = [ $item_1->itemnumber, $item_2->itemnumber ]; >+ my $assigned_item = $booking->item_id; >+ is( >+ ( scalar grep { $_ == $assigned_item } @$valid_items ), 1, >+ 'The item assigned was one of the valid, bookable items' >+ ); >+ >+ my $second_booking = Koha::Booking->new( >+ { >+ patron_id => $patron->borrowernumber, >+ biblio_id => $biblio->biblionumber, >+ pickup_library_id => $item_2->homebranch, >+ start_date => $start_1, >+ end_date => $end_1 >+ } >+ )->store(); >+ isnt( $second_booking->item_id, $assigned_item, "The subsequent booking picks the only other available item" ); >+ >+ # Cancel both bookings so we can check that cancelled bookings are allowed in the auto-assign >+ $booking->status('cancelled')->store(); >+ $second_booking->status('cancelled')->store(); >+ is($booking->status, 'cancelled', "Booking is cancelled"); >+ is($second_booking->status, 'cancelled', "Second booking is cancelled"); >+ >+ # Test randomness of selection >+ my %seen_items; >+ foreach my $i ( 1 .. 10 ) { >+ my $new_booking = Koha::Booking->new( >+ { >+ patron_id => $patron->borrowernumber, >+ biblio_id => $biblio->biblionumber, >+ pickup_library_id => $item_1->homebranch, >+ start_date => $start_1, >+ end_date => $end_1 >+ } >+ ); >+ $new_booking->store(); >+ $seen_items{ $new_booking->item_id }++; >+ $new_booking->delete(); >+ } >+ ok( >+ scalar( keys %seen_items ) > 1, >+ 'Multiple different items were selected randomly across bookings, and a cancelled booking is allowed in the selection' >+ ); > }; > > subtest 'confirmation notice trigger' => sub { >-- >2.47.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 38175
:
172770
|
172771
|
172772
|
172773
|
172814
|
172815
|
172816
|
172817
|
172880
|
172881
|
172882
|
172883
|
172884
|
173172
|
173173
|
173174
|
173175
|
173176
|
173177
|
173178
| 173201 |
173202
|
173203
|
173346
|
173915