Bugzilla – Attachment 33649 Details for
Bug 13274
t/00-load.t shouldn't depend on the DB
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED OFF] Bug 13274: Mock new_dbh in t::lib::Mocks
SIGNED-OFF-Bug-13274-Mock-newdbh-in-tlibMocks.patch (text/plain), 1.88 KB, created by
Mark Tompsett
on 2014-11-18 13:21:33 UTC
(
hide
)
Description:
[SIGNED OFF] Bug 13274: Mock new_dbh in t::lib::Mocks
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2014-11-18 13:21:33 UTC
Size:
1.88 KB
patch
obsolete
>From a0f993934ee6df71f20e66af51e929e48ea56195 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Tue, 18 Nov 2014 10:45:02 +0100 >Subject: [PATCH] [SIGNED OFF] Bug 13274: Mock new_dbh in t::lib::Mocks > >This patch suggests to create a routine to mock C4::Context::_new_dbh. > >NOTE: Works the same with and without this secondary patch. > koha-qa tests fine. Less cutting and pasting in the future. > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> >--- > t/00-load.t | 12 +++--------- > t/lib/Mocks.pm | 12 ++++++++++++ > 2 files changed, 15 insertions(+), 9 deletions(-) > >diff --git a/t/00-load.t b/t/00-load.t >index 88830b3..428ef39 100644 >--- a/t/00-load.t >+++ b/t/00-load.t >@@ -20,8 +20,8 @@ use Modern::Perl; > use Test::More; > use File::Spec; > use File::Find; >-use Test::MockModule; >-use DBD::Mock; >+ >+use t::lib::Mocks; > > =head1 DESCRIPTION > >@@ -29,13 +29,7 @@ use DBD::Mock; > > =cut > >-# 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; >-}); >+my $context_module = t::lib::Mocks::mock_dbh; > > # Loop through the C4:: modules > my $lib = File::Spec->rel2abs('C4'); >diff --git a/t/lib/Mocks.pm b/t/lib/Mocks.pm >index 3f834d2..55ce9d5 100644 >--- a/t/lib/Mocks.pm >+++ b/t/lib/Mocks.pm >@@ -2,6 +2,8 @@ package t::lib::Mocks; > > use Modern::Perl; > use C4::Context; >+ >+use DBD::Mock; > use Test::MockModule; > > my %configs; >@@ -36,4 +38,14 @@ sub mock_preference { > }); > } > >+sub mock_dbh { >+ 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; >+ } ); >+ return $context; >+} >+ > 1; >-- >1.7.9.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13274
:
33632
|
33636
|
33638
|
33645
| 33649