Bugzilla – Attachment 188009 Details for
Bug 39204
Problem with cancelling a hold via SIP without marking it as waiting returns an error
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39204: Unit test
Bug-39204-Unit-test.patch (text/plain), 3.98 KB, created by
Laura Escamilla
on 2025-10-16 14:08:30 UTC
(
hide
)
Description:
Bug 39204: Unit test
Filename:
MIME Type:
Creator:
Laura Escamilla
Created:
2025-10-16 14:08:30 UTC
Size:
3.98 KB
patch
obsolete
>From 04129dc9415683ec938db718077cfd3100ad4500 Mon Sep 17 00:00:00 2001 >From: Laura_Escamilla <laura.escamilla@bywatersolutions.com> >Date: Thu, 16 Oct 2025 14:07:51 +0000 >Subject: [PATCH] Bug 39204: Unit test > >--- > t/db_dependent/Koha/Hold.t | 81 +++++++++++++++++++++++++++++++++++++- > 1 file changed, 80 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Hold.t b/t/db_dependent/Koha/Hold.t >index 22b8ddbb14..997ea189fd 100755 >--- a/t/db_dependent/Koha/Hold.t >+++ b/t/db_dependent/Koha/Hold.t >@@ -1264,7 +1264,7 @@ subtest 'strings_map() tests' => sub { > > subtest 'revert_found() tests' => sub { > >- plan tests => 6; >+ plan tests => 7; > > subtest 'item-level holds tests' => sub { > >@@ -1592,6 +1592,85 @@ subtest 'revert_found() tests' => sub { > $schema->storage->txn_rollback; > }; > >+ subtest 'SIP do_hold/drop_hold regression: item-level visibility and cancel' => sub { >+ >+ plan tests => 6; >+ $schema->storage->txn_begin; >+ >+ use C4::Reserves qw(AddReserve); >+ use Test::MockModule; >+ >+ my $letters_mock = Test::MockModule->new('C4::Letters'); >+ $letters_mock->mock( 'GetPreparedLetter', sub { return { content => '', title => '' } } ); >+ >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $branch = $library->branchcode; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ my $biblio = $builder->build_sample_biblio( { title => 'SIP regression test' } ); >+ my $item = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); >+ my $priority = C4::Reserves::CalculatePriority( $biblio->biblionumber ); >+ AddReserve( >+ { >+ branchcode => $branch, >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $biblio->biblionumber, >+ priority => $priority, >+ } >+ ); >+ >+ my $holds_via_item_title = $item->holds->search( { borrowernumber => $patron->borrowernumber } ); >+ is( >+ $holds_via_item_title->count, 0, >+ 'Title-level hold is NOT visible via item->holds (expected baseline)' >+ ); >+ >+ my $title_hold = Koha::Holds->search( >+ { borrowernumber => $patron->borrowernumber, biblionumber => $biblio->biblionumber, itemnumber => undef } ) >+ ->next; >+ ok( $title_hold, 'Title-level hold created' ); >+ >+ if ( $title_hold->can('cancel') ) { >+ $title_hold->cancel( { cancellation_reason => 'TEST' } ); >+ } else { >+ $title_hold->delete; >+ } >+ ok( !Koha::Holds->find( $title_hold->id ), 'Title-level hold canceled (cleanup)' ); >+ >+ $priority = C4::Reserves::CalculatePriority( $biblio->biblionumber ); >+ AddReserve( >+ { >+ branchcode => $branch, >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $biblio->biblionumber, >+ itemnumber => $item->itemnumber, >+ priority => $priority, >+ } >+ ); >+ >+ my $holds_via_item = $item->holds->search( { borrowernumber => $patron->borrowernumber } ); >+ is( >+ $holds_via_item->count, 1, >+ 'Item-level hold IS visible via item->holds (SIP drop_hold depends on this)' >+ ); >+ my $item_hold = $holds_via_item->next; >+ ok( $item_hold && $item_hold->id, 'Have the specific item-level hold object' ); >+ if ( $item_hold->can('cancel') ) { >+ $item_hold->cancel( { cancellation_reason => 'TEST' } ); >+ } else { >+ $item_hold->delete; >+ } >+ ok( >+ !Koha::Holds->find( $item_hold->id ), >+ 'Item-level hold canceled successfully (mirrors SIP drop_hold behavior)' >+ ); >+ >+ $letters_mock->unmock_all; >+ >+ $schema->storage->txn_rollback; >+ }; >+ > subtest 'desk_id handling tests' => 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 39204
:
185913
|
185921
| 188009