Bugzilla – Attachment 97196 Details for
Bug 23934
Item level holds not checked for LocalHoldsPriority in Holds Queue
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23934: Unit test
Bug-23934-Unit-test.patch (text/plain), 9.34 KB, created by
Jonathan Druart
on 2020-01-10 13:05:38 UTC
(
hide
)
Description:
Bug 23934: Unit test
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-01-10 13:05:38 UTC
Size:
9.34 KB
patch
obsolete
>From 0227a38087eb8a3d471ecccc8d5a436c2523f3e5 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 31 Oct 2019 13:51:33 -0400 >Subject: [PATCH] Bug 23934: Unit test > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/db_dependent/HoldsQueue.t | 229 ++++++++++++++++++++++++++++++++++++++++---- > 1 file changed, 208 insertions(+), 21 deletions(-) > >diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t >index 8c8bb430dd..f103ac7b0c 100755 >--- a/t/db_dependent/HoldsQueue.t >+++ b/t/db_dependent/HoldsQueue.t >@@ -8,7 +8,7 @@ > > use Modern::Perl; > >-use Test::More tests => 48; >+use Test::More tests => 51; > use Data::Dumper; > > use C4::Calendar; >@@ -794,33 +794,220 @@ Koha::Holds->find( $reserve_id )->cancel; > # End testing hold itemtype limit > > >-# Test Local Holds Priority - Bug 18001 >-t::lib::Mocks::mock_preference('LocalHoldsPriority', 1); >-t::lib::Mocks::mock_preference('LocalHoldsPriorityPatronControl', 'PickupLibrary'); >-t::lib::Mocks::mock_preference('LocalHoldsPriorityItemControl', 'homebranch'); >+subtest "Test Local Holds Priority - Bib level" => sub { >+ plan tests => 2; >+ >+ Koha::Biblios->delete(); >+ t::lib::Mocks::mock_preference( 'LocalHoldsPriority', 1 ); >+ t::lib::Mocks::mock_preference( 'LocalHoldsPriorityPatronControl', 'PickupLibrary' ); >+ t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); >+ my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $local_patron = $builder->build_object( >+ { >+ class => "Koha::Patrons", >+ value => { >+ branchcode => $branch->branchcode >+ } >+ } >+ ); >+ my $other_patron = $builder->build_object( >+ { >+ class => "Koha::Patrons", >+ value => { >+ branchcode => $branch2->branchcode >+ } >+ } >+ ); >+ my $biblio = $builder->build_sample_biblio(); >+ my $item = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $branch->branchcode, >+ } >+ ); > >-$dbh->do("DELETE FROM tmp_holdsqueue"); >-$dbh->do("DELETE FROM hold_fill_targets"); >-$dbh->do("DELETE FROM reserves"); >+ my $reserve_id = >+ AddReserve( $branch2->branchcode, $other_patron->borrowernumber, >+ $biblio->biblionumber, '', 1, undef, undef, undef, undef, undef, undef, undef ); >+ my $reserve_id2 = >+ AddReserve( $item->homebranch, $local_patron->borrowernumber, >+ $biblio->biblionumber, '', 2, undef, undef, undef, undef, undef, undef, undef ); >+ >+ C4::HoldsQueue::CreateQueue(); >+ >+ my $queue_rs = $schema->resultset('TmpHoldsqueue'); >+ is( $queue_rs->count(), 1, >+ "Hold queue contains one hold" ); >+ is( >+ $queue_rs->next->borrowernumber, >+ $local_patron->borrowernumber, >+ "We should pick the local hold over the next available" >+ ); >+}; > >-$item = Koha::Items->find( { biblionumber => $biblionumber } ); >-$item->holdingbranch( $item->homebranch ); >-$item->store(); >+subtest "Test Local Holds Priority - Item level" => sub { >+ plan tests => 2; >+ >+ Koha::Biblios->delete(); >+ t::lib::Mocks::mock_preference( 'LocalHoldsPriority', 1 ); >+ t::lib::Mocks::mock_preference( 'LocalHoldsPriorityPatronControl', 'PickupLibrary' ); >+ t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); >+ my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $local_patron = $builder->build_object( >+ { >+ class => "Koha::Patrons", >+ value => { >+ branchcode => $branch->branchcode >+ } >+ } >+ ); >+ my $other_patron = $builder->build_object( >+ { >+ class => "Koha::Patrons", >+ value => { >+ branchcode => $branch2->branchcode >+ } >+ } >+ ); >+ my $biblio = $builder->build_sample_biblio(); >+ my $item = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $branch->branchcode, >+ } >+ ); > >-my $item2 = Koha::Item->new( $item->unblessed ); >-$item2->itemnumber( undef ); >-$item2->store(); >+ my $reserve_id = >+ AddReserve( $branch2->branchcode, $other_patron->borrowernumber, >+ $biblio->biblionumber, '', 1, undef, undef, undef, undef, $item->id, undef, undef ); >+ my $reserve_id2 = >+ AddReserve( $item->homebranch, $local_patron->borrowernumber, >+ $biblio->biblionumber, '', 2, undef, undef, undef, undef, $item->id, undef, undef ); > >-my $item3 = Koha::Item->new( $item->unblessed ); >-$item3->itemnumber( undef ); >-$item3->store(); >+ C4::HoldsQueue::CreateQueue(); > >-$reserve_id = AddReserve( $item->homebranch, $borrowernumber, $biblionumber, '', 1, undef, undef, undef, undef, undef, undef, undef ); >+ my $queue_rs = $schema->resultset('TmpHoldsqueue'); >+ my $q = $queue_rs->next; >+ is( $queue_rs->count(), 1, >+ "Hold queue contains one hold" ); >+ is( >+ $q->borrowernumber, >+ $local_patron->borrowernumber, >+ "We should pick the local hold over the next available" >+ ); >+}; > >-C4::HoldsQueue::CreateQueue(); >+subtest "Test Local Holds Priority - Item level hold over Record level hold (Bug 23934)" => sub { >+ plan tests => 2; >+ >+ Koha::Biblios->delete(); >+ t::lib::Mocks::mock_preference( 'LocalHoldsPriority', 1 ); >+ t::lib::Mocks::mock_preference( 'LocalHoldsPriorityPatronControl', 'PickupLibrary' ); >+ t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); >+ my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $local_patron = $builder->build_object( >+ { >+ class => "Koha::Patrons", >+ value => { >+ branchcode => $branch->branchcode >+ } >+ } >+ ); >+ my $other_patron = $builder->build_object( >+ { >+ class => "Koha::Patrons", >+ value => { >+ branchcode => $branch2->branchcode >+ } >+ } >+ ); >+ my $biblio = $builder->build_sample_biblio(); >+ my $item = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $branch->branchcode, >+ } >+ ); >+ >+ my $reserve_id = >+ AddReserve( $branch2->branchcode, $other_patron->borrowernumber, >+ $biblio->biblionumber, '', 1, undef, undef, undef, undef, undef, undef, undef ); >+ my $reserve_id2 = >+ AddReserve( $item->homebranch, $local_patron->borrowernumber, >+ $biblio->biblionumber, '', 2, undef, undef, undef, undef, $item->id, undef, undef ); >+ >+ C4::HoldsQueue::CreateQueue(); >+ >+ my $queue_rs = $schema->resultset('TmpHoldsqueue'); >+ my $q = $queue_rs->next; >+ is( $queue_rs->count(), 1, >+ "Hold queue contains one hold" ); >+ is( >+ $q->borrowernumber, >+ $local_patron->borrowernumber, >+ "We should pick the local hold over the next available" >+ ); >+}; >+ >+subtest "Test Local Holds Priority - Ensure no duplicate requests in holds queue (Bug 18001)" => sub { >+ plan tests => 1; >+ >+ $dbh->do("DELETE FROM tmp_holdsqueue"); >+ $dbh->do("DELETE FROM hold_fill_targets"); >+ $dbh->do("DELETE FROM reserves"); >+ $dbh->do("DELETE FROM issuingrules"); >+ $dbh->do("DELETE FROM circulation_rules"); >+ Koha::Biblios->delete(); >+ >+ t::lib::Mocks::mock_preference( 'LocalHoldsPriority', 1 ); >+ t::lib::Mocks::mock_preference( 'LocalHoldsPriorityPatronControl', 'PickupLibrary' ); >+ t::lib::Mocks::mock_preference( 'LocalHoldsPriorityItemControl', 'homebranch' ); >+ my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $branch2 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $patron = $builder->build_object( >+ { >+ class => "Koha::Patrons", >+ value => { >+ branchcode => $branch->branchcode >+ } >+ } >+ ); >+ my $biblio = $builder->build_sample_biblio(); >+ my $item1 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $branch->branchcode, >+ } >+ ); >+ my $item2 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $branch->branchcode, >+ } >+ ); >+ >+ my $item3 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $branch->branchcode, >+ } >+ ); >+ >+ $reserve_id = >+ AddReserve( $item1->homebranch, $patron->borrowernumber, $biblio->id, '', >+ 1, undef, undef, undef, undef, undef, undef, undef ); >+ >+ C4::HoldsQueue::CreateQueue(); >+ >+ my $queue_rs = $schema->resultset('TmpHoldsqueue'); >+ >+ is( $queue_rs->count(), 1, >+ "Hold queue contains one hold from chosen from three possible items" ); >+}; > >-my $queue_rs = $schema->resultset('TmpHoldsqueue'); >-is( $queue_rs->count(), 1, "Hold queue contains one hold from chosen from three possible items" ); > > subtest 'Trivial test for UpdateTransportCostMatrix' => sub { > plan tests => 1; >-- >2.11.0
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 23934
:
94908
|
94923
|
94924
|
94926
|
94929
|
94930
|
96163
| 97196 |
97197