From df4abfee4a1d43758b0b16570c8d57072df11942 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Wed, 6 Jul 2016 21:37:21 -0400 Subject: [PATCH] Bug 16868: Silence error t/db_dependent/Linker_FirstMatch.t MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the auth_header table has records which exclude 1xx and 2xx tags, the $bibfield doesn't match anything. This in turn sets it to undef, which triggers an error on the next line killing the test. LIMIT was removed as it is not necessary and is a MySQL-ism. Though this may slow down testing with huge auth_header files, it should not be significant. TEST PLAN --------- 1) back up DB 2) Make sure to add in some authority records. 3) DELETE FROM auth_header WHERE marcxml LIKE '%datafield tag="1%'; DELETE FROM auth_header WHERE marcxml LIKE '%datafield tag="2%'; -- Now the test should blow up nicely. -- If you find you have no records, add more such that you repeat steps 2 and 3 and still have records in auth_header. Sorry, getting the trigger data is the hard part. 4) prove t/db_dependent/Linker_FirstMatch.t -- should barf before running all the tests 5) apply patch 6) prove t/db_dependent/Linker_FirstMatch.t -- should have pretty skip message(s) 7) run koha qa test tools 8) restore your backup Signed-off-by: Marc VĂ©ron --- t/db_dependent/Linker_FirstMatch.t | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Linker_FirstMatch.t b/t/db_dependent/Linker_FirstMatch.t index 66c03ba..2360681 100755 --- a/t/db_dependent/Linker_FirstMatch.t +++ b/t/db_dependent/Linker_FirstMatch.t @@ -18,7 +18,15 @@ BEGIN { } my $dbh = C4::Context->dbh; -my $query = "SELECT authid, marc FROM auth_header LIMIT 1;"; +my $where_clause = ' WHERE marcxml LIKE \'%datafield tag="'; +if (C4::Context->preference('MARCFlavour') eq 'UNIMARC') { + $where_clause .= '2%\''; +} else { + $where_clause .= '1%\''; +} + +my $query = "SELECT authid, marc FROM auth_header "; +$query .= $where_clause; my $sth = $dbh->prepare($query); $sth->execute(); my ($authid, $marc) = $sth->fetchrow_array(); -- 1.7.10.4