Bugzilla – Attachment 190524 Details for
Bug 40435
Allow CanBookBeRenewed to consider future holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40435: Add tests
Bug-40435-Add-tests.patch (text/plain), 3.32 KB, created by
Nick Clemens (kidclamp)
on 2025-12-15 21:45:35 UTC
(
hide
)
Description:
Bug 40435: Add tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2025-12-15 21:45:35 UTC
Size:
3.32 KB
patch
obsolete
>From ad628518b5a6a8ea126cfcfd23aaf160ec60052f Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 11 Dec 2025 15:05:59 +0100 >Subject: [PATCH] Bug 40435: Add tests > >Test plan: >Run t/db_dependent/Circulation.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Circulation.t | 53 +++++++++++++++++++++++++++++++++++- > 1 file changed, 52 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index af0a61c5324..c641ca08343 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -19,7 +19,7 @@ use Modern::Perl; > use utf8; > > use Test::NoWarnings; >-use Test::More tests => 83; >+use Test::More tests => 84; > use Test::Exception; > use Test::MockModule; > use Test::Deep qw( cmp_deeply ); >@@ -1938,6 +1938,57 @@ subtest "CanBookBeRenewed | bookings" => sub { > $schema->storage->txn_rollback; > }; > >+subtest "CanBookBeRenewed | future holds" => sub { >+ plan tests => 6; >+ >+ $schema->storage->txn_begin; >+ t::lib::Mocks::mock_preference( 'ConfirmFutureHolds', 3 ); >+ t::lib::Mocks::mock_preference( 'FutureHoldsBlockRenewals', 1 ); >+ >+ Koha::CirculationRules->set_rules( >+ { >+ categorycode => undef, branchcode => undef, itemtype => undef, >+ rules => { renewalsallowed => 1, renewalperiod => 7 }, >+ } >+ ); >+ >+ my $future_date = DateTime->today->add( days => 2 ); >+ my $patron1 = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $patron2 = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $item = $builder->build_sample_item; >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $issue = AddIssue( $patron1, $item->barcode ); # not mangling userenv here >+ my $reserve_id = AddReserve( >+ { >+ branchcode => $library->branchcode, borrowernumber => $patron2->id, >+ biblionumber => $item->biblionumber, itemnumber => $item->id, reservation_date => $future_date >+ } >+ ); >+ my $hold = Koha::Holds->find($reserve_id); >+ >+ # Future hold should block renewal >+ my ( $renewok, $error ) = CanBookBeRenewed( $patron1, $issue, 0 ); >+ is( $renewok, 0, 'Cannot be renewed due to future hold' ); >+ is( $error, 'on_reserve', 'Check error message' ); >+ >+ # Move hold past 3 days limit so should be renewable >+ $hold->reservedate( $future_date->add( days => 2 ) )->store; >+ ( $renewok, $error ) = CanBookBeRenewed( $patron1, $issue, 0 ); >+ is( $renewok, 1, 'Can be renewed when reservedate is too far' ); >+ is( $error, undef, 'No error message' ); >+ >+ # Skip future holds for renewals >+ t::lib::Mocks::mock_preference( 'FutureHoldsBlockRenewals', 0 ); >+ $hold->reservedate($future_date)->store; >+ ( $renewok, $error ) = CanBookBeRenewed( $patron1, $issue, 0 ); >+ is( $renewok, 1, 'Can be renewed when future holds are skipped' ); >+ is( $error, undef, 'No error message 2' ); >+ >+ t::lib::Mocks::mock_preference( 'ConfirmFutureHolds', 0 ); >+ t::lib::Mocks::mock_preference( 'FutureHoldsBlockRenewals', 0 ); >+ $schema->storage->txn_rollback; >+}; >+ > subtest "GetUpcomingDueIssues" => sub { > plan tests => 12; > >-- >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 40435
:
190449
|
190450
|
190451
|
190452
|
190453
|
190520
|
190521
|
190522
|
190523
|
190524
|
190671
|
190672
|
190673
|
190674
|
190675
|
190676
|
190677