From e295cb61367b24568736bb21bd4abb582937d62f Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 20 Oct 2022 14:27:25 +0000 Subject: [PATCH] Bug 31889: Add unit test to show problem Test plan: Run t/db_dependent/Koha/Biblio/Metadata.t Fails with: not ok 10 - 951-952s-953 in 245,100,942,951,953,999,952,952,952,952,952,952,952,952 Signed-off-by: Marcel de Rooy Signed-off-by: David Nind --- t/db_dependent/Koha/Biblio/Metadata.t | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Biblio/Metadata.t b/t/db_dependent/Koha/Biblio/Metadata.t index 6adc4e75d4..f64bfedb55 100755 --- a/t/db_dependent/Koha/Biblio/Metadata.t +++ b/t/db_dependent/Koha/Biblio/Metadata.t @@ -86,7 +86,7 @@ subtest 'record() tests' => sub { }; subtest '_embed_items' => sub { - plan tests => 8; + plan tests => 10; $schema->storage->txn_begin(); @@ -190,5 +190,20 @@ subtest '_embed_items' => sub { 'For OPAC, If all items are hidden, no item should have been embedded' ); + # Check position of 952 in response of embed_items marc + t::lib::Mocks::mock_preference( 'OpacHiddenItems', q{} ); + $record = $biblio->metadata->record; + $record->insert_fields_ordered( + MARC::Field->new( '951', '', '', a => 'before items' ), + MARC::Field->new( '953', '', '', a => 'after items' ), + ); + C4::Biblio::ModBiblio( $record, $biblio->biblionumber, q{} ); + my $field_list = join ',', map { $_->tag } $record->fields; + ok( $field_list =~ /951,953/, "951 and 953 in $field_list" ); + $biblio->discard_changes; + $record = $biblio->metadata->record({ embed_items => 1 }); + $field_list = join ',', map { $_->tag } $record->fields; + ok( $field_list =~ /951,(952,)+953/, "951-952s-953 in $field_list" ); + $schema->storage->txn_rollback; }; -- 2.30.2