Bugzilla – Attachment 181948 Details for
Bug 31698
Add ability to move a hold to a new bibliographic record/item
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31698: Add unit tests
Bug-31698-Add-unit-tests.patch (text/plain), 5.47 KB, created by
Lucas Gass (lukeg)
on 2025-05-05 20:53:21 UTC
(
hide
)
Description:
Bug 31698: Add unit tests
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-05-05 20:53:21 UTC
Size:
5.47 KB
patch
obsolete
>From 7d2744dbc618061980392cfae563ec1d9b5d381e Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Mon, 5 May 2025 20:51:48 +0000 >Subject: [PATCH] Bug 31698: Add unit tests > >--- > t/db_dependent/Koha/Hold.t | 151 ++++++++++++++++++++++++++++++++++++- > 1 file changed, 150 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Hold.t b/t/db_dependent/Koha/Hold.t >index 4b84be57447..610691e6924 100755 >--- a/t/db_dependent/Koha/Hold.t >+++ b/t/db_dependent/Koha/Hold.t >@@ -20,7 +20,7 @@ > use Modern::Perl; > > use Test::NoWarnings; >-use Test::More tests => 15; >+use Test::More tests => 16; > > use Test::Exception; > use Test::MockModule; >@@ -1161,3 +1161,152 @@ subtest 'change_type() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'move_hold() tests' => sub { >+ plan tests => 11; >+ $schema->storage->txn_begin; >+ >+ my $patron = Koha::Patron->new( >+ { >+ surname => 'Luke', >+ categorycode => 'PT', >+ branchcode => 'CPL' >+ } >+ )->store; >+ >+ my $patron_2 = Koha::Patron->new( >+ { >+ surname => 'Gass', >+ categorycode => 'PT', >+ branchcode => 'CPL' >+ } >+ )->store; >+ >+ my $patron_3 = Koha::Patron->new( >+ { >+ surname => 'Test', >+ categorycode => 'PT', >+ branchcode => 'CPL' >+ } >+ )->store; >+ >+ my $patron_4 = Koha::Patron->new( >+ { >+ surname => 'Guy', >+ categorycode => 'PT', >+ branchcode => 'CPL' >+ } >+ )->store; >+ >+ my $biblio1 = $builder->build_sample_biblio(); >+ my $item_1 = $builder->build_sample_item( { biblionumber => $biblio1->biblionumber } ); >+ >+ my $biblio2 = $builder->build_sample_biblio(); >+ my $item_2 = $builder->build_sample_item( { biblionumber => $biblio2->biblionumber } ); >+ >+ my $biblio3 = $builder->build_sample_biblio(); >+ my $item_3 = $builder->build_sample_item( { biblionumber => $biblio3->biblionumber } ); >+ >+ my $biblio4 = $builder->build_sample_biblio(); >+ my $item_4 = $builder->build_sample_item( { biblionumber => $biblio4->biblionumber } ); >+ >+ # Create an item level hold >+ my $hold = Koha::Hold->new( >+ { >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $biblio1->biblionumber, >+ itemnumber => $item_1->itemnumber, >+ branchcode => 'CPL', >+ } >+ )->store; >+ >+ # Create a record level hold >+ my $hold_2 = Koha::Hold->new( >+ { >+ borrowernumber => $patron->borrowernumber, >+ biblionumber => $biblio1->biblionumber, >+ itemnumber => undef, >+ branchcode => 'CPL', >+ } >+ )->store; >+ >+ # Move the hold from item 1 to item 2 >+ my $result = $hold->move_hold( { new_itemnumber => $item_2->itemnumber } ); >+ ok( $result->{success}, 'Hold successfully moved' ); >+ $hold->discard_changes(); >+ is( $hold->biblionumber, $biblio2->biblionumber, 'Biblionumber updated correctly' ); >+ is( $hold->itemnumber, $item_2->itemnumber, 'Itemnumber updated correctly' ); >+ is( $hold->priority, 1, "Hold priority is set to 1" ); >+ >+ my $logs = Koha::ActionLogs->search( >+ { >+ action => 'MODIFY', >+ module => 'HOLDS', >+ object => $hold->id >+ } >+ ); >+ >+ is( $logs->count, 0, 'HoldsLog disabled, no logs added' ); >+ >+ my $result_2 = $hold_2->move_hold( { new_biblionumber => $biblio3->biblionumber } ); >+ ok( $result_2->{success}, 'Hold successfully moved' ); >+ $hold_2->discard_changes(); >+ is( $hold_2->biblionumber, $biblio3->biblionumber, 'Biblionumber updated correctly' ); >+ is( $hold->priority, 1, "Hold priority is set to 1" ); >+ >+ # Create an item level hold >+ my $hold_3 = Koha::Hold->new( >+ { >+ borrowernumber => $patron_3->borrowernumber, >+ biblionumber => $biblio4->biblionumber, >+ itemnumber => $item_4->itemnumber, >+ branchcode => 'CPL', >+ priority => 1, >+ } >+ )->store; >+ >+ # Create an item level hold >+ my $hold_4 = Koha::Hold->new( >+ { >+ borrowernumber => $patron_2->borrowernumber, >+ biblionumber => $biblio4->biblionumber, >+ itemnumber => $item_4->itemnumber, >+ branchcode => 'CPL', >+ priority => 2, >+ } >+ )->store; >+ >+ # Create an item level hold >+ my $hold_5 = Koha::Hold->new( >+ { >+ borrowernumber => $patron_4->borrowernumber, >+ biblionumber => $biblio4->biblionumber, >+ itemnumber => $item_4->itemnumber, >+ branchcode => 'CPL', >+ priority => 3, >+ } >+ )->store; >+ >+ #enable HoldsLog >+ t::lib::Mocks::mock_preference( 'HoldsLog', 1 ); >+ >+ my $result_3 = $hold_2->move_hold( { new_biblionumber => $biblio4->biblionumber } ); >+ ok( $result_3->{success}, 'Hold successfully moved' ); >+ $hold_2->discard_changes; >+ is( $hold_2->priority, 4, "Hold priority is set to 4" ); >+ >+ my $logs_2 = Koha::ActionLogs->search( >+ { >+ action => 'MODIFY', >+ module => 'HOLDS', >+ object => $hold_2->id >+ } >+ ); >+ >+ is( $logs_2->count, 1, 'Hold modification was logged' ); >+ >+ #disable HoldsLog >+ t::lib::Mocks::mock_preference( 'HoldsLog', 1 ); >+ >+ $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 31698
:
179226
|
179235
|
179236
|
179279
|
179287
|
179290
|
179291
|
179292
|
179295
|
179704
|
179711
|
179713
|
181222
|
181223
|
181224
|
181225
|
181226
|
181228
|
181229
|
181230
|
181231
|
181232
|
181233
|
181234
|
181929
|
181930
|
181944
|
181945
|
181946
|
181947
|
181948
|
181951
|
181952
|
181953
|
181954
|
181955
|
181956
|
181957
|
181958
|
181959
|
181960
|
181961
|
181962
|
182639
|
182640
|
182641