From fdbd536810cdb6510b787ffc94443ea5d4107b12 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 14 Dec 2021 09:30:44 +0000 Subject: [PATCH] Bug 29690: Unit test for get_components_query --- t/db_dependent/Koha/Biblio.t | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index 73dcb2ab13..8331de6563 100755 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -565,7 +565,7 @@ subtest 'get_marc_components() tests' => sub { }; subtest 'get_components_query' => sub { - plan tests => 3; + plan tests => 4; my $biblio = $builder->build_sample_biblio(); my $biblionumber = $biblio->biblionumber; @@ -588,6 +588,11 @@ subtest 'get_components_query' => sub { $biblio = Koha::Biblios->find( $biblio->biblionumber); is($biblio->get_components_query, "(((rcn:$biblionumber AND cni:OSt) OR rcn:\"OSt $biblionumber\") AND (bib-level:a OR bib-level:b))", "UseControlNumber enabled with MarcOrgCode"); + + $biblio->metadata->metadata('This is invalid for a MARC record')->store(); + $biblio = Koha::Biblios->find( $biblio->biblionumber); + + is($biblio->get_components_query, undef, "Invalid MARC record returns undefined and does not die"); }; subtest 'orders() and active_orders() tests' => sub { -- 2.20.1