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 <m.de.rooy@rijksmuseum.nl>

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Marcel de Rooy 2022-10-20 14:27:25 +00:00 committed by Tomas Cohen Arazi
parent 3fb5e43296
commit 2766dd82e7
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -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;
};