Bugzilla – Attachment 39928 Details for
Bug 14346
t/Biblio.t fails because of new warning
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14346: t/Biblio.t fails because of new warning
Bug-14346-tBibliot-fails-because-of-new-warning.patch (text/plain), 3.02 KB, created by
Mark Tompsett
on 2015-06-05 22:17:03 UTC
(
hide
)
Description:
Bug 14346: t/Biblio.t fails because of new warning
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2015-06-05 22:17:03 UTC
Size:
3.02 KB
patch
obsolete
>From 01b1295f1652c9266bc1b864d45b9277390226de Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@gmail.com> >Date: Fri, 5 Jun 2015 14:52:36 -0300 >Subject: [PATCH] Bug 14346: t/Biblio.t fails because of new warning > >Running > > $ prove t/Biblio.t > >fails because of us now using DBIx to retrieve sysprefs. Then our mocked DBI is not "supported" by DBIx hence a warning that makes our test fail (there is one more warning now). > >The cool thing about this, is that it actually helped spot a situation where GetMarcBiblio is doing wrong things because is not checking its parameters are undefined, so we have the chance to fix it. > >This patch makes GetMarcBiblio return undef if no biblionumber is passed, and >also raises a conveniently carped warning. This change is tested in t/Biblio.t with new tests. > >To test: >- In current master, run > $ prove t/Biblio.t >=> FAIL: a test detects a wrong warning count and fails. >- Apply the patch and run > $ prove t/Biblio.t >=> SUCCESS: Tests now pass, and there are 2 new ones. >- Sign off :-D > >Regards > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> >--- > C4/Biblio.pm | 6 ++++++ > t/Biblio.t | 15 +++++++++++---- > 2 files changed, 17 insertions(+), 4 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index fb4d4e8..1020990 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -1261,6 +1261,12 @@ The MARC record contains biblio data, and items data if $embeditems is set to tr > sub GetMarcBiblio { > my $biblionumber = shift; > my $embeditems = shift || 0; >+ >+ if (not defined $biblionumber) { >+ carp 'GetMarcBiblio called with undefined biblionumber'; >+ return; >+ } >+ > my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare("SELECT marcxml FROM biblioitems WHERE biblionumber=? "); > $sth->execute($biblionumber); >diff --git a/t/Biblio.t b/t/Biblio.t >index cec30a9..3217e77 100755 >--- a/t/Biblio.t >+++ b/t/Biblio.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 44; >+use Test::More tests => 46; > use Test::MockModule; > use Test::Warn; > use DBD::Mock; >@@ -167,9 +167,16 @@ warning_is { $ret = RemoveAllNsb() } > > ok( !defined $ret, 'RemoveAllNsb returns undef if not passed rec'); > >-warning_is { $ret = UpdateTotalIssues() } >- { carped => 'UpdateTotalIssues could not get biblio record'}, >- "UpdateTotalIssues returns carped warning if biblio record does not exist"; >+warning_is { $ret = GetMarcBiblio() } >+ { carped => 'GetMarcBiblio called with undefined biblionumber'}, >+ "GetMarcBiblio returns carped warning on undef biblionumber"; >+ >+ok( !defined $ret, 'GetMarcBiblio returns undef if not passed a biblionumber'); >+ >+warnings_like { $ret = UpdateTotalIssues() } >+ [ { carped => qr/GetMarcBiblio called with undefined biblionumber/ }, >+ { carped => qr/UpdateTotalIssues could not get biblio record/ } ], >+ "UpdateTotalIssues returns carped warnings if biblio record does not exist"; > > ok( !defined $ret, 'UpdateTotalIssues returns carped warning if biblio record does not exist'); > >-- >2.1.4
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 14346
:
39921
|
39922
|
39928
|
39929
|
39944
|
39945