From 5554a572cb25d52fb66a8ee180e0fe1c14914b36 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 17 Jul 2024 09:57:53 +0100 Subject: [PATCH] Bug 37364: Unit tests --- t/db_dependent/Koha/Biblio.t | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index 0cd7491d152..febb50d7737 100755 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -999,7 +999,7 @@ subtest 'get_volumes_query' => sub { }; subtest 'generate_marc_host_field' => sub { - plan tests => 22; + plan tests => 24; $schema->storage->txn_begin; @@ -1011,7 +1011,7 @@ subtest 'generate_marc_host_field' => sub { MARC::Field->new( '001', '1234' ), MARC::Field->new( '003', 'FIRST' ), MARC::Field->new( '240', '', '', a => 'A uniform title' ), - MARC::Field->new( '260', '', '', a => 'Publication' ), + MARC::Field->new( '260', '', '', a => 'Publication 260' ), MARC::Field->new( '250', '', '', a => 'Edition a', b => 'Edition b' ), MARC::Field->new( '022', '', '', a => '0317-8471' ), ); @@ -1025,7 +1025,7 @@ subtest 'generate_marc_host_field' => sub { is( $link->tag, '773', "MARC::Field->tag returns '773' when marcflavour is 'MARC21" ); is( $link->subfield('a'), 'Some boring author', 'MARC::Field->subfield(a) returns content from 100ab' ); is( $link->subfield('b'), 'Edition a Edition b', 'MARC::Field->subfield(b) returns content from 250ab' ); - is( $link->subfield('d'), 'Publication', 'MARC::Field->subfield(c) returns content from 260abc' ); + is( $link->subfield('d'), 'Publication 260', 'MARC::Field->subfield(c) returns content from 260abc' ); is( $link->subfield('s'), 'A uniform title', 'MARC::Field->subfield(s) returns content from 240a' ); is( $link->subfield('t'), 'Some boring read', 'MARC::Field->subfield(s) returns content from 245ab' ); is( $link->subfield('x'), '0317-8471', 'MARC::Field->subfield(s) returns content from 022a' ); @@ -1039,6 +1039,30 @@ subtest 'generate_marc_host_field' => sub { 'MARC::Field->subfield(w) returns content from 003 and 001 when "UseControlNumber" is enabled' ); + $record->append_fields( + MARC::Field->new( '264', '', '', a => 'Publication 264' ), + ); + C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); + $biblio = Koha::Biblios->find( $biblio->biblionumber ); + + $link = $biblio->generate_marc_host_field(); + is( + $link->subfield('d'), 'Publication 264', + 'MARC::Field->subfield(d) returns content from 264 in prefernce to 260' + ); + + $record->append_fields( + MARC::Field->new( '264', '3', '', a => 'Publication 264', b => 'Preferred' ), + ); + C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); + $biblio = Koha::Biblios->find( $biblio->biblionumber ); + + $link = $biblio->generate_marc_host_field(); + is( + $link->subfield('d'), 'Publication 264 Preferred', + 'MARC::Field->subfield(d) returns content from 264 with indicator 1 = 3 in prefernce to 264 without' + ); + # UNIMARC tests t::lib::Mocks::mock_preference( 'marcflavour', 'UNIMARC' ); -- 2.49.0