From 46c292e8fdc52b1fa9ab2c9985346a0e674ffb5b Mon Sep 17 00:00:00 2001
From: remi <remi.mayrand-provencher@inLibro.com>
Date: Wed, 29 Jul 2015 16:04:50 -0400
Subject: [PATCH] Bug 11299 - Adds test in t/Biblio.t to test the new sub in
 Biblio.pm

Also fixes some forbidden patterns.
---
 C4/Biblio.pm |    3 +++
 t/Biblio.t   |    3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/C4/Biblio.pm b/C4/Biblio.pm
index 2930f4c..9d9b01f 100644
--- a/C4/Biblio.pm
+++ b/C4/Biblio.pm
@@ -650,6 +650,9 @@ sub AddAuthorityFromHeading {
     my $field = shift;
     my $bib = shift;
 
+    if(!defined $heading || !defined $field || !defined $bib){
+       return 0;
+    }
     my $authtypedata =
       C4::AuthoritiesMarc::GetAuthType( $heading->auth_type() );
     my $marcrecordauth = MARC::Record->new();
diff --git a/t/Biblio.t b/t/Biblio.t
index 3217e77..76dc5be 100755
--- a/t/Biblio.t
+++ b/t/Biblio.t
@@ -17,7 +17,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 46;
+use Test::More tests => 47;
 use Test::MockModule;
 use Test::Warn;
 use DBD::Mock;
@@ -180,4 +180,5 @@ warnings_like { $ret = UpdateTotalIssues() }
 
 ok( !defined $ret, 'UpdateTotalIssues returns carped warning if biblio record does not exist');
 
+is(C4::Biblio::AddAuthorityFromHeading(), 0, 'AddAuthorityFromHeading returns zero if not passed heading, field or bib');
 1;
-- 
1.7.9.5