[PATCH 3/6] bug 8649: make sure C4::Context is fully mocked-up before tests
Galen Charlton
gmc at esilibrary.com
Thu Aug 16 19:04:00 CEST 2012
This fixes failures of the test cases to run for me
on Perl 5.10.1 using prove -v t/db_dependent/Search.t
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
Signed-off-by: wajasu <matted-34813 at mypacks.net>
---
t/db_dependent/Search.t | 43 +++++++++++++++++++++----------------------
1 file changed, 21 insertions(+), 22 deletions(-)
diff --git a/t/db_dependent/Search.t b/t/db_dependent/Search.t
index e6f9dfa..242f259 100644
--- a/t/db_dependent/Search.t
+++ b/t/db_dependent/Search.t
@@ -10,7 +10,7 @@ use utf8;
use YAML;
=20
use C4::Debug;
-use C4::Context;
+require C4::Context;
=20
use Test::More tests =3D> 57;
use Test::MockModule;
@@ -21,26 +21,8 @@ use File::Find;
use Test::Warn;
=20
system(dirname(__FILE__) . "/zebra_config.pl");
-
my $datadir =3D dirname(__FILE__) . "/data";
=20
-use_ok('C4::Search');
-
-foreach my $string ("Le=C3=A7on","mod=C3=A8les") {
- my @results=3DC4::Search::_remove_stopwords($string,"kw");
- $debug && warn "$string ",Dump(@results);
- ok($results[0] eq $string,"$string is not modified");
-}
-
-foreach my $string ("A book about the stars") {
- my @results=3DC4::Search::_remove_stopwords($string,"kw");
- $debug && warn "$string ",Dump(@results);
- ok($results[0] ne $string,"$results[0] from $string");
-}
-
-my $indexes =3D C4::Search::getIndexes();
-is(scalar(grep(/^ti$/, @$indexes)), 1, "Title index supported");
-
my $QueryStemming =3D 0;
my $QueryAutoTruncate =3D 0;
my $QueryWeightFields =3D 0;
@@ -123,6 +105,26 @@ $contextmodule->mock('marcfromkohafield', sub {
);
return \%hash;
});
+my $context =3D new C4::Context("$datadir/etc/koha-conf.xml");
+$context->set_context();
+
+use_ok('C4::Search');
+
+foreach my $string ("Le=C3=A7on","mod=C3=A8les") {
+ my @results=3DC4::Search::_remove_stopwords($string,"kw");
+ $debug && warn "$string ",Dump(@results);
+ ok($results[0] eq $string,"$string is not modified");
+}
+
+foreach my $string ("A book about the stars") {
+ my @results=3DC4::Search::_remove_stopwords($string,"kw");
+ $debug && warn "$string ",Dump(@results);
+ ok($results[0] ne $string,"$results[0] from $string");
+}
+
+my $indexes =3D C4::Search::getIndexes();
+is(scalar(grep(/^ti$/, @$indexes)), 1, "Title index supported");
+
my $bibliomodule =3D new Test::MockModule('C4::Biblio');
$bibliomodule->mock('_get_inverted_marc_field_map', sub {
my %hash =3D (
@@ -225,9 +227,6 @@ $record->add_fields(
($biblionumber,undef,$title) =3D FindDuplicate($record);
is($biblionumber, 203, 'Found duplicate with author/title');
=20
-my $context =3D new C4::Context("$datadir/etc/koha-conf.xml");
-$context->set_context();
-
# Testing SimpleSearch
=20
my ( $error, $marcresults, $total_hits ) =3D SimpleSearch("book", 0, 9);
--=20
1.7.11.4
------=_Part_5104_6714174.1345149989434
Content-Disposition: attachment; filename="0004-bug-8649-make-sure-we-can-exit-if-a-test-fails.patch"
Content-Type: text/x-patch;
name=0004-bug-8649-make-sure-we-can-exit-if-a-test-fails.patch;
charset=us-ascii
Content-Transfer-Encoding: 7bit
More information about the Koha-patches
mailing list