Bug 22749: Regression tests for Koha::Item->hidden_in_opac
This patch introduces regression tests for Koha::Item->hidden_in_opac to verify it is not considering the hidelostitems syspref when determining if an item should be hidden (per policy) in the OPAC. To test: - Apply this patch - Run: $ kshell k$ prove t/db_dependent/Koha/Item.t => FAIL: Tests fail! Signed-off-by: Liz Rea <wizzyrea@gmail.com> Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
b78bd2faec
commit
6f4565ce68
|
|
@ -32,21 +32,32 @@ my $builder = t::lib::TestBuilder->new;
|
|||
|
||||
subtest 'hidden_in_opac() tests' => sub {
|
||||
|
||||
plan tests => 3;
|
||||
plan tests => 4;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $item = $builder->build_sample_item;
|
||||
my $item = $builder->build_sample_item({ itemlost => 2 });
|
||||
my $rules = {};
|
||||
|
||||
# disable hidelostitems as it interteres with OpachiddenItems for the calculation
|
||||
t::lib::Mocks::mock_preference( 'hidelostitems', 0 );
|
||||
|
||||
ok( !$item->hidden_in_opac, 'No rules passed, shouldn\'t hide' );
|
||||
ok( !$item->hidden_in_opac({ rules => $rules }), 'Empty rules passed, shouldn\'t hide' );
|
||||
|
||||
# enable hidelostitems to verify correct behaviour
|
||||
t::lib::Mocks::mock_preference( 'hidelostitems', 1 );
|
||||
ok( $item->hidden_in_opac, 'Even with no rules, item should hide because of hidelostitems syspref' );
|
||||
|
||||
# disable hidelostitems
|
||||
t::lib::Mocks::mock_preference( 'hidelostitems', 0 );
|
||||
my $withdrawn = $item->withdrawn + 1; # make sure this attribute doesn't match
|
||||
|
||||
$rules = { withdrawn => [$withdrawn], itype => [ $item->itype ] };
|
||||
|
||||
ok( $item->hidden_in_opac({ rules => $rules }), 'Rule matching itype passed, should hide' );
|
||||
|
||||
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue