From 6c291c7918984ad1aa59bfa7274b79afa70174dd Mon Sep 17 00:00:00 2001 From: Janusz Kaczmarek Date: Thu, 3 Apr 2025 14:22:54 +0000 Subject: [PATCH] Bug 39545: Unit tests Signed-off-by: Roman Dolny --- t/db_dependent/Biblio.t | 69 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t index 79109d708a..4207c40305 100755 --- a/t/db_dependent/Biblio.t +++ b/t/db_dependent/Biblio.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 25; +use Test::More tests => 26; use Test::MockModule; use Test::Warn; use List::MoreUtils qw( uniq ); @@ -37,7 +37,7 @@ use C4::Linker::Default qw( get_link ); BEGIN { use_ok( 'C4::Biblio', - qw( AddBiblio GetMarcFromKohaField BiblioAutoLink GetMarcSubfieldStructure GetMarcSubfieldStructureFromKohaField LinkBibHeadingsToAuthorities GetBiblioData ModBiblio GetMarcISSN GetMarcISBN GetMarcPrice GetFrameworkCode GetMarcUrls IsMarcStructureInternal GetMarcStructure GetXmlBiblio DelBiblio ) + qw( AddBiblio GetMarcFromKohaField BiblioAutoLink GetMarcSubfieldStructure GetMarcSubfieldStructureFromKohaField LinkBibHeadingsToAuthorities GetBiblioData ModBiblio GetMarcISSN GetMarcISBN GetMarcPrice GetFrameworkCode GetMarcUrls IsMarcStructureInternal GetMarcStructure GetXmlBiblio DelBiblio prepare_host_field ) ); } @@ -1378,6 +1378,71 @@ subtest 'AddBiblio/ModBiblio calling ModBiblioMarc for field 005' => sub { ok( $field && $field->data, 'Record contains field 005 after ModBiblio' ); }; +subtest 'Construction of field 773' => sub { + plan tests => 1; + + my $marc_record = MARC::Record->new; + $marc_record->leader(' cam a22 i 4500'); + $marc_record->insert_fields_ordered( MARC::Field->new( '001', 'e50010474705' ) ); + $marc_record->insert_fields_ordered( MARC::Field->new( '003', 'UkLCURL' ) ); + $marc_record->insert_fields_ordered( MARC::Field->new( '020', ' ', ' ', a => '0130810819' ) ); + $marc_record->insert_fields_ordered( MARC::Field->new( '020', ' ', ' ', a => '020163354x' ) ); + $marc_record->insert_fields_ordered( MARC::Field->new( '100', '1', ' ', a => 'Stevens, W. Richard' ) ); + $marc_record->insert_fields_ordered( + MARC::Field->new( + '245', '1', '0', + a => 'UNIX network programming.', + n => 'Vol. 2,', + p => 'Interprocess communications /', + c => 'by W. Richard Stevens.' + ) + ); + $marc_record->insert_fields_ordered( MARC::Field->new( '250', ' ', ' ', a => '2nd edition' ) ); + $marc_record->insert_fields_ordered( + MARC::Field->new( + '260', ' ', ' ', + a => 'Upper Saddle River, N.J. :', + b => 'Prentice Hall PTR,', + c => 'c1999.' + ) + ); + $marc_record->insert_fields_ordered( + MARC::Field->new( + '490', '1', ' ', + a => 'Addison-Wesley professional computing series' + ) + ); + $marc_record->insert_fields_ordered( + MARC::Field->new( + '830', ' ', '0', + a => 'Addison-Wesley professional computing series', + x => '1234-5678' + ) + ); + $marc_record->insert_fields_ordered( MARC::Field->new( '942', '0', ' ', c => 'BK' ) ); + + my $expected_field_773 = MARC::Field->new( + '773', '0', ' ', + 7 => 'p1am', + a => 'Stevens, W. Richard', + t => 'UNIX network programming. Vol. 2, Interprocess communications', + b => '2nd edition', + d => 'Upper Saddle River, N.J. : Prentice Hall PTR, c1999', + k => 'Addison-Wesley professional computing series, ISSN 1234-5678', + z => '020163354x', + z => '0130810819', + w => '(UkLCURL)e50010474705' + ); + my ( $biblionumber, undef ) = + AddBiblio( $marc_record, '', { skip_record_index => 1 } ); + my $host_field = prepare_host_field( $biblionumber, 'MARC21' ); + is( + $host_field->as_formatted, + $expected_field_773->as_formatted, + 'Host field 773 formed corrrectly' + ); +}; + # Cleanup Koha::Caches->get_instance->clear_from_cache("MarcSubfieldStructure-"); $schema->storage->txn_rollback; -- 2.39.5