Bug 18851: Tests must be skipped in cardnumber.t if Test::DBIx::Class is not installed
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 5 Jul 2017 20:38:41 +0000 (17:38 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 8 Aug 2017 12:21:06 +0000 (09:21 -0300)
Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/Members/cardnumber.t

index f2f7882..47902f8 100644 (file)
@@ -1,7 +1,9 @@
 #!/usr/bin/env perl
 
 use Modern::Perl;
-use Test::More tests => 25;
+use Module::Load::Conditional qw/check_install/;
+use Test::More;
+use Test::MockModule;
 
 use t::lib::Mocks;
 
@@ -9,9 +11,18 @@ use Koha::Schema;
 use_ok('C4::Members');
 
 BEGIN {
-    use Test::DBIx::Class;
+    if ( check_install( module => 'Test::DBIx::Class' ) ) {
+        plan tests => 25;
+    } else {
+        plan skip_all => "Need Test::DBIx::Class"
+    }
 }
 
+use Test::DBIx::Class;
+
+my $db = Test::MockModule->new('Koha::Database');
+$db->mock( _new_schema => sub { return Schema(); } );
+
 my $dbh = C4::Context->dbh;
 my $rs = [];