From 819ef7985919a2cb1471f1c282e693f23f5868a6 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 31 Aug 2016 15:52:08 +0200 Subject: [PATCH] Bug 17229: Add unit test for BlockExpiredPatronOpacActions check --- t/db_dependent/Holds.t | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Holds.t b/t/db_dependent/Holds.t index 5825f7cad3..7d1f6903da 100755 --- a/t/db_dependent/Holds.t +++ b/t/db_dependent/Holds.t @@ -7,7 +7,7 @@ use t::lib::TestBuilder; use C4::Context; -use Test::More tests => 61; +use Test::More tests => 62; use MARC::Record; use C4::Biblio; use C4::Items; @@ -34,7 +34,12 @@ my $dbh = C4::Context->dbh; my $branch_1 = $builder->build({ source => 'Branch' })->{ branchcode }; my $branch_2 = $builder->build({ source => 'Branch' })->{ branchcode }; -my $category = $builder->build({ source => 'Category' }); +my $category = $builder->build({ + source => 'Category', + value => { + BlockExpiredPatronOpacActions => -1, + }, +}); my $borrowers_count = 5; @@ -486,6 +491,17 @@ my $res_id = AddReserve( $branch_1, $borrowernumbers[0], $bibnum, '', 1, ); is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ), 'tooManyReserves', 'Patron cannot reserve item with hold limit of 1, 1 bib level hold placed' ); +my $expired_borrowernumber = AddMember( + firstname => 'Expired', + surname => 'Patron', + categorycode => $category->{categorycode}, + branchcode => $branch_1, + dateexpiry => '2000-01-01', +); +t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); +is(CanItemBeReserved($expired_borrowernumber, $itemnumber), + 'expired', 'Expired patron cannot reserve'); + # Helper method to set up a Biblio. sub create_helper_biblio { -- 2.11.0