From dc53a37ef1d6e07d06b39da2cdfe7e999767d14a 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 Signed-off-by: David Nind Signed-off-by: Tomas Cohen Arazi --- 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 a2c0e52320..8aa5bbe5d9 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.32.0