From 0bb34b9d0aa18e4da5185b4f4f713084196864ba Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Tue, 17 Sep 2013 11:43:53 +1200 Subject: [PATCH] Bug 10897 Removing DB dependence of t/ILSDI_Services.t To test 1/ Run the test with a config that doesnt allow db access you should get a message like t/ILSDI_Services.t .................. DBI connect('dbname=koha;host=localhost;port=3306','kohaadmin',...) failed: Access denied for user 'kohaadmin'@'localhost' (using password: YES) at /home/travis/build/ranginui/koha/blib/PERL_MODULE_DIR/C4/Context.pm line 810. 2/ Apply patch and run again 3/ Test should now run cleanly (cherry picked from commit c525dd384eba818076929cd20f10003c3b804111) Signed-off-by: Chris Cormack --- t/ILSDI_Services.t | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/t/ILSDI_Services.t b/t/ILSDI_Services.t index 99476d3..1d330b9 100755 --- a/t/ILSDI_Services.t +++ b/t/ILSDI_Services.t @@ -1,14 +1,25 @@ #!/usr/bin/perl # -# This Koha test module is a stub! +# This Koha test module is a stub! # Add more tests here!!! use strict; use warnings; use Test::More tests => 1; +use Test::MockModule; +use DBD::Mock; + +my $module_context = new Test::MockModule('C4::Context'); +$module_context->mock( + '_new_dbh', + sub { + my $dbh = DBI->connect( 'DBI:Mock:', '', '' ) + || die "Cannot create handle: $DBI::errstr\n"; + return $dbh; + } +); + +use_ok('C4::ILSDI::Services'); -BEGIN { - use_ok('C4::ILSDI::Services'); -} -- 1.8.1.2