Lines 32-52
my $builder = t::lib::TestBuilder->new;
Link Here
|
32 |
|
32 |
|
33 |
subtest 'hidden_in_opac() tests' => sub { |
33 |
subtest 'hidden_in_opac() tests' => sub { |
34 |
|
34 |
|
35 |
plan tests => 3; |
35 |
plan tests => 4; |
36 |
|
36 |
|
37 |
$schema->storage->txn_begin; |
37 |
$schema->storage->txn_begin; |
38 |
|
38 |
|
39 |
my $item = $builder->build_sample_item; |
39 |
my $item = $builder->build_sample_item({ itemlost => 2 }); |
40 |
my $rules = {}; |
40 |
my $rules = {}; |
41 |
|
41 |
|
|
|
42 |
# disable hidelostitems as it interteres with OpachiddenItems for the calculation |
43 |
t::lib::Mocks::mock_preference( 'hidelostitems', 0 ); |
44 |
|
42 |
ok( !$item->hidden_in_opac, 'No rules passed, shouldn\'t hide' ); |
45 |
ok( !$item->hidden_in_opac, 'No rules passed, shouldn\'t hide' ); |
43 |
ok( !$item->hidden_in_opac({ rules => $rules }), 'Empty rules passed, shouldn\'t hide' ); |
46 |
ok( !$item->hidden_in_opac({ rules => $rules }), 'Empty rules passed, shouldn\'t hide' ); |
44 |
|
47 |
|
|
|
48 |
# enable hidelostitems to verify correct behaviour |
49 |
t::lib::Mocks::mock_preference( 'hidelostitems', 1 ); |
50 |
ok( $item->hidden_in_opac, 'Even with no rules, item should hide because of hidelostitems syspref' ); |
51 |
|
52 |
# disable hidelostitems |
53 |
t::lib::Mocks::mock_preference( 'hidelostitems', 0 ); |
45 |
my $withdrawn = $item->withdrawn + 1; # make sure this attribute doesn't match |
54 |
my $withdrawn = $item->withdrawn + 1; # make sure this attribute doesn't match |
46 |
|
55 |
|
47 |
$rules = { withdrawn => [$withdrawn], itype => [ $item->itype ] }; |
56 |
$rules = { withdrawn => [$withdrawn], itype => [ $item->itype ] }; |
48 |
|
57 |
|
49 |
ok( $item->hidden_in_opac({ rules => $rules }), 'Rule matching itype passed, should hide' ); |
58 |
ok( $item->hidden_in_opac({ rules => $rules }), 'Rule matching itype passed, should hide' ); |
50 |
|
59 |
|
|
|
60 |
|
61 |
|
51 |
$schema->storage->txn_rollback; |
62 |
$schema->storage->txn_rollback; |
52 |
}; |
63 |
}; |
53 |
- |
|
|