Bug 18712: Fix t/Matcher.t if DB is empty
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 2 Nov 2017 13:13:46 +0000 (10:13 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Sun, 26 Nov 2017 16:00:03 +0000 (13:00 -0300)
t/Matcher.t is failing with an empty DB, the data are not mocked
correctly

Test plan:
drop your DB and recreate it without any data and prove t/Matcher.t

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/Matcher.t

index 55b5a87..3a5494e 100755 (executable)
@@ -33,10 +33,13 @@ BEGIN {
     }
 }
 
-use_ok('C4::Matcher');
-
 use Test::DBIx::Class;
 
+my $db = Test::MockModule->new('Koha::Database');
+$db->mock( _new_schema => sub { return Schema(); } );
+
+use_ok('C4::Matcher');
+
 fixtures_ok [
     MarcMatcher => [
         [ 'matcher_id', 'code', 'description', 'record_type', 'threshold' ],
@@ -45,9 +48,6 @@ fixtures_ok [
     ],
 ], 'add fixtures';
 
-my $db = Test::MockModule->new('Koha::Database');
-$db->mock( _new_schema => sub { return Schema(); } );
-
 my @matchers = C4::Matcher::GetMatcherList();
 
 is( $matchers[0]->{'matcher_id'}, 1, 'First matcher_id value is 1' );