Lines 63-75
subtest 'metadata() tests' => sub {
Link Here
|
63 |
|
63 |
|
64 |
subtest 'hidden_in_opac() tests' => sub { |
64 |
subtest 'hidden_in_opac() tests' => sub { |
65 |
|
65 |
|
66 |
plan tests => 4; |
66 |
plan tests => 6; |
67 |
|
67 |
|
68 |
$schema->storage->txn_begin; |
68 |
$schema->storage->txn_begin; |
69 |
|
69 |
|
70 |
my $biblio = $builder->build_sample_biblio(); |
70 |
my $biblio = $builder->build_sample_biblio(); |
|
|
71 |
my $rules = { withdrawn => [ 2 ] }; |
72 |
|
73 |
t::lib::Mocks::mock_preference( 'OpacHiddenItemsHidesRecord', 0 ); |
71 |
|
74 |
|
72 |
ok( !$biblio->hidden_in_opac({ rules => { withdrawn => [ 2 ] } }), 'Biblio not hidden if there is no item attached' ); |
75 |
ok( |
|
|
76 |
!$biblio->hidden_in_opac({ rules => $rules }), |
77 |
'Biblio not hidden if there is no item attached (!OpacHiddenItemsHidesRecord)' |
78 |
); |
79 |
|
80 |
t::lib::Mocks::mock_preference( 'OpacHiddenItemsHidesRecord', 1 ); |
81 |
|
82 |
ok( |
83 |
!$biblio->hidden_in_opac({ rules => $rules }), |
84 |
'Biblio not hidden if there is no item attached (OpacHiddenItemsHidesRecord)' |
85 |
); |
73 |
|
86 |
|
74 |
my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); |
87 |
my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); |
75 |
my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); |
88 |
my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); |
Lines 77-93
subtest 'hidden_in_opac() tests' => sub {
Link Here
|
77 |
$item_1->withdrawn( 1 )->store->discard_changes; |
90 |
$item_1->withdrawn( 1 )->store->discard_changes; |
78 |
$item_2->withdrawn( 1 )->store->discard_changes; |
91 |
$item_2->withdrawn( 1 )->store->discard_changes; |
79 |
|
92 |
|
80 |
ok( !$biblio->hidden_in_opac({ rules => { withdrawn => [ 2 ] } }), 'Biblio not hidden' ); |
93 |
ok( !$biblio->hidden_in_opac({ rules => $rules }), 'Biblio not hidden' ); |
81 |
|
94 |
|
82 |
$item_2->withdrawn( 2 )->store->discard_changes; |
95 |
$item_2->withdrawn( 2 )->store->discard_changes; |
83 |
$biblio->discard_changes; # refresh |
96 |
$biblio->discard_changes; # refresh |
84 |
|
97 |
|
85 |
ok( !$biblio->hidden_in_opac({ rules => { withdrawn => [ 2 ] } }), 'Biblio not hidden' ); |
98 |
ok( !$biblio->hidden_in_opac({ rules => $rules }), 'Biblio not hidden' ); |
86 |
|
99 |
|
87 |
$item_1->withdrawn( 2 )->store->discard_changes; |
100 |
$item_1->withdrawn( 2 )->store->discard_changes; |
88 |
$biblio->discard_changes; # refresh |
101 |
$biblio->discard_changes; # refresh |
89 |
|
102 |
|
90 |
ok( $biblio->hidden_in_opac({ rules => { withdrawn => [ 2 ] } }), 'Biblio hidden' ); |
103 |
ok( $biblio->hidden_in_opac({ rules => $rules }), 'Biblio hidden' ); |
|
|
104 |
|
105 |
t::lib::Mocks::mock_preference( 'OpacHiddenItemsHidesRecord', 0 ); |
106 |
ok( |
107 |
!$biblio->hidden_in_opac( { rules => $rules } ), |
108 |
'Biblio hidden (!OpacHiddenItemsHidesRecord)' |
109 |
); |
110 |
|
91 |
|
111 |
|
92 |
$schema->storage->txn_rollback; |
112 |
$schema->storage->txn_rollback; |
93 |
}; |
113 |
}; |
94 |
- |
|
|