From a845188c7d3a7700301d5d649ad7685f72879d6d Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 22 Dec 2017 10:08:07 +0100 Subject: [PATCH] Bug 19301: (QA follow-up) Add a few simple tests We removed tests from Reserves.t, but would be nice to test the new sub in IssuingRules.t too. Adding a subtest there. Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- t/db_dependent/Koha/IssuingRules.t | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/IssuingRules.t b/t/db_dependent/Koha/IssuingRules.t index b1c97bfa4d..66e2836759 100644 --- a/t/db_dependent/Koha/IssuingRules.t +++ b/t/db_dependent/Koha/IssuingRules.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 2; +use Test::More tests => 3; use Benchmark; @@ -290,6 +290,22 @@ subtest 'get_opacitemholds_policy' => sub { $patron->delete; }; +subtest 'get_onshelfholds_policy' => sub { + plan tests => 3; + + t::lib::Mocks::mock_preference('item-level_itypes', 1); + Koha::IssuingRules->delete; + + my $patron = $builder->build_object({ class => 'Koha::Patrons' }); + my $item = $builder->build_object({ class => 'Koha::Items' }); + + is( Koha::IssuingRules->get_onshelfholds_policy({ item => $item, patron => $patron }), undef, 'Should return undef when no rules can be found' ); + Koha::IssuingRule->new({ categorycode => $patron->categorycode, itemtype => $item->itype, branchcode => '*', onshelfholds => "0" })->store; + is( Koha::IssuingRules->get_onshelfholds_policy({ item => $item, patron => $patron }), 0, 'Should be zero' ); + Koha::IssuingRule->new({ categorycode => $patron->categorycode, itemtype => $item->itype, branchcode => $item->holdingbranch, onshelfholds => "2" })->store; + is( Koha::IssuingRules->get_onshelfholds_policy({ item => $item, patron => $patron }), 2, 'Should be two now' ); +}; + sub _row_match { my ($rule, $branchcode, $categorycode, $itemtype) = @_; -- 2.20.1