|
Lines 1-6
Link Here
|
| 1 |
use Modern::Perl; |
1 |
use Modern::Perl; |
| 2 |
|
2 |
|
| 3 |
use Test::More tests => 95; |
3 |
use Test::More tests => 96; |
| 4 |
|
4 |
|
| 5 |
use Koha::SimpleMARC; |
5 |
use Koha::SimpleMARC; |
| 6 |
|
6 |
|
|
Lines 346-351
subtest 'GetModificationTemplates' => sub {
Link Here
|
| 346 |
is_deeply( [map{$_->{name}} @templates], ['aaa', 'mmm', 'zzz'] ); |
346 |
is_deeply( [map{$_->{name}} @templates], ['aaa', 'mmm', 'zzz'] ); |
| 347 |
}; |
347 |
}; |
| 348 |
|
348 |
|
|
|
349 |
subtest "not_equals" => sub { |
| 350 |
plan tests => 2; |
| 351 |
$dbh->do(q|DELETE FROM marc_modification_templates|); |
| 352 |
my $template_id = AddModificationTemplate("template_name"); |
| 353 |
AddModificationTemplateAction( |
| 354 |
$template_id, 'move_field', 0, |
| 355 |
'650', '', '', '651', '', |
| 356 |
'', '', '', |
| 357 |
'if', '650', '9', 'not_equals', '499', '', |
| 358 |
'Move field 650 to 651 if 650$9 != 499' |
| 359 |
); |
| 360 |
my $record = new_record(); |
| 361 |
ModifyRecordWithTemplate( $template_id, $record ); |
| 362 |
my $expected_record = expected_record_2(); |
| 363 |
is_deeply( $record, $expected_record, '650 has been moved to 651 when 650$9 != 499' ); |
| 364 |
|
| 365 |
$dbh->do(q|DELETE FROM marc_modification_templates|); |
| 366 |
$template_id = AddModificationTemplate("template_name"); |
| 367 |
AddModificationTemplateAction( |
| 368 |
$template_id, 'move_field', 0, |
| 369 |
'650', '', '', '651', '', |
| 370 |
'', '', '', |
| 371 |
'if', '650', 'b', 'not_equals', '499', '', |
| 372 |
'Move field 650 to 651 if 650$b != 499' |
| 373 |
); |
| 374 |
$record = new_record(); |
| 375 |
ModifyRecordWithTemplate( $template_id, $record ); |
| 376 |
$expected_record = new_record(); |
| 377 |
is_deeply( $record, $expected_record, 'None 650 have been moved, no $650$b exists' ); |
| 378 |
}; |
| 379 |
|
| 349 |
sub new_record { |
380 |
sub new_record { |
| 350 |
my $record = MARC::Record->new; |
381 |
my $record = MARC::Record->new; |
| 351 |
$record->leader('03174nam a2200445 a 4500'); |
382 |
$record->leader('03174nam a2200445 a 4500'); |
|
Lines 445-472
sub expected_record_2 {
Link Here
|
| 445 |
c => 'Donald E. Knuth.', |
476 |
c => 'Donald E. Knuth.', |
| 446 |
), |
477 |
), |
| 447 |
MARC::Field->new( |
478 |
MARC::Field->new( |
|
|
479 |
245, '1', '4', |
| 480 |
a => 'Bad title', |
| 481 |
c => 'Donald E. Knuth.', |
| 482 |
), |
| 483 |
MARC::Field->new( |
| 448 |
650, ' ', '0', |
484 |
650, ' ', '0', |
| 449 |
9 => '462', |
485 |
a => 'Computer programming.', |
|
|
486 |
9 => '499', |
| 450 |
), |
487 |
), |
| 451 |
MARC::Field->new( |
488 |
MARC::Field->new( |
| 452 |
952, ' ', ' ', |
489 |
952, ' ', ' ', |
| 453 |
p => '3010023917_updated', |
490 |
p => '3010023917', |
| 454 |
y => 'BK', |
491 |
y => 'BK', |
| 455 |
c => 'GEN', |
492 |
c => 'GEN', |
| 456 |
e => '2001-06-25', |
493 |
d => '2001-06-25', |
| 457 |
), |
|
|
| 458 |
MARC::Field->new( |
| 459 |
246, '', ' ', |
| 460 |
a => 'The art of computer programming', |
| 461 |
), |
494 |
), |
| 462 |
MARC::Field->new( |
495 |
MARC::Field->new( |
| 463 |
651, ' ', '0', |
496 |
651, ' ', '0', |
| 464 |
a => 'Computer algorithms.', |
497 |
a => 'Computer programming.', |
| 465 |
9 => '499', |
498 |
9 => '462', |
| 466 |
), |
|
|
| 467 |
MARC::Field->new( |
| 468 |
999, ' ', ' ', |
| 469 |
a => 'non existent.', |
| 470 |
), |
499 |
), |
| 471 |
); |
500 |
); |
| 472 |
$record->append_fields(@fields); |
501 |
$record->append_fields(@fields); |
| 473 |
- |
|
|