From d9615e4821eb6fea3565c6260463866947fb7d4a Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Tue, 30 Apr 2024 18:59:24 +0000 Subject: [PATCH] Bug 36515: Add unit tests Test plan: 1. Run unit tests ktd --shell prove t/SimpleMARC.t Sponsored-by: Education Services Australia SCIS Signed-off-by: David Nind --- t/SimpleMARC.t | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/t/SimpleMARC.t b/t/SimpleMARC.t index 3e8e840ff8..da6b98ff7f 100755 --- a/t/SimpleMARC.t +++ b/t/SimpleMARC.t @@ -924,7 +924,7 @@ subtest 'copy_field' => sub { # copy_and_replace_field - subfield subtest 'copy_and_replace_field' => sub { - plan tests => 2; + plan tests => 3; subtest 'copy and replace subfield' => sub { plan tests => 20; my $record = new_record; @@ -1516,6 +1516,28 @@ subtest 'copy_and_replace_field' => sub { 'Copy and replace to an existent field should not create a new field' ); }; + + # Copy and replace with control field + subtest 'copy and replace control field' => sub { + plan tests => 1; + my $record = new_record; + $record->append_fields( + MARC::Field->new( '001', '4815162342' ), + ); + + # Copy control field to subfield + copy_and_replace_field( + { record => $record, from_field => '001', to_field => '099', to_subfield => 'a' } ); + is_deeply( + [ + read_field( + { record => $record, field => '099', subfield => 'a' } + ) + ], + ['4815162342'], + 'Copy and replace - Update a subfield with content of control field' + ); + }; }; # move_field - subfields -- 2.39.2