Bug 18851: Fix few other tests
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 10 Jul 2017 19:11:44 +0000 (16:11 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 8 Aug 2017 12:21:06 +0000 (09:21 -0300)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/Patron.t
t/Search.t
t/SuggestionEngine_AuthorityFile.t
t/XSLT.t

index be66f9d..3b87939 100755 (executable)
 
 use Modern::Perl;
 
-use Test::More tests => 11;
+use Test::More;
 use Test::Warn;
 use t::lib::Mocks;
 
+use Module::Load::Conditional qw/check_install/;
+
 BEGIN {
-    use Test::DBIx::Class;
+    if ( check_install( module => 'Test::DBIx::Class' ) ) {
+        plan tests => 11;
+    } else {
+        plan skip_all => "Need Test::DBIx::Class"
+    }
     use_ok('Koha::Object');
     use_ok('Koha::Patron');
 }
 
+use Test::DBIx::Class;
+my $db = Test::MockModule->new('Koha::Database');
+$db->mock( _new_schema => sub { return Schema(); } );
+
 my $object = Koha::Patron->new( { surname => 'Test Patron' } );
 is( $object->surname(), 'Test Patron', "Accessor returns correct value" );
 $object->surname('Test Patron Surname');
index 5c35419..104e094 100755 (executable)
 
 use Modern::Perl;
 
-use Test::More tests => 3;
+use Test::More;
 use t::lib::Mocks;
 
+use Module::Load::Conditional qw/check_install/;
+
+BEGIN {
+    if ( check_install( module => 'Test::DBIx::Class' ) ) {
+        plan tests => 3;
+    } else {
+        plan skip_all => "Need Test::DBIx::Class"
+    }
+}
+
 # Mock the DB connexion and C4::Context
 use Test::DBIx::Class;
 
index 96ca44d..b648f31 100755 (executable)
@@ -28,8 +28,20 @@ use Test::More;
 use Test::MockModule;
 use t::lib::Mocks;
 
-# Mock the DB connexion and C4::Context
+use Module::Load::Conditional qw/check_install/;
+
+BEGIN {
+    if ( check_install( module => 'Test::DBIx::Class' ) ) {
+        plan tests => 3;
+    } else {
+        plan skip_all => "Need Test::DBIx::Class"
+    }
+}
+
+# Mock the DB connexion
 use Test::DBIx::Class;
+my $db = Test::MockModule->new('Koha::Database');
+$db->mock( _new_schema => sub { return Schema(); } );
 
 use_ok('Koha::SuggestionEngine');
 
index aefa4df..b902aa6 100755 (executable)
--- a/t/XSLT.t
+++ b/t/XSLT.t
@@ -36,6 +36,8 @@ BEGIN {
 };
 
 use Test::DBIx::Class;
+my $db = Test::MockModule->new('Koha::Database');
+$db->mock( _new_schema => sub { return Schema(); } );
 
 my $dir = File::Temp->newdir();
 my @themes = ('prog', 'test');