Bugzilla – Attachment 175335 Details for
Bug 38650
We should only fill title level or specific item holds when a patron checks out an item
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38650: Unit tests
Bug-38650-Unit-tests.patch (text/plain), 4.57 KB, created by
Nick Clemens (kidclamp)
on 2024-12-09 20:31:47 UTC
(
hide
)
Description:
Bug 38650: Unit tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-12-09 20:31:47 UTC
Size:
4.57 KB
patch
obsolete
>From 44309963c7944863d74acf6f675e7ddb32ccac97 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 9 Dec 2024 20:22:49 +0000 >Subject: [PATCH] Bug 38650: Unit tests > >--- > t/db_dependent/Reserves.t | 57 ++++++++++++++++++++++++++++++--------- > 1 file changed, 44 insertions(+), 13 deletions(-) > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 616506b9b71..6c91091fac6 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -1028,15 +1028,17 @@ subtest 'reserves.item_level_hold' => sub { > > subtest 'MoveReserve additional test' => sub { > >- plan tests => 4; >+ plan tests => 8; > > # Create the items and patrons we need > my $biblio = $builder->build_sample_biblio(); >- my $itype = $builder->build_object({ class => "Koha::ItemTypes", value => { notforloan => 0 } }); >- my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber,notforloan => 0, itype => $itype->itemtype }); >- my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, notforloan => 0, itype => $itype->itemtype }); >- my $patron_1 = $builder->build_object({ class => "Koha::Patrons" }); >- my $patron_2 = $builder->build_object({ class => "Koha::Patrons" }); >+ my $itype = $builder->build_object( { class => "Koha::ItemTypes", value => { notforloan => 0 } } ); >+ my $item_1 = $builder->build_sample_item( >+ { biblionumber => $biblio->biblionumber, notforloan => 0, itype => $itype->itemtype } ); >+ my $item_2 = $builder->build_sample_item( >+ { biblionumber => $biblio->biblionumber, notforloan => 0, itype => $itype->itemtype } ); >+ my $patron_1 = $builder->build_object( { class => "Koha::Patrons" } ); >+ my $patron_2 = $builder->build_object( { class => "Koha::Patrons" } ); > > # Place a hold on the title for both patrons > my $reserve_1 = AddReserve( >@@ -1057,16 +1059,45 @@ subtest 'MoveReserve additional test' => sub { > itemnumber => $item_1->itemnumber, > } > ); >- is($patron_1->holds->next()->reserve_id, $reserve_1, "The 1st patron has a hold"); >- is($patron_2->holds->next()->reserve_id, $reserve_2, "The 2nd patron has a hold"); >+ is( $patron_1->holds->next()->reserve_id, $reserve_1, "The 1st patron has a hold" ); >+ is( $patron_2->holds->next()->reserve_id, $reserve_2, "The 2nd patron has a hold" ); > > # Fake the holds queue >- $dbh->do(q{INSERT INTO hold_fill_targets VALUES (?, ?, ?, ?, ?,?)},undef,($patron_1->borrowernumber,$biblio->biblionumber,$item_1->itemnumber,$item_1->homebranch,0,$reserve_1)); >+ $dbh->do( >+ q{INSERT INTO hold_fill_targets VALUES (?, ?, ?, ?, ?,?)}, undef, >+ ( $patron_1->borrowernumber, $biblio->biblionumber, $item_1->itemnumber, $item_1->homebranch, 0, $reserve_1 ) >+ ); >+ >+ # The 2nd hold should be filled even if the item is preselected for the first hold >+ MoveReserve( $item_1->itemnumber, $patron_2->borrowernumber ); >+ is( $patron_2->holds->count, 0, "The 2nd patrons no longer has a hold" ); >+ is( >+ $patron_2->old_holds->next()->reserve_id, $reserve_2, >+ "The 2nd patrons hold was filled and moved to old holds" >+ ); >+ >+ my $reserve_3 = AddReserve( >+ { >+ branchcode => $item_2->homebranch, >+ borrowernumber => $patron_2->borrowernumber, >+ biblionumber => $biblio->biblionumber, >+ priority => 1, >+ itemnumber => $item_2->itemnumber, >+ } >+ ); >+ >+ # The 3rd hold should not be filled as it is an item level hold on a different item >+ MoveReserve( $item_1->itemnumber, $patron_2->borrowernumber ); >+ is( $patron_2->holds->count, 1, "The 2nd patron still has a hold" ); >+ is( $patron_2->old_holds->count, 1, "The 2nd patron has only 1 old holds" ); >+ >+ my $hold_3 = Koha::Holds->find($reserve_3); >+ $hold_3->item_level_hold(0)->store(); > >- # The 2nd hold should be filed even if the item is preselected for the first hold >- MoveReserve($item_1->itemnumber,$patron_2->borrowernumber); >- is($patron_2->holds->count, 0, "The 2nd patrons no longer has a hold"); >- is($patron_2->old_holds->next()->reserve_id, $reserve_2, "The 2nd patrons hold was filled and moved to old holds"); >+ # The 3rd hold should now be filled as it is a title level hold, even though associated with a different item >+ MoveReserve( $item_1->itemnumber, $patron_2->borrowernumber ); >+ is( $patron_2->holds->count, 0, "The 2nd patron no longer has a hold" ); >+ is( $patron_2->old_holds->count(), 2, "The 2nd patron's hold was filled and moved to old holds" ); > > }; > >-- >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 38650
:
175335
|
175336
|
181143
|
181144
|
181369
|
181370
|
182017
|
182018