Bugzilla – Attachment 141855 Details for
Bug 31784
SingleBranchMode ignores public flag
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31784: Add Libraries->singleBranchMode
Bug-31784-Add-Libraries-singleBranchMode.patch (text/plain), 2.23 KB, created by
Marcel de Rooy
on 2022-10-14 07:03:38 UTC
(
hide
)
Description:
Bug 31784: Add Libraries->singleBranchMode
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2022-10-14 07:03:38 UTC
Size:
2.23 KB
patch
obsolete
>From e0c3de7093a19fa6bb5b1a933c23fe3763f9ce5e Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 14 Oct 2022 06:31:23 +0000 >Subject: [PATCH] Bug 31784: Add Libraries->singleBranchMode >Content-Type: text/plain; charset=utf-8 > >Test plan: >Run t/db_dependent/Koha/Libraries.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Libraries.pm | 18 ++++++++++++++++++ > t/db_dependent/Koha/Libraries.t | 16 +++++++++++++++- > 2 files changed, 33 insertions(+), 1 deletion(-) > >diff --git a/Koha/Libraries.pm b/Koha/Libraries.pm >index 20ceb8aa34..b4fd772164 100644 >--- a/Koha/Libraries.pm >+++ b/Koha/Libraries.pm >@@ -64,6 +64,24 @@ sub search_filtered { > return $self->SUPER::search( $params, $attributes ); > } > >+=head3 singleLibraryMode >+ >+ Aka singleBranchMode. >+ >+ my $boolean = Koha::Libraries->singleLibaryMode; >+ >+ Returns 1 if there is only one library marked public. >+ >+=cut >+ >+sub singleLibraryMode { # formerly called singleBranchMode >+ my $self = shift; >+ if( $self->search({ public => 1 })->count == 1 ) { # Historically we test number==1 instead of number<2 >+ return 1; >+ } >+ return 0; >+} >+ > =head3 type > > =cut >diff --git a/t/db_dependent/Koha/Libraries.t b/t/db_dependent/Koha/Libraries.t >index 86c68fd5c7..a730de4900 100755 >--- a/t/db_dependent/Koha/Libraries.t >+++ b/t/db_dependent/Koha/Libraries.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 12; >+use Test::More tests => 13; > > use C4::Biblio; > use C4::Context; >@@ -365,3 +365,17 @@ subtest 'outgoing_transfers' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'singleLibrarymode aka singleBranchMode' => sub { >+ plan tests => 3; >+ $schema->storage->txn_begin; >+ >+ Koha::Libraries->new->update({ public => 0 }); >+ is( Koha::Libraries->singleLibraryMode, 0, 'No public libraries' ); >+ my $library1 = $builder->build_object({ class => 'Koha::Libraries', value => { public => 1 } }); >+ is( Koha::Libraries->singleLibraryMode, 1, 'One public library' ); >+ my $library2 = $builder->build_object({ class => 'Koha::Libraries', value => { public => 1 } }); >+ is( Koha::Libraries->singleLibraryMode, 0, 'Two public libraries' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.30.2
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 31784
:
141855
|
141856
|
141857
|
141858
|
141870
|
141927
|
141928
|
141929
|
141969
|
141970
|
141971