Bugzilla – Attachment 179311 Details for
Bug 38615
Cancelling a waiting hold via SIP should include an option to move it to holds with cancellation requests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38615: (follow-up) Unit tests
Bug-38615-follow-up-Unit-tests.patch (text/plain), 6.38 KB, created by
Martin Renvoize (ashimema)
on 2025-03-14 08:17:26 UTC
(
hide
)
Description:
Bug 38615: (follow-up) Unit tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-03-14 08:17:26 UTC
Size:
6.38 KB
patch
obsolete
>From 0736a9265b1ee8e901c1e2b79ee9fd9e1ef43ea1 Mon Sep 17 00:00:00 2001 >From: Brendan Lawlor <blawlor@clamsnet.org> >Date: Thu, 13 Mar 2025 20:13:05 +0000 >Subject: [PATCH] Bug 38615: (follow-up) Unit tests > >Adds tests for the new HoldCancellationRequestSIP preference > >Test plan: >1. prove t/db_dependent/SIP/ILS.t >2. prove t/db_dependent/SIP/Transaction.t > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/SIP/ILS.t | 30 ++++++++++- > t/db_dependent/SIP/Transaction.t | 86 +++++++++++++++++++++++++++++++- > 2 files changed, 114 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/SIP/ILS.t b/t/db_dependent/SIP/ILS.t >index a397cf19fbc..d04c000b380 100755 >--- a/t/db_dependent/SIP/ILS.t >+++ b/t/db_dependent/SIP/ILS.t >@@ -192,7 +192,7 @@ subtest cancel_hold => sub { > }; > > subtest cancel_waiting_hold => sub { >- plan tests => 7; >+ plan tests => 12; > > my $library = $builder->build_object( { class => 'Koha::Libraries' } ); > my $patron = $builder->build_object( >@@ -204,6 +204,7 @@ subtest cancel_waiting_hold => sub { > } > ); > t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode, flags => 1 } ); >+ t::lib::Mocks::mock_preference( 'HoldCancellationRequestSIP', 0 ); > > my $item = $builder->build_sample_item( > { >@@ -252,6 +253,33 @@ subtest cancel_waiting_hold => sub { > > is( $item->biblio->holds->count(), 0, "Bib has 0 holds remaining" ); > is( $item->holds->count(), 0, "Item has 0 holds remaining" ); >+ >+ t::lib::Mocks::mock_preference( 'HoldCancellationRequestSIP', 1 ); >+ >+ $reserve_id = AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $item->biblio->biblionumber, >+ itemnumber => $item->itemnumber, >+ } >+ ); >+ $hold = Koha::Holds->find($reserve_id); >+ ok( $hold, 'Get hold object' ); >+ $hold->update( { found => 'W' } ); >+ $hold->get_from_storage; >+ >+ is( $hold->found, 'W', "Hold was correctly set to waiting." ); >+ >+ $transaction = $ils->cancel_hold( $patron->cardnumber, undef, $item->barcode, undef ); >+ >+ is( >+ $transaction->{screen_msg}, "Hold Cancellation Requested.", >+ "We get a success message when hold cancellation requested" >+ ); >+ >+ is( $item->biblio->holds->count(), 1, "Bib has 1 holds remaining" ); >+ is( $item->holds->count(), 1, "Item has 1 holds remaining" ); > }; > > subtest checkout => sub { >diff --git a/t/db_dependent/SIP/Transaction.t b/t/db_dependent/SIP/Transaction.t >index 1bee4c17e7c..a07033def5b 100755 >--- a/t/db_dependent/SIP/Transaction.t >+++ b/t/db_dependent/SIP/Transaction.t >@@ -5,7 +5,7 @@ > > use Modern::Perl; > use Test::NoWarnings; >-use Test::More tests => 20; >+use Test::More tests => 21; > use Test::Warn; > > use DateTime; >@@ -223,6 +223,90 @@ subtest cancel_hold => sub { > is( $item->holds->count(), 0, "Item has 0 holds remaining" ); > }; > >+subtest cancel_waiting_hold => sub { >+ plan tests => 14; >+ >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { >+ branchcode => $library->branchcode, >+ } >+ } >+ ); >+ t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode, flags => 1 } ); >+ t::lib::Mocks::mock_preference( 'HoldCancellationRequestSIP', 0 ); >+ >+ my $item = $builder->build_sample_item( >+ { >+ library => $library->branchcode, >+ } >+ ); >+ >+ Koha::CirculationRules->set_rules( >+ { >+ categorycode => $patron->categorycode, >+ branchcode => $library->branchcode, >+ itemtype => $item->effective_itemtype, >+ rules => { >+ onshelfholds => 1, >+ reservesallowed => 3, >+ holds_per_record => 3, >+ issuelength => 5, >+ lengthunit => 'days', >+ } >+ } >+ ); >+ >+ my $reserve_id = AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $item->biblio->biblionumber, >+ itemnumber => $item->itemnumber, >+ } >+ ); >+ is( $item->biblio->holds->count(), 1, "Hold was placed on bib" ); >+ is( $item->holds->count(), 1, "Hold was placed on specific item" ); >+ >+ my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); >+ my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); >+ my $transaction = C4::SIP::ILS::Transaction::Hold->new(); >+ is( ref $transaction, "C4::SIP::ILS::Transaction::Hold", "New transaction created" ); >+ is( $transaction->patron($sip_patron), $sip_patron, "Patron assigned to transaction" ); >+ is( $transaction->item($sip_item), $sip_item, "Item assigned to transaction" ); >+ my $hold = $transaction->drop_hold(); >+ is( $item->biblio->holds->count(), 0, "Bib has 0 holds remaining" ); >+ is( $item->holds->count(), 0, "Item has 0 holds remaining" ); >+ >+ t::lib::Mocks::mock_preference( 'HoldCancellationRequestSIP', 1 ); >+ >+ $reserve_id = AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $item->biblio->biblionumber, >+ itemnumber => $item->itemnumber, >+ } >+ ); >+ >+ $hold = Koha::Holds->find($reserve_id); >+ ok( $hold, 'Get hold object' ); >+ $hold->update( { found => 'W' } ); >+ $hold->get_from_storage; >+ >+ is( $hold->found, 'W', "Hold was correctly set to waiting." ); >+ >+ $transaction = C4::SIP::ILS::Transaction::Hold->new(); >+ is( ref $transaction, "C4::SIP::ILS::Transaction::Hold", "New transaction created" ); >+ is( $transaction->patron($sip_patron), $sip_patron, "Patron assigned to transaction" ); >+ is( $transaction->item($sip_item), $sip_item, "Item assigned to transaction" ); >+ $hold = $transaction->drop_hold(); >+ is( $item->biblio->holds->count(), 1, "Bib has 1 holds remaining" ); >+ is( $item->holds->count(), 1, "Item has 1 holds remaining" ); >+}; >+ > subtest do_hold => sub { > plan tests => 8; > >-- >2.48.1
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 38615
:
175097
|
178046
|
178047
|
178055
|
178056
|
178098
|
178099
|
179288
|
179289
|
179309
|
179310
| 179311