Bug 22219: Add tests
[koha.git] / t / Search.t
index 69ed79f..0959c85 100755 (executable)
 
 use Modern::Perl;
 
-use Test::More tests => 3;
-use Test::MockModule;
-use DBD::Mock;
+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
-my $context = new Test::MockModule('C4::Context');
-$context->mock( '_new_dbh', sub {
-        my $dbh = DBI->connect( 'DBI:Mock:', '', '' )
-          || die "Cannot create handle: $DBI::errstr\n";
-        return $dbh;
-});
+use Test::DBIx::Class;
 
 use_ok('C4::Search');
 can_ok('C4::Search',
@@ -166,4 +170,3 @@ subtest "_build_initial_query tests" => sub {
 };
 
 
-1;