Bugzilla – Attachment 53168 Details for
Bug 16869
Silence and catch warnings in t/db_dependent/SuggestionEngine_ExplodedTerms.t
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF]Bug 16869: Silence and catch warnings in t/db_dependent/SuggestionEngine_ExplodedTerms.t
SIGNED-OFFBug-16869-Silence-and-catch-warnings-in-.patch (text/plain), 3.86 KB, created by
Héctor Eduardo Castro Avalos
on 2016-07-07 13:57:50 UTC
(
hide
)
Description:
[SIGNED-OFF]Bug 16869: Silence and catch warnings in t/db_dependent/SuggestionEngine_ExplodedTerms.t
Filename:
MIME Type:
Creator:
Héctor Eduardo Castro Avalos
Created:
2016-07-07 13:57:50 UTC
Size:
3.86 KB
patch
obsolete
>From 697989f6f9e74131b03eec7c9684848d6f68c538 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Thu, 7 Jul 2016 02:34:28 -0400 >Subject: [PATCH] [SIGNED-OFF]Bug 16869: Silence and catch warnings in > t/db_dependent/SuggestionEngine_ExplodedTerms.t > >By properly defining a opachtdocs (intranethtdocs was done too) >in the mock function, uninitialized variable warnings are >eliminated. Given that we can check if $KOHA_CONF is defined or >not, we can catch the warning as part of testing, so the output >of the test is cleaner. > >TEST PLAN >--------- >1) unset KOHA_CONF >2) prove t/db_dependent/SuggestionEngine_ExplodedTerms.t > -- lots of noise >3) apply patch >4) prove t/db_dependent/SuggestionEngine_ExplodedTerms.t > -- no noise >5) prove -v t/db_dependent/SuggestionEngine_ExplodedTerms.t > -- see the warnings were caught and not just ignored. >6) run koha qa test tools > >Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com> >No warnings. Works as advertised >--- > t/db_dependent/SuggestionEngine_ExplodedTerms.t | 59 ++++++++++++++++++----- > 1 file changed, 46 insertions(+), 13 deletions(-) > mode change 100755 => 100644 t/db_dependent/SuggestionEngine_ExplodedTerms.t > >diff --git a/t/db_dependent/SuggestionEngine_ExplodedTerms.t b/t/db_dependent/SuggestionEngine_ExplodedTerms.t >old mode 100755 >new mode 100644 >index 15b491e..68fae90 >--- a/t/db_dependent/SuggestionEngine_ExplodedTerms.t >+++ b/t/db_dependent/SuggestionEngine_ExplodedTerms.t >@@ -7,12 +7,45 @@ use File::Basename; > use File::Spec; > use Test::More; > use Test::MockModule; >+use Test::Warn; > >-BEGIN { >- use_ok('Koha::SuggestionEngine'); >+my $contextModule = new Test::MockModule('C4::Context'); >+$contextModule->mock('preference', sub { >+ return ''; >+}); >+$contextModule->mock('config', sub { >+ my ($self,$key) = @_; >+ if ($key eq 'opachtdocs') { >+ return get_where() . '/koha-tmpl/opac-tmpl'; >+ } elsif ($key eq 'intrahtdocs') { >+ return get_where() . '/koha-tmpl/intranet-tmpl'; >+ } else { >+ return ''; >+ } >+}); >+ >+use_ok('Koha::SuggestionEngine'); >+ >+sub get_where { >+ my $location = File::Spec->rel2abs(dirname(__FILE__)); >+ if ($location =~ /db_dependent/) { >+ $location .= '/../..'; >+ } >+ else { >+ $location .= '/..'; >+ } >+ return $location; > } > >-my $langModule = new Test::MockModule('C4::Languages'); >+my $langModule; >+if (! defined $ENV{KOHA_CONF}) { >+ warning_like { $langModule = new Test::MockModule('C4::Languages'); } >+ qr /unable to locate Koha configuration file koha-conf.xml/, >+ 'Expected warning for unset $KOHA_CONF'; >+} >+else { >+ $langModule = new Test::MockModule('C4::Languages'); >+} > $langModule->mock('regex_lang_subtags', sub { > return { > 'extension' => undef, >@@ -53,20 +86,20 @@ $langModule->mock('getTranslatedLanguages', sub { > } > ]; > }); >-my $tmplModule = new Test::MockModule('C4::Templates'); >+my $tmplModule; >+if (! defined $ENV{KOHA_CONF}) { >+ warning_like { $tmplModule = new Test::MockModule('C4::Templates'); } >+ qr /unable to locate Koha configuration file koha-conf.xml/, >+ 'Expected warning for unset $KOHA_CONF'; >+} >+else { >+ $tmplModule = new Test::MockModule('C4::Templates'); >+} > $tmplModule->mock('_get_template_file', sub { > my ($tmplbase, $interface, $query) = @_; >- my $opactmpl = File::Spec->rel2abs(dirname(__FILE__) . '/../../koha-tmpl/opac-tmpl'); >+ my $opactmpl = get_where() . '/koha-tmpl/opac-tmpl'; > return ($opactmpl, 'bootstrap', 'en', "$opactmpl/bootstrap/en/modules/$tmplbase"); > }); >-my $contextModule = new Test::MockModule('C4::Context'); >-$contextModule->mock('preference', sub { >- return ''; >-}); >-$contextModule->mock('config', sub { >- return ''; >-}); >- > > my $suggestor = Koha::SuggestionEngine->new( { plugins => [ 'ExplodedTerms' ] } ); > is(ref($suggestor), 'Koha::SuggestionEngine', 'Created suggestion engine'); >-- >1.7.10.4
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 16869
:
53160
|
53168
|
53169