From 59c450fb3803e8dc1862436c91f47b1ef11be1f6 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 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 --- 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(); -- 2.1.4