Bugzilla – Attachment 189914 Details for
Bug 15261
Verify if checkout or hold request periods overlap with existing holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15261: Add tests for overlapping reserves on ILS-DI
Bug-15261-Add-tests-for-overlapping-reserves-on-IL.patch (text/plain), 5.38 KB, created by
Arthur Suzuki
on 2025-11-24 14:00:25 UTC
(
hide
)
Description:
Bug 15261: Add tests for overlapping reserves on ILS-DI
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2025-11-24 14:00:25 UTC
Size:
5.38 KB
patch
obsolete
>From b66e95dea032b8306ffcae4250d6b2776733b30f Mon Sep 17 00:00:00 2001 >From: Arthur Suzuki <arthur.suzuki@biblibre.com> >Date: Mon, 24 Nov 2025 12:59:21 +0000 >Subject: [PATCH] Bug 15261: Add tests for overlapping reserves on ILS-DI > >--- > t/db_dependent/ILSDI_Services.t | 129 +++++++++++++++++++++++++++++++- > 1 file changed, 125 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t >index 369f629f8b..67422f28ca 100755 >--- a/t/db_dependent/ILSDI_Services.t >+++ b/t/db_dependent/ILSDI_Services.t >@@ -20,7 +20,7 @@ use Modern::Perl; > use CGI qw ( -utf8 ); > > use Test::NoWarnings; >-use Test::More tests => 16; >+use Test::More tests => 17; > use Test::MockModule; > use t::lib::Mocks; > use t::lib::TestBuilder; >@@ -472,13 +472,23 @@ subtest 'Holds test' => sub { > > t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 0 ); > >+ my $pickup_library = $builder->build_object( >+ { >+ class => 'Koha::Libraries', >+ value => { >+ pickup_location => 1, >+ } >+ } >+ ); >+ > my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > >- my $item = $builder->build_sample_item( { damaged => 1 } ); >+ my $item = $builder->build_sample_item( { damaged => 1, library => $pickup_library->branchcode, } ); > > my $query = CGI->new; >- $query->param( 'patron_id', $patron->borrowernumber ); >- $query->param( 'bib_id', $item->biblionumber ); >+ $query->param( 'patron_id', $patron->borrowernumber ); >+ $query->param( 'bib_id', $item->biblionumber ); >+ $query->param( 'pickup_location', $pickup_library->branchcode ); > > my $reply = C4::ILSDI::Services::HoldTitle($query); > is( $reply->{code}, 'damaged', "Item damaged" ); >@@ -1263,3 +1273,114 @@ subtest 'Bug 34893: ILS-DI can return the wrong patron for AuthenticatePatron' = > > $schema->storage->txn_rollback; > }; >+ >+subtest 'Bug 23669: PreventReservesOnSamePeriod with ILS-DI' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ # Set up the test environment >+ t::lib::Mocks::mock_preference( 'PreventReservesOnSamePeriod', 1 ); >+ t::lib::Mocks::mock_preference( 'AllowHoldDateInFuture', 1 ); >+ >+ my $pickup_library = $builder->build_object( >+ { >+ class => 'Koha::Libraries', >+ value => { >+ pickup_location => 1, >+ } >+ } >+ ); >+ >+ # Create a patron >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ } >+ ); >+ >+ # Create a record and items >+ my $biblio = $builder->build_sample_biblio(); >+ my $item = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $pickup_library->branchcode, >+ } >+ ); >+ >+ Koha::CirculationRules->set_rule( >+ { >+ categorycode => undef, >+ itemtype => undef, >+ branchcode => undef, >+ rule_name => 'reservesallowed', >+ rule_value => 99, >+ } >+ ); >+ >+ Koha::CirculationRules->set_rule( >+ { >+ categorycode => undef, >+ itemtype => undef, >+ branchcode => undef, >+ rule_name => 'holds_per_record', >+ rule_value => 99, >+ } >+ ); >+ >+ # Place an existing hold with specific dates >+ my $reserve_id = C4::Reserves::AddReserve( >+ { >+ branchcode => $item->homebranch, >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $biblio->biblionumber, >+ priority => 1, >+ reservation_date => '2023-11-01', >+ expiration_date => '2023-11-10', >+ } >+ ); >+ >+ # Attempt to place a new hold with overlapping dates through ILS-DI >+ my $query = CGI->new; >+ $query->param( 'pickup_location', $pickup_library->branchcode ); >+ $query->param( 'patron_id', $patron->borrowernumber ); >+ $query->param( 'bib_id', $biblio->biblionumber ); >+ $query->param( 'start_date', '2023-11-05' ); >+ $query->param( 'expiry_date', '2023-11-15' ); >+ >+ my $reply = C4::ILSDI::Services::HoldTitle($query); >+ >+ # Verify that the hold is rejected >+ is( $reply->{code}, 'overlap', 'Hold is rejected due to overlapping dates' ); >+ >+ # Now try with non-overlapping dates >+ $query->param( 'start_date', '2023-11-15' ); >+ $query->param( 'expiry_date', '2023-11-20' ); >+ >+ $reply = C4::ILSDI::Services::HoldTitle($query); >+ >+ # Verify that the hold is accepted >+ is( $reply->{code}, undef, 'Hold is accepted with non-overlapping dates' ); >+ >+ # Test with item-level hold >+ $query->param( 'item_id', $item->itemnumber ); >+ $query->param( 'start_date', '2023-11-05' ); >+ $query->param( 'expiry_date', '2023-11-15' ); >+ >+ $reply = C4::ILSDI::Services::HoldItem($query); >+ >+ # Verify that the hold is rejected >+ is( $reply->{code}, 'overlap', 'Item-level hold is rejected due to overlapping dates' ); >+ >+ # Now try with non-overlapping dates >+ $query->param( 'start_date', '2023-11-25' ); >+ $query->param( 'expiry_date', '2023-11-30' ); >+ >+ $reply = C4::ILSDI::Services::HoldItem($query); >+ >+ # Verify that the hold is accepted >+ is( $reply->{code}, undef, 'Item-level hold is accepted with non-overlapping dates' ); >+ >+ $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 15261
:
45216
|
45833
|
45841
|
46432
|
46433
|
46441
|
46442
|
49001
|
49002
|
49003
|
52704
|
59643
|
61534
|
61539
|
61544
|
67088
|
67094
|
67143
|
68660
|
68661
|
68662
|
68663
|
68664
|
68852
|
68853
|
72956
|
72957
|
76221
|
76222
|
88292
|
88293
|
88297
|
88298
|
92376
|
92377
|
92584
|
92585
|
92664
|
93136
|
94871
|
98383
|
98424
|
98672
|
106944
|
106949
|
120822
|
123405
|
125793
|
125794
|
125795
|
125796
|
131569
|
131570
|
131571
|
131572
|
131573
|
187999
|
188000
|
189912
|
189913
| 189914 |
189915