Bugzilla – Attachment 154160 Details for
Bug 29750
Reserves.pm should check patron category hold policies when finding a reserve for an item
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29750: Unit test fixes for Reserves.pm
Bug-29750-Unit-test-fixes-for-Reservespm.patch (text/plain), 5.61 KB, created by
Sam Lau
on 2023-08-02 14:52:01 UTC
(
hide
)
Description:
Bug 29750: Unit test fixes for Reserves.pm
Filename:
MIME Type:
Creator:
Sam Lau
Created:
2023-08-02 14:52:01 UTC
Size:
5.61 KB
patch
obsolete
>From f33bc3f8afbd64679651cc0e6ad676382e813af5 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Thu, 9 Dec 2021 19:46:21 +0000 >Subject: [PATCH] Bug 29750: Unit test fixes for Reserves.pm > >Test plan: >1. sudo koha-shell <instance> >2. >prove t/db_dependent/Holds.t >prove t/db_dependent/Reserves.t > >Sponsored-By: Catalyst IT >Signed-off-by: Sam Lau <samalau@gmail.com> >--- > t/db_dependent/Holds.t | 6 +++--- > t/db_dependent/Reserves.t | 41 ++++++++++++++++++++++++++++++++------- > 2 files changed, 37 insertions(+), 10 deletions(-) > >diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t >index 39224e9905..d47b976491 100755 >--- a/t/db_dependent/Holds.t >+++ b/t/db_dependent/Holds.t >@@ -44,7 +44,7 @@ my $builder = t::lib::TestBuilder->new(); > my $dbh = C4::Context->dbh; > > # Create two random branches >-my $branch_1 = $builder->build({ source => 'Branch' })->{ branchcode }; >+my $branch_1 = $builder->build({ source => 'Branch', value => { 'pickup_location' => 1 }})->{ branchcode }; > my $branch_2 = $builder->build({ source => 'Branch' })->{ branchcode }; > > my $category = $builder->build({ source => 'Category' }); >@@ -1483,8 +1483,8 @@ subtest 'non priority holds' => sub { > } > ); > >- my $item = $builder->build_sample_item; >- >+ my $branch = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } ); >+ my $item = $builder->build_sample_item({ library => $branch->branchcode }); > my $patron1 = $builder->build_object( > { > class => 'Koha::Patrons', >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 2d97fa43a1..e5dfd16a60 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -71,9 +71,9 @@ $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); > > ## Setup Test > # Add branches >-my $branch_1 = $builder->build({ source => 'Branch' })->{ branchcode }; >-my $branch_2 = $builder->build({ source => 'Branch' })->{ branchcode }; >-my $branch_3 = $builder->build({ source => 'Branch' })->{ branchcode }; >+my $branch_1 = $builder->build({ source => 'Branch', value => { pickup_location => 1 } })->{ branchcode }; >+my $branch_2 = $builder->build({ source => 'Branch', value => { pickup_location => 1 } })->{ branchcode }; >+my $branch_3 = $builder->build({ source => 'Branch', value => { pickup_location => 1 } })->{ branchcode }; > # Add categories > my $category_1 = $builder->build({ source => 'Category' })->{ categorycode }; > my $category_2 = $builder->build({ source => 'Category' })->{ categorycode }; >@@ -108,6 +108,19 @@ my $patron = Koha::Patrons->find( $borrowernumber ); > my $borrower = $patron->unblessed; > my $biblionumber = $bibnum; > >+# Set circulation rules >+Koha::CirculationRules->set_rules( >+ { >+ categorycode => undef, >+ branchcode => undef, >+ itemtype => undef, >+ rules => { >+ reservesallowed => 25, >+ holds_per_record => 99, >+ } >+ } >+); >+ > my $branchcode = Koha::Libraries->search->next->branchcode; > > AddReserve( >@@ -212,6 +225,17 @@ Koha::CirculationRules->set_rules( > } > } > ); >+Koha::CirculationRules->set_rules( >+ { >+ categorycode => undef, >+ branchcode => undef, >+ itemtype => undef, >+ rules => { >+ reservesallowed => 25, >+ holds_per_record => 99, >+ } >+ } >+); > > my $bibnum2 = $builder->build_sample_biblio({frameworkcode => $frameworkcode})->biblionumber; > >@@ -1088,9 +1112,10 @@ subtest 'MoveReserve additional test' => sub { > > # Create the items and patrons we need > my $biblio = $builder->build_sample_biblio(); >+ my $branch = $builder->build({ source => 'Branch', value => { pickup_location => 1 } })->{ branchcode }; > my $itype = $builder->build_object({ class => "Koha::ItemTypes", value => { notforloan => 0 } }); >- my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber,notforloan => 0, itype => $itype->itemtype }); >- my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, notforloan => 0, itype => $itype->itemtype }); >+ my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber,notforloan => 0, itype => $itype->itemtype, library => $branch }); >+ my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, notforloan => 0, itype => $itype->itemtype, library => $branch }); > my $patron_1 = $builder->build_object({ class => "Koha::Patrons" }); > my $patron_2 = $builder->build_object({ class => "Koha::Patrons" }); > >@@ -1172,8 +1197,10 @@ subtest 'RevertWaitingStatus' => sub { > subtest 'CheckReserves additional tests' => sub { > > plan tests => 8; >+ my $branch_1 = $builder->build({ source => 'Branch', value => { pickup_location => 1 } })->{ branchcode }; >+ my $branch_2 = $builder->build({ source => 'Branch', value => { pickup_location => 1 } })->{ branchcode }; > >- my $item = $builder->build_sample_item; >+ my $item = $builder->build_sample_item({ library => $branch_1 }); > my $reserve1 = $builder->build_object( > { > class => "Koha::Holds", >@@ -1245,7 +1272,7 @@ subtest 'CheckReserves additional tests' => sub { > $reserve1->reserve_id, "We got the Transit reserve" ); > is( scalar @$possible_reserves, 2, 'We do get both reserves' ); > >- my $patron_B = $builder->build_object({ class => "Koha::Patrons" }); >+ my $patron_B = $builder->build_object({ class => "Koha::Patrons", value => { branchcode => $branch_2, } }); > my $item_A = $builder->build_sample_item; > my $item_B = $builder->build_sample_item({ > homebranch => $patron_B->branchcode, >-- >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 29750
:
128858
|
128859
|
154140
|
154141
|
154159
| 154160