Bugzilla – Attachment 151170 Details for
Bug 33718
_new_Zconn crashes on a bug in t::lib::Mocks::mock_config
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33718: Fix the mock of Koha::Config->get in mock_config
Bug-33718-Fix-the-mock-of-KohaConfig-get-in-mockco.patch (text/plain), 2.44 KB, created by
Katrin Fischer
on 2023-05-14 11:06:12 UTC
(
hide
)
Description:
Bug 33718: Fix the mock of Koha::Config->get in mock_config
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2023-05-14 11:06:12 UTC
Size:
2.44 KB
patch
obsolete
>From ac4bc1c50890b2c9014ad1e414eb7e16ba0bb306 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 11 May 2023 12:52:23 +0000 >Subject: [PATCH] Bug 33718: Fix the mock of Koha::Config->get in mock_config > >It should not mock calls for other sections than 'config' in >koha-conf.xml. > >Test plan: >Without this patch: >[1] Enable AutoLinkBiblios, CatalogModuleRelink and LinkerRelink. >This will trigger a SearchAuthorities call when creating a sample biblio. >Note: SearchAuthorities calls Zconn and gets back information from >a wrong part of koha-conf.xml. >[2] Run t/db_dependent/Koha/Pseudonymization.t >You should see something like: > {UNKNOWN}: Can't use string ("authorities") as a HASH ref while "strict refs" in use at /usr/share/koha/C4/Context.pm line 587. at /usr/share/koha/C4/Biblio.pm line 302 > >With this patch: >[3] Run t/db_dependent/Koha/Pseudonymization.t. Should pass now. >[4] git grep -l mock_config | xargs -i{} prove {} > Exclude Mocks.pm. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > t/lib/Mocks.pm | 20 ++++++++++++-------- > 1 file changed, 12 insertions(+), 8 deletions(-) > >diff --git a/t/lib/Mocks.pm b/t/lib/Mocks.pm >index 68d8829ca6..bca34f4e0b 100644 >--- a/t/lib/Mocks.pm >+++ b/t/lib/Mocks.pm >@@ -39,20 +39,24 @@ my %configs; > > Mock the configuration I<$config_entry> with the specified I<$value>. > >+NOTE: We are only mocking config entries here, so no entries from other >+sections of koha-conf.xml. Bug 33718 fixed the section parameter of >+mocked Koha::Config->get calls for other sections (not cached). >+ > =cut > > sub mock_config { >+ my ( $config_entry, $value ) = @_; > my $koha_config = Test::MockModule->new('Koha::Config'); >- my ( $conf, $value ) = @_; >- $configs{$conf} = $value; >+ $configs{$config_entry} = $value; > $koha_config->mock('get', sub { >- my ( $self, $conf ) = @_; >- if ( exists $configs{$conf} ) { >- return $configs{$conf} >- } else { >- my $method = $koha_config->original('get'); >- return $method->($self, $conf); >+ my ( $self, $key, $section ) = @_; >+ $section ||= 'config'; >+ if( $section eq 'config' && exists $configs{$key} ) { >+ return $configs{$key}; > } >+ my $method = $koha_config->original('get'); >+ return $method->( $self, $key, $section ); > }); > } > >-- >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 33718
:
151074
|
151075
|
151101
|
151110
| 151170