Bugzilla – Attachment 186161 Details for
Bug 40644
Bookings biblio checks erroneously if multiple check-outs and bookings exist
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40644: Add tests
Bug-40644-Add-tests.patch (text/plain), 3.51 KB, created by
Pedro Amorim
on 2025-09-04 14:29:05 UTC
(
hide
)
Description:
Bug 40644: Add tests
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2025-09-04 14:29:05 UTC
Size:
3.51 KB
patch
obsolete
>From 1342dd5be4d7428e59d09802ee5010e6a0b25e27 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@openfifth.co.uk> >Date: Thu, 4 Sep 2025 14:20:55 +0000 >Subject: [PATCH] Bug 40644: Add tests > >If you apply this patch before the other one: > >prove t/db_dependent/Koha/Biblio.t > >Will fail. Apply both patches. The above now passes. > >This highlighted something. Following the test plan I can't reproduce >this anymore. In order to reproduce, the check-outs need to happen >before the bookings, otherwise when the check-outs happen on an existing >booking it'll 'complete' or 'cancel' the booking thus not causing the >error. >--- > t/db_dependent/Koha/Biblio.t | 69 +++++++++++++++++++++++++++++++++++- > 1 file changed, 68 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t >index f0d32ee3009..0d9d44a4591 100755 >--- a/t/db_dependent/Koha/Biblio.t >+++ b/t/db_dependent/Koha/Biblio.t >@@ -2194,7 +2194,7 @@ sub host_record { > } > > subtest 'check_booking tests' => sub { >- plan tests => 5; >+ plan tests => 6; > > $schema->storage->txn_begin; > >@@ -2309,5 +2309,72 @@ subtest 'check_booking tests' => sub { > "Koha::Item->check_booking takes account of cancelled status in bookings check" > ); > >+ my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ t::lib::Mocks::mock_userenv( { branchcode => $library->id } ); >+ >+ # Create a a test biblio with 8 items >+ my $new_biblio = $builder->build_object( >+ { >+ class => 'Koha::Biblios', >+ value => { title => 'Test biblio with items' } >+ } >+ ); >+ my @new_items; >+ for ( 1 .. 8 ) { >+ my $item = $builder->build_object( >+ { >+ class => 'Koha::Items', >+ value => { >+ homebranch => $library->branchcode, >+ holdingbranch => $library->branchcode, >+ biblionumber => $new_biblio->biblionumber, >+ bookable => 1 >+ } >+ } >+ ); >+ push @new_items, $item; >+ } >+ >+ my @item_numbers = map { $_->itemnumber } @new_items; >+ my @item_barcodes = map { $_->barcode } @new_items; >+ >+ # Check-out all of those 6 items >+ @item_barcodes = splice @item_barcodes, 0, 6; >+ for my $item_barcode (@item_barcodes) { >+ AddIssue( $patron_1, $item_barcode ); >+ } >+ >+ @item_numbers = splice @item_numbers, 0, 6; >+ my @new_bookings; >+ for my $itemnumber (@item_numbers) { >+ my $booking = $builder->build_object( >+ { >+ class => 'Koha::Bookings', >+ value => { >+ biblio_id => $new_biblio->biblionumber, >+ item_id => $itemnumber, >+ start_date => $start_2, >+ end_date => $end_2, >+ status => 'new' >+ } >+ } >+ ); >+ push @new_bookings, $booking; >+ } >+ >+ # Place a booking on one of the 2 remaining items >+ my $item = ( grep { $_->itemnumber ne $new_bookings[0]->item_id } @new_items )[0]; >+ >+ my $check_booking = $new_biblio->get_from_storage->check_booking( >+ { >+ start_date => $start_2, >+ end_date => $end_2, >+ item_id => $item->itemnumber >+ } >+ ); >+ >+ is( $check_booking, 1, "Koha::Biblio->check_booking returns true when we can book on an item" ); >+ > $schema->storage->txn_rollback; > }; >-- >2.39.5
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 40644
:
185358
|
185359
|
185360
|
185417
|
186129
|
186159
| 186161