Bugzilla – Attachment 142966 Details for
Bug 24860
Add ability to place item group level holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24860: (QA follow-up) Add unit tests to cover changes to HoldsQueue.pm
Bug-24860-QA-follow-up-Add-unit-tests-to-cover-cha.patch (text/plain), 5.82 KB, created by
Kyle M Hall (khall)
on 2022-11-02 13:14:57 UTC
(
hide
)
Description:
Bug 24860: (QA follow-up) Add unit tests to cover changes to HoldsQueue.pm
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2022-11-02 13:14:57 UTC
Size:
5.82 KB
patch
obsolete
>From 164c883090839868a578d5a228b89ea802d4cef4 Mon Sep 17 00:00:00 2001 >From: Kyle Hall <kyle@bywatersolutions.com> >Date: Wed, 12 Oct 2022 12:57:40 -0400 >Subject: [PATCH] Bug 24860: (QA follow-up) Add unit tests to cover changes to > HoldsQueue.pm > >--- > t/db_dependent/HoldsQueue.t | 152 +++++++++++++++++++++++++++++++++++- > 1 file changed, 151 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t >index 7067931c35..016ca7fa0f 100755 >--- a/t/db_dependent/HoldsQueue.t >+++ b/t/db_dependent/HoldsQueue.t >@@ -8,7 +8,7 @@ > > use Modern::Perl; > >-use Test::More tests => 58; >+use Test::More tests => 59; > use Data::Dumper; > > use C4::Calendar qw( new insert_single_holiday ); >@@ -1473,6 +1473,156 @@ subtest 'Excludes from local holds priority' => sub { > $next = $queue_rs->next; > is($next->borrowernumber->borrowernumber, $local_patron_excluded->borrowernumber, 'Excluded local patron is queued'); > }; >+ >+subtest "Test item group holds" => sub { >+ >+ plan tests => 4; >+ >+ $dbh->do("DELETE FROM tmp_holdsqueue"); >+ $dbh->do("DELETE FROM hold_fill_targets"); >+ $dbh->do("DELETE FROM reserves"); >+ $dbh->do("DELETE FROM circulation_rules"); >+ >+ t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 0); >+ t::lib::Mocks::mock_preference('LocalHoldsPriority', 0); >+ >+ my $library = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $category = $builder->build_object( { class => 'Koha::Patron::Categories', value => {exclude_from_local_holds_priority => 0} }); >+ my $patron_1 = $builder->build_object( >+ { >+ class => "Koha::Patrons", >+ value => { >+ branchcode => $library->branchcode, >+ categorycode => $category->categorycode >+ } >+ } >+ ); >+ >+ my $patron_2 = $builder->build_object( >+ { >+ class => "Koha::Patrons", >+ value => { >+ branchcode => $library->branchcode, >+ categorycode => $category->categorycode >+ } >+ } >+ ); >+ >+ my $patron_3 = $builder->build_object( >+ { >+ class => "Koha::Patrons", >+ value => { >+ branchcode => $library->branchcode, >+ categorycode => $category->categorycode >+ } >+ } >+ ); >+ >+ my $patron_4 = $builder->build_object( >+ { >+ class => "Koha::Patrons", >+ value => { >+ branchcode => $library->branchcode, >+ categorycode => $category->categorycode >+ } >+ } >+ ); >+ >+ my $biblio = $builder->build_sample_biblio(); >+ >+ my $item_1 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $library->branchcode, >+ exclude_from_local_holds_priority => 0, >+ } >+ ); >+ my $item_2 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $library->branchcode, >+ exclude_from_local_holds_priority => 0, >+ } >+ ); >+ my $item_3 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $library->branchcode, >+ exclude_from_local_holds_priority => 0, >+ } >+ ); >+ my $item_4 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $library->branchcode, >+ exclude_from_local_holds_priority => 0, >+ } >+ ); >+ >+ my $item_group_1 = Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id } )->store(); >+ my $item_group_2 = Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id } )->store(); >+ >+ $item_group_1->add_item({ item_id => $item_1->id }); >+ $item_group_1->add_item({ item_id => $item_2->id }); >+ >+ # Add item-level hold for patron_1 >+ my $reserve_id_1 = AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron_1->borrowernumber, >+ biblionumber => $biblio->id, >+ itemnumber => $item_1->itemnumber, >+ priority => 1, >+ item_group_id => $item_group_1->id >+ } >+ ); >+ >+ my $reserve_id_2 = AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron_2->borrowernumber, >+ biblionumber => $biblio->id, >+ priority => 2, >+ item_group_id => $item_group_2->id >+ } >+ ); >+ >+ my $reserve_id_3 = AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron_3->borrowernumber, >+ biblionumber => $biblio->id, >+ priority => 3, >+ item_group_id => $item_group_1->id >+ } >+ ); >+ >+ my $reserve_id_4 = AddReserve( >+ { >+ branchcode => $library->branchcode, >+ borrowernumber => $patron_4->borrowernumber, >+ biblionumber => $biblio->id, >+ priority => 4, >+ item_group_id => undef >+ } >+ ); >+ >+ C4::HoldsQueue::CreateQueue(); >+ >+ my $queue_rs = $schema->resultset('TmpHoldsqueue'); >+ >+ is( $queue_rs->count(), 3, "Hold queue contains two holds" ); >+ >+ my $queue_line_1 = $queue_rs->next; >+ is( $queue_line_1->borrowernumber->id, $patron_1->id, "Correct Hold was filled for the correct patron, item group 1, priority 1" ); >+ >+ my $queue_line_2 = $queue_rs->next; >+ is( $queue_line_2->borrowernumber->id, $patron_3->id, "Correct Hold was filled for the correct patron, item group 1, priority 2" ); >+ >+ my $queue_line_3 = $queue_rs->next; >+ is( $queue_line_3->borrowernumber->id, $patron_4->id, "Correct Hold was filled for the correct patron, no item group" ); >+}; >+ > # Cleanup > $schema->storage->txn_rollback; > >-- >2.30.2
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 24860
:
100644
|
100645
|
100646
|
100647
|
100648
|
100649
|
100650
|
100651
|
101744
|
101745
|
101746
|
101747
|
101748
|
101749
|
101750
|
101751
|
101827
|
101828
|
101829
|
101830
|
101831
|
101832
|
101833
|
101834
|
101835
|
102230
|
102231
|
102232
|
102233
|
102234
|
102235
|
102236
|
102237
|
102238
|
102239
|
102240
|
102241
|
102242
|
102243
|
102244
|
102245
|
102246
|
102247
|
106589
|
106590
|
106591
|
106592
|
106593
|
106594
|
106595
|
106596
|
106597
|
106682
|
106683
|
106684
|
106685
|
106686
|
106687
|
106688
|
106689
|
106690
|
106742
|
106743
|
106744
|
106745
|
106746
|
106747
|
106748
|
106749
|
106750
|
108458
|
108459
|
108460
|
108461
|
108462
|
108463
|
108464
|
108465
|
108466
|
109097
|
109098
|
109099
|
109100
|
109101
|
109102
|
109103
|
109104
|
109105
|
109171
|
109172
|
109173
|
109174
|
109175
|
109176
|
109177
|
109178
|
109179
|
113616
|
113617
|
113618
|
113619
|
113620
|
113621
|
113622
|
113623
|
113624
|
135922
|
135923
|
135924
|
135925
|
135926
|
135927
|
135928
|
135929
|
135930
|
138221
|
138222
|
138224
|
138225
|
138226
|
138227
|
138228
|
138229
|
138230
|
141214
|
141215
|
141735
|
141736
|
141737
|
141738
|
141739
|
141740
|
141741
|
141742
|
141743
|
141744
|
141745
|
141746
|
141747
|
141748
|
141749
|
141750
|
142413
|
142414
|
142415
|
142416
|
142417
|
142418
|
142419
|
142420
|
142421
|
142422
|
142423
|
142424
|
142425
|
142426
|
142427
|
142428
|
142429
|
142430
|
142827
|
142955
|
142956
|
142957
|
142958
|
142959
|
142960
|
142961
|
142962
|
142963
|
142964
|
142965
|
142966
|
142967
|
142968
|
142969
|
142970
|
142971
|
142972
|
142973
|
142974
|
142975
|
142992
|
142993
|
142994
|
142995
|
142996
|
142997
|
142998
|
142999
|
143000
|
143001
|
143002
|
143003
|
143004
|
143005
|
143006
|
143007
|
143008
|
143009
|
143010
|
143011