Bugzilla – Attachment 120137 Details for
Bug 18989
Allow displaying biblios with all items hidden by OpacHiddenItems
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18989: (QA follow-up) Make Koha::Biblio->hidden_in_opac aware of OpacHiddenItemsHidesRecord
Bug-18989-QA-follow-up-Make-KohaBiblio-hiddeninopa.patch (text/plain), 3.97 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-04-23 19:51:30 UTC
(
hide
)
Description:
Bug 18989: (QA follow-up) Make Koha::Biblio->hidden_in_opac aware of OpacHiddenItemsHidesRecord
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-04-23 19:51:30 UTC
Size:
3.97 KB
patch
obsolete
>From eb80d3f664b57ecaa9677cfc8ae5959003ec69ef Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 23 Apr 2021 15:30:03 -0300 >Subject: [PATCH] Bug 18989: (QA follow-up) Make Koha::Biblio->hidden_in_opac > aware of OpacHiddenItemsHidesRecord > >This patch makes the method aware of the new syspref. It will only eval >the rules against items if the OpacHiddenItemsHidesRecord syspref is >set. > >Tests are added to reflect this. > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Biblio.t >=> SUCCESS: Tests pass! >3. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Biblio.pm | 6 +++++- > t/db_dependent/Koha/Biblio.t | 30 +++++++++++++++++++++++++----- > 2 files changed, 30 insertions(+), 6 deletions(-) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index fc1affe2333..92adf709e96 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -234,7 +234,8 @@ sub pickup_locations { > my $bool = $biblio->hidden_in_opac({ [ rules => $rules ] }) > > Returns true if the biblio matches the hidding criteria defined in $rules. >-Returns false otherwise. >+Returns false otherwise. It involves the I<OpacHiddenItems> and >+I<OpacHiddenItemsHidesRecord> system preferences. > > Takes HASHref that can have the following parameters: > OPTIONAL PARAMETERS: >@@ -254,6 +255,9 @@ sub hidden_in_opac { > > return 0 unless @items; # Do not hide if there is no item > >+ # Ok, there are items, don't even try the rules unless OpacHiddenItemsHidesRecord >+ return 0 unless C4::Context->preference('OpacHiddenItemsHidesRecord'); >+ > return !(any { !$_->hidden_in_opac({ rules => $rules }) } @items); > } > >diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t >index c396bd88248..ac5699ee125 100755 >--- a/t/db_dependent/Koha/Biblio.t >+++ b/t/db_dependent/Koha/Biblio.t >@@ -63,13 +63,26 @@ subtest 'metadata() tests' => sub { > > subtest 'hidden_in_opac() tests' => sub { > >- plan tests => 4; >+ plan tests => 6; > > $schema->storage->txn_begin; > > my $biblio = $builder->build_sample_biblio(); >+ my $rules = { withdrawn => [ 2 ] }; >+ >+ t::lib::Mocks::mock_preference( 'OpacHiddenItemsHidesRecord', 0 ); > >- ok( !$biblio->hidden_in_opac({ rules => { withdrawn => [ 2 ] } }), 'Biblio not hidden if there is no item attached' ); >+ ok( >+ !$biblio->hidden_in_opac({ rules => $rules }), >+ 'Biblio not hidden if there is no item attached (!OpacHiddenItemsHidesRecord)' >+ ); >+ >+ t::lib::Mocks::mock_preference( 'OpacHiddenItemsHidesRecord', 1 ); >+ >+ ok( >+ !$biblio->hidden_in_opac({ rules => $rules }), >+ 'Biblio not hidden if there is no item attached (OpacHiddenItemsHidesRecord)' >+ ); > > my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); > my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); >@@ -77,17 +90,24 @@ subtest 'hidden_in_opac() tests' => sub { > $item_1->withdrawn( 1 )->store->discard_changes; > $item_2->withdrawn( 1 )->store->discard_changes; > >- ok( !$biblio->hidden_in_opac({ rules => { withdrawn => [ 2 ] } }), 'Biblio not hidden' ); >+ ok( !$biblio->hidden_in_opac({ rules => $rules }), 'Biblio not hidden' ); > > $item_2->withdrawn( 2 )->store->discard_changes; > $biblio->discard_changes; # refresh > >- ok( !$biblio->hidden_in_opac({ rules => { withdrawn => [ 2 ] } }), 'Biblio not hidden' ); >+ ok( !$biblio->hidden_in_opac({ rules => $rules }), 'Biblio not hidden' ); > > $item_1->withdrawn( 2 )->store->discard_changes; > $biblio->discard_changes; # refresh > >- ok( $biblio->hidden_in_opac({ rules => { withdrawn => [ 2 ] } }), 'Biblio hidden' ); >+ ok( $biblio->hidden_in_opac({ rules => $rules }), 'Biblio hidden' ); >+ >+ t::lib::Mocks::mock_preference( 'OpacHiddenItemsHidesRecord', 0 ); >+ ok( >+ !$biblio->hidden_in_opac( { rules => $rules } ), >+ 'Biblio hidden (!OpacHiddenItemsHidesRecord)' >+ ); >+ > > $schema->storage->txn_rollback; > }; >-- >2.31.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18989
:
109656
|
109657
|
114738
|
116000
|
116001
|
116002
|
116003
|
119524
|
119784
|
119785
|
119786
|
119787
|
119788
| 120137 |
120138
|
120171
|
120431
|
120432
|
120558