Bugzilla – Attachment 12617 Details for
Bug 8846
t/SuggestionEngine_ExplodedTerms.t sneakily uses database
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8846: Exploded Terms test sneakily uses database
Bug-8846-Exploded-Terms-test-sneakily-uses-databas.patch (text/plain), 2.88 KB, created by
Jared Camins-Esakov
on 2012-10-01 09:26:55 UTC
(
hide
)
Description:
Bug 8846: Exploded Terms test sneakily uses database
Filename:
MIME Type:
Creator:
Jared Camins-Esakov
Created:
2012-10-01 09:26:55 UTC
Size:
2.88 KB
patch
obsolete
>From 7fe6ab6253c3a2ba2dbc536aae5ef4176e72ec66 Mon Sep 17 00:00:00 2001 >From: Jared Camins-Esakov <jcamins@cpbibliography.com> >Date: Sat, 29 Sep 2012 09:28:43 -0400 >Subject: [PATCH] Bug 8846: Exploded Terms test sneakily uses database > >Even though there is no need for anything stored in the database for the >test, C4::Templates requires the database and a koha-conf.xml. The >solution is to mock all database- and koha-conf-using routines. > >To test: >1) Stop MySQL >2) Unset KOHA_CONF >3) Run test >--- > t/SuggestionEngine_ExplodedTerms.t | 59 ++++++++++++++++++++++++++++++++++++ > 1 files changed, 59 insertions(+), 0 deletions(-) > >diff --git a/t/SuggestionEngine_ExplodedTerms.t b/t/SuggestionEngine_ExplodedTerms.t >index 52683b2..8726e74 100755 >--- a/t/SuggestionEngine_ExplodedTerms.t >+++ b/t/SuggestionEngine_ExplodedTerms.t >@@ -3,12 +3,71 @@ > use strict; > use warnings; > >+use File::Basename; >+use File::Spec; > use Test::More; >+use Test::MockModule; > > BEGIN { > use_ok('Koha::SuggestionEngine'); > } > >+my $langModule = new Test::MockModule('C4::Languages'); >+$langModule->mock('regex_lang_subtags', sub { >+ return { >+ 'extension' => undef, >+ 'script' => undef, >+ 'privateuse' => undef, >+ 'variant' => undef, >+ 'language' => 'en', >+ 'region' => undef, >+ 'rfc4646_subtag' => 'en' >+ }; >+}); >+$langModule->mock('getTranslatedLanguages', sub { >+ return [ >+ { >+ 'sublanguages_loop' => [ >+ { >+ 'script' => undef, >+ 'extension' => undef, >+ 'language' => 'en', >+ 'region' => undef, >+ 'region_description' => undef, >+ 'sublanguage_current' => 1, >+ 'privateuse' => undef, >+ 'variant' => undef, >+ 'variant_description' => undef, >+ 'script_description' => undef, >+ 'rfc4646_subtag' => 'en', >+ 'native_description' => 'English', >+ 'enabled' => 1 >+ }, >+ ], >+ 'plural' => 1, >+ 'language' => 'en', >+ 'current' => 1, >+ 'native_description' => 'English', >+ 'rfc4646_subtag' => 'en', >+ 'group_enabled' => 1 >+ } >+ ]; >+}); >+my $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'); >+ return ($opactmpl, 'prog', 'en', "$opactmpl/prog/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.2.5
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 8846
:
12607
|
12617
|
12710
|
13157
|
13158
|
13160