From f3587c37b094f068a49f8a840dd734203b3fa1c4 Mon Sep 17 00:00:00 2001 From: Janusz Kaczmarek Date: Wed, 25 Mar 2026 14:00:39 +0000 Subject: [PATCH] Bug 42159: Unit tests Unit tests Signed-off-by: David Nind Signed-off-by: Paul Derscheid Signed-off-by: Lucas Gass (cherry picked from commit b8a81cf73ce7f2496c63b955bd99a8681c425b68) Signed-off-by: Baptiste Wojtkowski --- t/db_dependent/Koha/Biblio.t | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index 48b8c607c8..59b45af65c 100755 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -1753,7 +1753,7 @@ subtest 'current_checkouts() and old_checkouts() tests' => sub { subtest 'get_marc_contributors() tests' => sub { - plan tests => 2; + plan tests => 4; $schema->storage->txn_begin; @@ -1772,6 +1772,32 @@ subtest 'get_marc_contributors() tests' => sub { is( @{ $biblio->get_marc_authors }, 3, 'get_marc_authors retrieves correct number of author subfields' ); is( @{ $biblio->get_marc_contributors }, 2, 'get_marc_contributors retrieves correct number of author subfields' ); + + # main heading 110 + my $biblio2 = $builder->build_sample_biblio; + my $record2 = $biblio2->metadata->record; + $record2->delete_fields( $record2->field('1..') ); + + # add author information + $field = MARC::Field->new( '110', '1', '', 'a' => 'City of Marseille' ); + $record2->append_fields($field); + $field = MARC::Field->new( '700', '1', '', 'a' => 'Jefferson, Thomas' ); + $record2->append_fields($field); + $field = MARC::Field->new( '701', '1', '', 'd' => 'Secondary author 2' ); + $record2->append_fields($field); + + # get record2 + C4::Biblio::ModBiblio( $record2, $biblio2->biblionumber ); + $biblio2 = Koha::Biblios->find( $biblio2->biblionumber ); + + is( + @{ $biblio2->get_marc_authors }, 3, + 'get_marc_authors retrieves correct number of author fields for 110 being the main heading' + ); + is( + @{ $biblio2->get_marc_contributors }, 2, + 'get_marc_contributors retrieves correct number of author fields for 110 being the main heading' + ); $schema->storage->txn_rollback; };