@@ -, +, @@ UseHidingRulesWithBorrowerCategory --- t/db_dependent/Items.t | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) --- a/t/db_dependent/Items.t +++ a/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; -}; +}; + +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'); +}; --