Bugzilla – Attachment 186781 Details for
Bug 32950
MARC modification template moving subfield can lose values for repeatable fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32950: Add test for moving subfield in repeatable fields
Bug-32950-Add-test-for-moving-subfield-in-repeatab.patch (text/plain), 4.06 KB, created by
Martin Renvoize (ashimema)
on 2025-09-23 09:51:29 UTC
(
hide
)
Description:
Bug 32950: Add test for moving subfield in repeatable fields
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-09-23 09:51:29 UTC
Size:
4.06 KB
patch
obsolete
>From d80dae650cd90ea391273b18ab934e6375d2495d Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Tue, 23 Sep 2025 10:37:38 +0100 >Subject: [PATCH] Bug 32950: Add test for moving subfield in repeatable fields > >This test verifies that when moving subfields between repeatable fields, >existing values in fields that don't contain the source subfield are >preserved. > >The test creates multiple 020 fields: >- Some with existing $a values >- Some with $z values to be moved to $a > >After applying the move template, it verifies: >- Existing $a values are preserved >- $z values are moved to $a only in fields that had $z >- $z subfields are properly removed after the move >--- > t/db_dependent/MarcModificationTemplates.t | 60 +++++++++++++++++++++- > 1 file changed, 59 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/MarcModificationTemplates.t b/t/db_dependent/MarcModificationTemplates.t >index f4465f09fd4..aaf24a8128c 100755 >--- a/t/db_dependent/MarcModificationTemplates.t >+++ b/t/db_dependent/MarcModificationTemplates.t >@@ -3,7 +3,7 @@ > use Modern::Perl; > > use Test::NoWarnings; >-use Test::More tests => 130; >+use Test::More tests => 131; > > use Koha::Database; > use Koha::SimpleMARC; >@@ -1018,3 +1018,61 @@ is_deeply( > $record, $expected_record_0, > '100$0 has been deleted, added back, updated, moved to 600$0, and copied back to 100$0; finally, 245$0 has been copied and replaced to 700$0' > ); >+ >+# Test for Bug 32950: Moving subfield can lose values for repeatable fields >+subtest "Bug 32950: Moving subfield preserves values in repeatable fields" => sub { >+ plan tests => 14; >+ $dbh->do(q|DELETE FROM marc_modification_templates|); >+ my $template_id = AddModificationTemplate("test_bug_32950"); >+ >+ # Create template action to move 020$z to 020$a >+ AddModificationTemplateAction( >+ $template_id, 'move_field', 0, >+ '020', 'z', '', '020', 'a', >+ '', '', '', >+ '', '', '', '', '', '', >+ 'Move field 020$z to 020$a' >+ ); >+ >+ # Create test record with multiple 020 fields, some with $a, some with $z >+ my $record = MARC::Record->new; >+ $record->leader('03174nam a2200445 a 4500'); >+ my @fields = ( >+ MARC::Field->new( '020', ' ', ' ', 'a' => '9781003182870', 'q' => '(ebk)' ), >+ MARC::Field->new( '020', ' ', ' ', 'a' => '1003182879' ), >+ MARC::Field->new( '020', ' ', ' ', 'a' => '9781000407204', 'q' => '(electronic bk. : EPUB)' ), >+ MARC::Field->new( '020', ' ', ' ', 'z' => '9781032023175', 'q' => '(hbk.)' ), >+ MARC::Field->new( '020', ' ', ' ', 'z' => '9780367760380', 'q' => '(pbk.)' ), >+ ); >+ $record->append_fields(@fields); >+ >+ # Apply the template >+ ModifyRecordWithTemplate( $template_id, $record ); >+ >+ # Get all 020 fields after modification >+ my @fields_020 = $record->field('020'); >+ is( scalar @fields_020, 5, "Should still have 5 020 fields" ); >+ >+ # Check that existing $a values are preserved >+ is( $fields_020[0]->subfield('a'), '9781003182870', 'First field $a value preserved' ); >+ is( $fields_020[0]->subfield('q'), '(ebk)', 'First field $q value preserved' ); >+ >+ is( $fields_020[1]->subfield('a'), '1003182879', 'Second field $a value preserved' ); >+ >+ is( $fields_020[2]->subfield('a'), '9781000407204', 'Third field $a value preserved' ); >+ is( $fields_020[2]->subfield('q'), '(electronic bk. : EPUB)', 'Third field $q value preserved' ); >+ >+ # Check that $z values were moved to $a in fields that had $z >+ is( $fields_020[3]->subfield('a'), '9781032023175', 'Fourth field $z moved to $a' ); >+ is( $fields_020[3]->subfield('q'), '(hbk.)', 'Fourth field $q value preserved' ); >+ >+ is( $fields_020[4]->subfield('a'), '9780367760380', 'Fifth field $z moved to $a' ); >+ >+ # Verify $z subfields were removed (move operation) >+ for my $field (@fields_020) { >+ my @z_subfields = $field->subfield('z'); >+ is( scalar @z_subfields, 0, 'No $z subfields should remain' ); >+ } >+ >+ DelModificationTemplate($template_id); >+}; >-- >2.51.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32950
:
146586
|
186781
|
186782
|
187184
|
187185
|
187186
|
187187
|
187450
|
187451
|
187452
|
187538