@@ -, +, @@ $ prove t/Biblio.t - In current master, run $ prove t/Biblio.t - Apply the patch and run $ prove t/Biblio.t - Sign off :-D --- C4/Biblio.pm | 6 ++++++ t/Biblio.t | 15 +++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) --- a/C4/Biblio.pm +++ a/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); --- a/t/Biblio.t +++ a/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'); --