3 use Test::More tests => 10;
6 use_ok("MARC::Record");
7 use_ok("Koha::SimpleMARC");
10 my $record = MARC::Record->new;
11 $record->leader('03174nam a2200445 a 4500');
15 a => 'Knuth, Donald Ervin',
20 a => 'The art of computer programming',
21 c => 'Donald E. Knuth.',
25 a => 'Computer programming.',
36 $record->append_fields(@fields);
41 subtest 'field_exists' => sub {
43 my $record = new_record;
45 field_exists( { record => $record, field => '650', subfield => 'a' } ),
50 field_exists( { record => $record, field => '650', subfield => 'b' } ),
52 '650$b does not exist'
55 $record->append_fields(
58 a => 'Computer algorithms.',
64 field_exists( { record => $record, field => '650', subfield => 'a' } ),
66 '650$a exists, field_exists returns the 2 field numbers'
71 subtest 'read_field' => sub {
73 subtest 'read subfield' => sub {
75 my $record = new_record;
76 $record->append_fields(
79 a => 'Computer algorithms.',
85 read_field( { record => $record, field => '650', subfield => 'a' } );
86 is_deeply( $fields_650a[0], 'Computer programming.', 'first 650$a' );
87 is_deeply( $fields_650a[1], 'Computer algorithms.', 'second 650$a' );
99 ['Computer programming.'],
113 ['Computer algorithms.'],
128 'There is no 3 650$a'
131 subtest 'read field' => sub {
133 my $record = new_record;
134 $record->append_fields(
137 a => 'Computer algorithms.',
150 [ 'Computer programming.', '462', 'Computer algorithms.', '463' ],
151 'Get the all subfield values for field 650'
163 [ 'Computer programming.', '462' ],
164 'Get the all subfield values for the first field 650'
169 { record => $record, field => '650', field_numbers => [2] }
172 [ 'Computer algorithms.', '463' ],
173 'Get the all subfield values for the second field 650'
178 { record => $record, field => '650', field_numbers => [3] }
182 'Get the all subfield values for the third field 650 which does not exist'
188 subtest 'update_field' => sub {
190 subtest 'update subfield' => sub {
192 my $record = new_record;
199 values => ['3010023918']
205 { record => $record, field => '952', subfield => 'p' }
209 'update existing subfield 952$p'
211 delete_field( { record => $record, field => '952' } );
217 values => ['3010023918']
231 { record => $record, field => '952', subfield => 'p' }
235 'create subfield 952$p'
239 { record => $record, field => '952', subfield => 'y' }
242 'create subfield 952$k on existing 952 field'
245 $record->append_fields(
257 values => ['3010023919']
261 read_field( { record => $record, field => '952', subfield => 'p' } );
264 [ '3010023919', '3010023919' ],
265 'update all subfields 952$p with the same value'
273 values => [ '3010023917', '3010023918' ]
277 read_field( { record => $record, field => '952', subfield => 'p' } );
280 [ '3010023917', '3010023918' ],
281 'update all subfields 952$p with the different values'
286 # copy_field - subfield
287 subtest 'copy_field' => sub {
289 subtest 'copy subfield' => sub {
291 my $record = new_record;
292 $record->append_fields(
295 a => 'Computer algorithms.',
303 from_subfield => 'a',
311 { record => $record, field => '245', subfield => 'a' }
314 ['The art of computer programming'],
315 'After copy 245$a still exists'
320 { record => $record, field => '246', subfield => 'a' }
323 ['The art of computer programming'],
324 '246$a is a new field'
326 delete_field( { record => $record, field => '246' } );
329 { record => $record, field => '246', subfield => 'a' }
332 '246$a does not exist anymore'
339 from_subfield => 'a',
345 read_field( { record => $record, field => '651', subfield => 'a' } );
348 [ 'Computer programming.', 'Computer algorithms.' ],
349 'Copy multivalued field'
351 delete_field( { record => $record, field => '651' } );
357 from_subfield => 'a',
366 { record => $record, field => '651', subfield => 'a' }
369 ['Computer programming.'],
370 'Copy first field 650$a'
372 delete_field( { record => $record, field => '652' } );
378 from_subfield => 'a',
387 { record => $record, field => '651', subfield => 'a' }
390 ['Computer programming.', 'Computer algorithms.'],
391 'Copy second field 650$a'
393 delete_field( { record => $record, field => '651' } );
399 from_subfield => 'a',
402 regex => { search => 'Computer', replace => 'The art of' }
406 read_field( { record => $record, field => '651', subfield => 'a' } );
409 [ 'The art of programming.', 'The art of algorithms.' ],
410 'Copy field using regex'
412 delete_field( { record => $record, field => '651' } );
418 from_subfield => 'a',
421 regex => { search => 'Computer', replace => 'The mistake of' }
425 read_field( { record => $record, field => '651', subfield => 'a' } );
428 [ 'The mistake of programming.', 'The mistake of algorithms.' ],
429 'Copy fields using regex on existing fields'
431 delete_field( { record => $record, field => '651' } );
437 from_subfield => 'a',
440 regex => { search => 'Computer', replace => 'The art of' }
444 read_field( { record => $record, field => '651', subfield => 'a' } );
447 [ 'The art of programming.', 'The art of algorithms.', ],
448 'Copy all fields using regex'
450 delete_field( { record => $record, field => '651' } );
456 from_subfield => 'a',
459 regex => { search => 'Computer', replace => 'The art of' },
464 read_field( { record => $record, field => '651', subfield => 'a' } );
467 [ 'The art of programming.', ],
468 'Copy first field using regex'
470 delete_field( { record => $record, field => '651' } );
472 # Copy with regex modifiers
473 $record = new_record;
474 $record->append_fields(
477 a => 'Computer algorithms.',
485 from_subfield => 'a',
488 regex => { search => 'o', replace => 'foo' }
492 read_field( { record => $record, field => '652', subfield => 'a' } );
495 [ 'Cfoomputer programming.', 'Cfoomputer algorithms.' ],
496 'Copy field using regex'
503 from_subfield => 'a',
506 regex => { search => 'o', replace => 'foo', modifiers => 'g' }
510 read_field( { record => $record, field => '653', subfield => 'a' } );
513 [ 'Cfoomputer prfoogramming.', 'Cfoomputer algfoorithms.' ],
514 'Copy field using regex'
521 from_subfield => 'a',
524 regex => { search => 'O', replace => 'foo', modifiers => 'i' }
528 read_field( { record => $record, field => '654', subfield => 'a' } );
531 [ 'Cfoomputer programming.', 'Cfoomputer algorithms.' ],
532 'Copy field using regex'
539 from_subfield => 'a',
542 regex => { search => 'O', replace => 'foo', modifiers => 'gi' }
546 read_field( { record => $record, field => '655', subfield => 'a' } );
549 [ 'Cfoomputer prfoogramming.', 'Cfoomputer algfoorithms.' ],
550 'Copy field using regex'
553 $record = new_record;
554 $record->append_fields(
566 from_subfield => 'd',
572 read_field( { record => $record, field => '952', subfield => 'd' } );
573 # FIXME We need a new action "duplicate" if we don't want to modify the original field
576 [ '2001-06-25', '2001-06-25', '2001-06-25' ],
577 'copy 952$d into others 952 field'
584 from_subfield => '1',
590 read_field( { record => $record, field => '999', subfield => '9' } );
591 is_deeply( \@fields_9999, [],
592 'copy a nonexistent subfield does not create a new one' );
594 $record = new_record;
599 from_subfield => 'a',
602 regex => { search => '^', replace => 'BEGIN ' }
608 { record => $record, field => '245', subfield => 'a' }
611 ['The art of computer programming', 'BEGIN The art of computer programming'],
612 'Update a subfield: add a string at the beginning'
615 $record = new_record;
620 from_subfield => 'a',
623 regex => { search => '$', replace => ' END' }
629 { record => $record, field => '245', subfield => 'a' }
632 ['The art of computer programming', 'The art of computer programming END'],
633 'Update a subfield: add a string at the end'
636 $record = new_record;
641 from_subfield => 'c',
650 { record => $record, field => '650' }
653 [ 'Computer programming.', '462', 'Donald E. Knuth.' ],
654 'Copy a subfield to an existent field but inexistent subfield'
657 $record = new_record;
662 from_subfield => 'c',
671 { record => $record, field => '650' }
674 [ 'Computer programming.', '462', 'Donald E. Knuth.' ],
675 'Copy a subfield to an existent field / subfield'
679 subtest 'copy field' => sub {
681 my $record = new_record;
682 $record->append_fields(
692 { record => $record, from_field => '952', to_field => '953' } );
693 my @fields_952 = read_field( { record => $record, field => '952' } );
697 { record => $record, field => '952', field_numbers => [1] }
700 [ '3010023917', 'BK', 'GEN', '2001-06-25' ],
701 "copy all: original first field still exists"
706 { record => $record, field => '952', field_numbers => [2] }
709 [ '3010023918', 'CD' ],
710 "copy all: original second field still exists"
715 { record => $record, field => '953', field_numbers => [1] }
718 [ '3010023917', 'BK', 'GEN', '2001-06-25' ],
719 "copy all: first original fields has been copied"
724 { record => $record, field => '953', field_numbers => [2] }
727 [ '3010023918', 'CD' ],
728 "copy all: second original fields has been copied"
731 #- copy only the first field
743 { record => $record, field => '953', field_numbers => [1] }
746 [ '3010023917', 'BK', 'GEN', '2001-06-25' ],
747 "copy first: first original fields has been copied"
752 { record => $record, field => '953', field_numbers => [2] }
755 [ '3010023918', 'CD' ],
756 "copy first: second original fields has been copied"
759 [ read_field( { record => $record, field => '954' } ) ],
760 [ '3010023917', 'BK', 'GEN', '2001-06-25' ],
761 "copy first: only first, first 953 has been copied"
764 $record = new_record;
765 $record->append_fields(
773 #- copy all fields and modify values using a regex
779 regex => { search => '30100', replace => '42424' }
785 { record => $record, field => '952', field_numbers => [1] }
788 [ '3010023917', 'BK', 'GEN', '2001-06-25' ],
789 "copy all with regex: original first field still exists"
794 { record => $record, field => '952', field_numbers => [2] }
797 [ '3010023918', 'CD' ],
798 "copy all with regex: original second field still exists"
803 { record => $record, field => '953', field_numbers => [1] }
806 [ '4242423917', 'BK', 'GEN', '2001-06-25' ],
807 "copy all with regex: first original fields has been copied"
812 { record => $record, field => '953', field_numbers => [2] }
815 [ '4242423918', 'CD' ],
816 "copy all with regex: second original fields has been copied"
826 read_field( { record => $record, field => '999', subfield => '9' } );
827 is_deeply( \@fields_9999, [],
828 'copy a nonexistent field does not create a new one' );
830 $record = new_record;
842 { record => $record, field => '650', field_numbers => [2] }
845 [ 'The art of computer programming', 'Donald E. Knuth.' ],
846 'Copy a field to existent fields should create a new field'
851 { record => $record, field => '650', field_numbers => [1] }
854 [ 'Computer programming.', '462' ],
855 'Copy a field to existent fields should create a new field, the original one should not have been updated'
860 # copy_and_replace_field - subfield
861 subtest 'copy_and_replace_field' => sub {
863 subtest 'copy and replace subfield' => sub {
865 my $record = new_record;
866 $record->append_fields(
869 a => 'Computer algorithms.',
873 copy_and_replace_field(
877 from_subfield => 'a',
885 { record => $record, field => '245', subfield => 'a' }
888 ['The art of computer programming'],
889 'Copy and replace should not have modify original subfield 245$a (same as copy)'
894 { record => $record, field => '246', subfield => 'a' }
897 ['The art of computer programming'],
898 'Copy and replace should create a new 246$a (same as copy)'
901 $record = new_record;
902 $record->append_fields(
905 a => 'Computer algorithms.',
909 copy_and_replace_field(
913 from_subfield => 'a',
919 read_field( { record => $record, field => '651', subfield => 'a' } );
922 [ 'Computer programming.', 'Computer algorithms.' ],
923 'Copy and replace multivalued field (same as copy)'
925 delete_field( { record => $record, field => '651' } );
927 copy_and_replace_field(
931 from_subfield => 'a',
940 { record => $record, field => '651', subfield => 'a' }
943 ['Computer programming.'],
944 'Copy and replace first field 650$a should only copy the 1st (same as copy)'
947 copy_and_replace_field(
951 from_subfield => 'a',
960 { record => $record, field => '651', subfield => 'a' }
963 ['Computer algorithms.'],
964 'Copy and replace second field 650$a should erase 651$a'
966 delete_field( { record => $record, field => '651' } );
968 copy_and_replace_field(
972 from_subfield => 'a',
975 regex => { search => 'Computer', replace => 'The art of' }
979 read_field( { record => $record, field => '651', subfield => 'a' } );
982 [ 'The art of programming.', 'The art of algorithms.' ],
983 'Copy and replace field using regex (same as copy)'
985 delete_field( { record => $record, field => '651' } );
987 copy_and_replace_field(
991 from_subfield => 'a',
994 regex => { search => 'Computer', replace => 'The mistake of' }
998 read_field( { record => $record, field => '651', subfield => 'a' } );
1001 [ 'The mistake of programming.', 'The mistake of algorithms.' ],
1002 'Copy and replace fields using regex on existing fields (same as copy)'
1004 delete_field( { record => $record, field => '651' } );
1006 copy_and_replace_field(
1009 from_field => '650',
1010 from_subfield => 'a',
1013 regex => { search => 'Computer', replace => 'The art of' }
1017 read_field( { record => $record, field => '651', subfield => 'a' } );
1020 [ 'The art of programming.', 'The art of algorithms.', ],
1021 'Copy and replace all fields using regex (same as copy)'
1023 delete_field( { record => $record, field => '651' } );
1025 copy_and_replace_field(
1028 from_field => '650',
1029 from_subfield => 'a',
1032 regex => { search => 'Computer', replace => 'The art of' },
1033 field_numbers => [1]
1037 read_field( { record => $record, field => '651', subfield => 'a' } );
1040 [ 'The art of programming.', ],
1041 'Copy and replace first field using regex (same as copy)'
1043 delete_field( { record => $record, field => '651' } );
1045 # Copy and replace with regex modifiers
1046 $record = new_record;
1047 $record->append_fields(
1050 a => 'Computer algorithms.',
1054 copy_and_replace_field(
1057 from_field => '650',
1058 from_subfield => 'a',
1061 regex => { search => 'o', replace => 'foo' }
1065 read_field( { record => $record, field => '652', subfield => 'a' } );
1068 [ 'Cfoomputer programming.', 'Cfoomputer algorithms.' ],
1069 'Copy and replace field using regex (same as copy)'
1072 copy_and_replace_field(
1075 from_field => '650',
1076 from_subfield => 'a',
1079 regex => { search => 'o', replace => 'foo', modifiers => 'g' }
1083 read_field( { record => $record, field => '653', subfield => 'a' } );
1086 [ 'Cfoomputer prfoogramming.', 'Cfoomputer algfoorithms.' ],
1087 'Copy and replace field using regex (same as copy)'
1090 copy_and_replace_field(
1093 from_field => '650',
1094 from_subfield => 'a',
1097 regex => { search => 'O', replace => 'foo', modifiers => 'i' }
1101 read_field( { record => $record, field => '654', subfield => 'a' } );
1104 [ 'Cfoomputer programming.', 'Cfoomputer algorithms.' ],
1105 'Copy and replace field using regex (same as copy)'
1108 copy_and_replace_field(
1111 from_field => '650',
1112 from_subfield => 'a',
1115 regex => { search => 'O', replace => 'foo', modifiers => 'gi' }
1119 read_field( { record => $record, field => '655', subfield => 'a' } );
1122 [ 'Cfoomputer prfoogramming.', 'Cfoomputer algfoorithms.' ],
1123 'Copy and replace field using regex (same as copy)'
1126 $record = new_record;
1127 $record->append_fields(
1135 copy_and_replace_field(
1138 from_field => '952',
1139 from_subfield => 'd',
1145 read_field( { record => $record, field => '952', subfield => 'd' } );
1148 [ '2001-06-25', '2001-06-25' ],
1149 'copy and replace 952$d into others 952 field'
1152 copy_and_replace_field(
1155 from_field => '111',
1156 from_subfield => '1',
1162 read_field( { record => $record, field => '999', subfield => '9' } );
1163 is_deeply( \@fields_9999, [],
1164 'copy and replace a nonexistent subfield does not create a new one (same as copy)' );
1166 $record = new_record;
1167 copy_and_replace_field(
1171 from_subfield => 'a',
1174 regex => { search => '^', replace => 'BEGIN ' }
1177 # This is the same as update the subfield
1181 { record => $record, field => '245', subfield => 'a' }
1184 ['BEGIN The art of computer programming'],
1185 'Copy and replace - Update a subfield: add a string at the beginning'
1188 $record = new_record;
1189 copy_and_replace_field(
1193 from_subfield => 'a',
1196 regex => { search => '$', replace => ' END' }
1199 # This is the same as update the subfield
1203 { record => $record, field => '245', subfield => 'a' }
1206 ['The art of computer programming END'],
1207 'Copy and replace - Update a subfield: add a string at the end'
1210 $record = new_record;
1211 copy_and_replace_field(
1215 from_subfield => 'c',
1224 { record => $record, field => '650' }
1227 [ 'Computer programming.', '462', 'Donald E. Knuth.' ],
1228 'Copy and replace a subfield to an existent field but inexistent subfield (same as copy)'
1231 $record = new_record;
1232 copy_and_replace_field(
1236 from_subfield => 'c',
1245 { record => $record, field => '650' }
1248 [ 'Computer programming.', 'Donald E. Knuth.' ],
1249 'Copy and replace a subfield to an existent field / subfield, the origin subfield is replaced'
1253 subtest 'copy and replace field' => sub {
1255 my $record = new_record;
1256 $record->append_fields(
1265 copy_and_replace_field(
1266 { record => $record, from_field => '952', to_field => '953' } );
1267 my @fields_952 = read_field( { record => $record, field => '952' } );
1271 { record => $record, field => '952', field_numbers => [1] }
1274 [ '3010023917', 'BK', 'GEN', '2001-06-25' ],
1275 "copy all: original first field still exists (same as copy)"
1280 { record => $record, field => '952', field_numbers => [2] }
1283 [ '3010023918', 'CD' ],
1284 "copy all: original second field still exists (same as copy)"
1289 { record => $record, field => '953', field_numbers => [1] }
1292 [ '3010023917', 'BK', 'GEN', '2001-06-25' ],
1293 "copy all: first original fields has been copied (same as copy)"
1298 { record => $record, field => '953', field_numbers => [2] }
1301 [ '3010023918', 'CD' ],
1302 "copy all: second original fields has been copied (same as copy)"
1305 #- copy only the first field
1306 copy_and_replace_field(
1309 from_field => '953',
1311 field_numbers => [1]
1317 { record => $record, field => '953', field_numbers => [1] }
1320 [ '3010023917', 'BK', 'GEN', '2001-06-25' ],
1321 "copy and replace first: first original fields has been copied (same as copy)"
1326 { record => $record, field => '953', field_numbers => [2] }
1329 [ '3010023918', 'CD' ],
1330 "copy and replace first: second original fields has been copied (same as copy)"
1333 [ read_field( { record => $record, field => '954' } ) ],
1334 [ '3010023917', 'BK', 'GEN', '2001-06-25' ],
1335 "copy and replace first: only first, first 953 has been copied (same as copy)"
1338 $record = new_record;
1339 $record->append_fields(
1347 #- copy and replace all fields and modify values using a regex
1348 copy_and_replace_field(
1351 from_field => '952',
1353 regex => { search => '30100', replace => '42424' }
1359 { record => $record, field => '952', field_numbers => [1] }
1362 [ '3010023917', 'BK', 'GEN', '2001-06-25' ],
1363 "copy and replace all with regex: original first field still exists (same as copy)"
1368 { record => $record, field => '952', field_numbers => [2] }
1371 [ '3010023918', 'CD' ],
1372 "copy and replace all with regex: original second field still exists (same as copy)"
1377 { record => $record, field => '953', field_numbers => [1] }
1380 [ '4242423917', 'BK', 'GEN', '2001-06-25' ],
1381 "copy and replace all with regex: first original fields has been copied (same as copy)"
1386 { record => $record, field => '953', field_numbers => [2] }
1389 [ '4242423918', 'CD' ],
1390 "copy and replace all with regex: second original fields has been copied (same as copy)"
1392 copy_and_replace_field(
1395 from_field => '111',
1400 read_field( { record => $record, field => '999', subfield => '9' } );
1401 is_deeply( \@fields_9999, [],
1402 'copy and replace a nonexistent field does not create a new one (same as copy)' );
1404 $record = new_record;
1405 copy_and_replace_field(
1416 { record => $record, field => '650', field_numbers => [1] }
1419 [ 'The art of computer programming', 'Donald E. Knuth.' ],
1420 'Copy and replace to an existent field should erase the original field'
1425 { record => $record, field => '650', field_numbers => [2] }
1429 'Copy and replace to an existent field should not create a new field'
1434 # move_field - subfields
1435 subtest 'move_field' => sub {
1437 subtest 'move subfield' => sub {
1439 my $record = new_record;
1440 my ( @fields_952d, @fields_952c, @fields_954c, @fields_954p );
1441 $record->append_fields(
1451 from_field => '952',
1452 from_subfield => 'c',
1458 read_field( { record => $record, field => '952', subfield => 'c' } );
1460 read_field( { record => $record, field => '954', subfield => 'c' } );
1461 is_deeply( \@fields_952c, [], 'The 952$c has moved' );
1462 is_deeply( \@fields_954c, ['GEN'], 'Now 954$c exists' );
1467 from_field => '952',
1468 from_subfield => 'p',
1471 field_numbers => [1]
1473 ); # Move the first field
1475 read_field( { record => $record, field => '952', subfield => 'p' } );
1477 read_field( { record => $record, field => '954', subfield => 'p' } );
1478 is_deeply( \@fields_952p, ['3010023917'], 'One of 952$p has moved' );
1479 is_deeply( \@fields_954p, ['3010023917'], 'Now 954$p exists' );
1481 $record = new_record;
1482 $record->append_fields(
1493 from_field => '952',
1494 from_subfield => 'p',
1500 read_field( { record => $record, field => '952', subfield => 'p' } );
1502 read_field( { record => $record, field => '954', subfield => 'p' } );
1503 is_deeply( \@fields_952p, [], 'All 952$p have moved' );
1506 [ '3010023917', '3010023917' ],
1513 from_field => '111',
1514 from_subfield => '1',
1520 read_field( { record => $record, field => '999', subfield => '9' } );
1521 is_deeply( \@fields_9999, [],
1522 'move a nonexistent subfield does not create a new one' );
1525 subtest 'move field' => sub {
1528 # move_field - fields
1529 my $record = new_record;
1530 $record->append_fields(
1540 { record => $record, from_field => '952', to_field => '953' } );
1541 is_deeply( [ read_field( { record => $record, field => '952' } ) ],
1542 [], "original fields don't exist" );
1546 { record => $record, field => '953', field_numbers => [1] }
1549 [ '3010023917', 'BK', 'GEN', '2001-06-25' ],
1550 "first original fields has been copied"
1555 { record => $record, field => '953', field_numbers => [2] }
1558 [ '3010023917', 'BK' ],
1559 "second original fields has been copied"
1562 #- Move only the first field
1566 from_field => '953',
1568 field_numbers => [1]
1572 [ read_field( { record => $record, field => '953' } ) ],
1573 [ '3010023917', 'BK' ],
1574 "only first, the second 953 still exists"
1577 [ read_field( { record => $record, field => '954' } ) ],
1578 [ '3010023917', 'BK', 'GEN', '2001-06-25' ],
1579 "only first, first 953 has been copied"
1582 $record = new_record;
1583 $record->append_fields(
1591 #- Move all fields and modify values using a regex
1595 from_field => '952',
1597 regex => { search => 'BK', replace => 'DVD' }
1600 is_deeply( [ read_field( { record => $record, field => '952' } ) ],
1601 [], "use a regex, original fields don't exist" );
1605 { record => $record, field => '953', field_numbers => [1] }
1608 [ '3010023917', 'DVD', 'GEN', '2001-06-25' ],
1609 "use a regex, first original fields has been copied"
1614 { record => $record, field => '953', field_numbers => [2] }
1617 [ '3010023917', 'DVD' ],
1618 "use a regex, second original fields has been copied"
1624 from_field => '111',
1629 read_field( { record => $record, field => '999', subfield => '9' } );
1630 is_deeply( \@fields_9999, [],
1631 'move a nonexistent field does not create a new one' );
1637 subtest 'delete_field' => sub {
1639 subtest 'delete subfield' => sub {
1641 my $record = new_record;
1642 $record->append_fields(
1655 field_numbers => [1]
1659 read_field( { record => $record, field => '952', subfield => 'p' } );
1660 is_deeply( \@fields_952p, ['3010023917'], 'Delete first 952$p' );
1662 $record = new_record;
1663 $record->append_fields(
1670 delete_field( { record => $record, field => '952', subfield => 'p' } );
1672 read_field( { record => $record, field => '952', subfield => 'p' } );
1673 is_deeply( \@fields_952p, [], 'Delete all 952$p' );
1676 subtest 'delete field' => sub {
1678 my $record = new_record;
1679 delete_field( { record => $record, field => '952' } );
1680 my @fields_952 = read_field( { record => $record, field => '952' } );
1681 is_deeply( \@fields_952, [], 'Delete all 952, 1 deleted' );
1683 $record = new_record;
1684 $record->append_fields(
1691 delete_field( { record => $record, field => '952' } );
1692 @fields_952 = read_field( { record => $record, field => '952' } );
1693 is_deeply( \@fields_952, [], 'Delete all 952, 2 deleted' );