|
Lines 326-332
subtest 'update_field' => sub {
Link Here
|
| 326 |
subtest 'copy_field' => sub { |
326 |
subtest 'copy_field' => sub { |
| 327 |
plan tests => 2; |
327 |
plan tests => 2; |
| 328 |
subtest 'copy subfield' => sub { |
328 |
subtest 'copy subfield' => sub { |
| 329 |
plan tests => 20; |
329 |
plan tests => 21; |
| 330 |
my $record = new_record; |
330 |
my $record = new_record; |
| 331 |
$record->append_fields( |
331 |
$record->append_fields( |
| 332 |
MARC::Field->new( |
332 |
MARC::Field->new( |
|
Lines 672-677
subtest 'copy_field' => sub {
Link Here
|
| 672 |
'Update a subfield: add a string at the end' |
672 |
'Update a subfield: add a string at the end' |
| 673 |
); |
673 |
); |
| 674 |
|
674 |
|
|
|
675 |
$record = new_record; |
| 676 |
copy_field( |
| 677 |
{ |
| 678 |
record => $record, |
| 679 |
from_field => 245, |
| 680 |
from_subfield => 'a', |
| 681 |
to_field => 245, |
| 682 |
to_subfield => 'a', |
| 683 |
regex => { search => '(art)', replace => 'sm$1 $1' } |
| 684 |
} |
| 685 |
); |
| 686 |
is_deeply( |
| 687 |
[ |
| 688 |
read_field( |
| 689 |
{ record => $record, field => '245', subfield => 'a' } |
| 690 |
) |
| 691 |
], |
| 692 |
['The art of computer programming', 'The smart art of computer programming'], |
| 693 |
'Update a subfield: use capture groups' |
| 694 |
); |
| 695 |
|
| 675 |
$record = new_record; |
696 |
$record = new_record; |
| 676 |
copy_field( |
697 |
copy_field( |
| 677 |
{ |
698 |
{ |
|
Lines 900-906
subtest 'copy_field' => sub {
Link Here
|
| 900 |
subtest 'copy_and_replace_field' => sub { |
921 |
subtest 'copy_and_replace_field' => sub { |
| 901 |
plan tests => 2; |
922 |
plan tests => 2; |
| 902 |
subtest 'copy and replace subfield' => sub { |
923 |
subtest 'copy and replace subfield' => sub { |
| 903 |
plan tests => 19; |
924 |
plan tests => 20; |
| 904 |
my $record = new_record; |
925 |
my $record = new_record; |
| 905 |
$record->append_fields( |
926 |
$record->append_fields( |
| 906 |
MARC::Field->new( |
927 |
MARC::Field->new( |
|
Lines 1246-1251
subtest 'copy_and_replace_field' => sub {
Link Here
|
| 1246 |
'Copy and replace - Update a subfield: add a string at the end' |
1267 |
'Copy and replace - Update a subfield: add a string at the end' |
| 1247 |
); |
1268 |
); |
| 1248 |
|
1269 |
|
|
|
1270 |
$record = new_record; |
| 1271 |
copy_and_replace_field( |
| 1272 |
{ |
| 1273 |
record => $record, |
| 1274 |
from_field => 245, |
| 1275 |
from_subfield => 'a', |
| 1276 |
to_field => 245, |
| 1277 |
to_subfield => 'a', |
| 1278 |
regex => { search => '(art)', replace => 'sm$1 $1' } |
| 1279 |
} |
| 1280 |
); |
| 1281 |
# This is the same as update the subfield |
| 1282 |
is_deeply( |
| 1283 |
[ |
| 1284 |
read_field( |
| 1285 |
{ record => $record, field => '245', subfield => 'a' } |
| 1286 |
) |
| 1287 |
], |
| 1288 |
['The smart art of computer programming'], |
| 1289 |
'Copy and replace - Update a subfield: use capture groups' |
| 1290 |
); |
| 1291 |
|
| 1249 |
$record = new_record; |
1292 |
$record = new_record; |
| 1250 |
copy_and_replace_field( |
1293 |
copy_and_replace_field( |
| 1251 |
{ |
1294 |
{ |
| 1252 |
- |
|
|