From 0ce67ce4b66d5784bc1e06987c7ec6c03b9e7b43 Mon Sep 17 00:00:00 2001 From: Ere Maijala Date: Fri, 1 Mar 2019 16:13:25 +0200 Subject: [PATCH] Bug 20664: (follow-up) Add tests for UseHidingRulesWithBorrowerCategory Signed-off-by: Josef Moravec --- t/db_dependent/Items.t | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index ba8e332820..baadf59743 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -34,7 +34,7 @@ use Koha::AuthorisedValues; use t::lib::Mocks; use t::lib::TestBuilder; -use Test::More tests => 17; +use Test::More tests => 18; use Test::Warn; @@ -1124,4 +1124,21 @@ subtest 'tests for GetMarcItemFields' => sub { is_deeply( $item3_marc->field($itemtag), @$marc_items[0], "We should get the third item when explicitly requested"); $schema->storage->txn_rollback; -}; \ No newline at end of file +}; + +subtest 'tests for UseHidingRulesWithBorrowerCategory' => sub { + plan tests => 6; + + t::lib::Mocks::mock_preference('OpacHiddenItemsExceptions', ''); + + is(C4::Items::UseHidingRulesWithBorrowerCategory('PT'), 1, 'Hiding rules used for category PT'); + is(C4::Items::UseHidingRulesWithBorrowerCategory('S'), 1, 'Hiding rules used for category S'); + + t::lib::Mocks::mock_preference('OpacHiddenItemsExceptions', 'S|L'); + + is(C4::Items::UseHidingRulesWithBorrowerCategory('PT'), 1, 'Hiding rules used for category PT'); + is(C4::Items::UseHidingRulesWithBorrowerCategory('S'), 0, 'Hiding rules ignored for category S'); + is(C4::Items::UseHidingRulesWithBorrowerCategory('L'), 0, 'Hiding rules ignored for category L'); + + is(C4::Items::UseHidingRulesWithBorrowerCategory(), 1, 'Hiding rules used for unspecified category'); +}; -- 2.11.0