| 
      
            Lines 1-6
          
      
      
        Link Here
      
     | 
  
        
          | 1 | 
          use Modern::Perl;  | 
          1 | 
          use Modern::Perl;  | 
        
        
          | 2 | 
           | 
          2 | 
           | 
        
          
            
              | 3 | 
              use Test::More tests => 115;  | 
              3 | 
              use Test::More tests => 125;  | 
            
        
          | 4 | 
           | 
          4 | 
           | 
        
        
          | 5 | 
          use Koha::Database;  | 
          5 | 
          use Koha::Database;  | 
        
        
          | 6 | 
          use Koha::SimpleMARC;  | 
          6 | 
          use Koha::SimpleMARC;  | 
        
  
    | 
      
            Lines 55-61
          is( AddModificationTemplateAction(
      
      
        Link Here
      
     | 
  
        
          | 55 | 
          # Getter  | 
          55 | 
          # Getter  | 
        
        
          | 56 | 
           | 
          56 | 
           | 
        
        
          | 57 | 
          my @actions = GetModificationTemplateActions( $template_id );  | 
          57 | 
          my @actions = GetModificationTemplateActions( $template_id );  | 
        
          
            
              | 58 | 
              is( @actions, 4, "4 actions are insered");  | 
              58 | 
              is( @actions, 4, "4 actions are inserted");  | 
            
        
          | 59 | 
           | 
          59 | 
           | 
        
        
          | 60 | 
          for my $action ( @actions ) { | 
          60 | 
          for my $action ( @actions ) { | 
        
        
          | 61 | 
              isnt( GetModificationTemplateAction( $action->{mmta_id} ), undef, "action with id $action->{mmta_id} exists" ); | 
          61 | 
              isnt( GetModificationTemplateAction( $action->{mmta_id} ), undef, "action with id $action->{mmta_id} exists" ); | 
        
  
    | 
      
            Lines 546-548
          sub expected_record_2 {
      
      
        Link Here
      
     | 
  
        
          | 546 | 
              $record->append_fields(@fields);  | 
          546 | 
              $record->append_fields(@fields);  | 
        
        
          | 547 | 
              return $record;  | 
          547 | 
              return $record;  | 
        
        
          | 548 | 
          }  | 
          548 | 
          }  | 
        
          
            
              | 549 | 
              -   | 
              549 | 
               | 
            
            
               | 
               | 
              550 | 
              # Tests related to use of subfield 0 ($0)  | 
            
            
              | 551 | 
               | 
            
            
              | 552 | 
              sub new_record_0 { | 
            
            
              | 553 | 
                  my $record = MARC::Record->new;  | 
            
            
              | 554 | 
                  $record->leader('03174nam a2200445 a 4500'); | 
            
            
              | 555 | 
                  my @fields = (  | 
            
            
              | 556 | 
                      MARC::Field->new(  | 
            
            
              | 557 | 
                          100, '1', ' ',  | 
            
            
              | 558 | 
                          0 => '12345',  | 
            
            
              | 559 | 
                          a => 'Knuth, Donald Ervin',  | 
            
            
              | 560 | 
                          d => '1938',  | 
            
            
              | 561 | 
                      ),  | 
            
            
              | 562 | 
                      MARC::Field->new(  | 
            
            
              | 563 | 
                          245, '1', '4',  | 
            
            
              | 564 | 
                          0 => '12345',  | 
            
            
              | 565 | 
                          a => 'The art of computer programming',  | 
            
            
              | 566 | 
                          c => 'Donald E. Knuth.',  | 
            
            
              | 567 | 
                      ),  | 
            
            
              | 568 | 
                      MARC::Field->new(  | 
            
            
              | 569 | 
                          650, ' ', '0',  | 
            
            
              | 570 | 
                          0 => '42',  | 
            
            
              | 571 | 
                          a => 'Computer programming.',  | 
            
            
              | 572 | 
                          9 => '462',  | 
            
            
              | 573 | 
                      ),  | 
            
            
              | 574 | 
                  );  | 
            
            
              | 575 | 
                  $record->append_fields(@fields);  | 
            
            
              | 576 | 
                  return $record;  | 
            
            
              | 577 | 
              }  | 
            
            
              | 578 | 
               | 
            
            
              | 579 | 
              sub expected_record_0 { | 
            
            
              | 580 | 
                  my $record = MARC::Record->new;  | 
            
            
              | 581 | 
                  $record->leader('03174nam a2200445 a 4500'); | 
            
            
              | 582 | 
                  my @fields = (  | 
            
            
              | 583 | 
                      MARC::Field->new(  | 
            
            
              | 584 | 
                          245, '1', '4',  | 
            
            
              | 585 | 
                          0 => '12345',  | 
            
            
              | 586 | 
                          a => 'The art of computer programming',  | 
            
            
              | 587 | 
                          c => 'Donald E. Knuth.',  | 
            
            
              | 588 | 
                      ),  | 
            
            
              | 589 | 
                      MARC::Field->new(  | 
            
            
              | 590 | 
                          650, ' ', '0',  | 
            
            
              | 591 | 
                          0 => '42',  | 
            
            
              | 592 | 
                          a => 'Computer programming.',  | 
            
            
              | 593 | 
                          9 => '462',  | 
            
            
              | 594 | 
                      ),  | 
            
            
              | 595 | 
                      MARC::Field->new(  | 
            
            
              | 596 | 
                          600, ' ', ' ',  | 
            
            
              | 597 | 
                          0 => 'TestUpdated',  | 
            
            
              | 598 | 
                      ),  | 
            
            
              | 599 | 
                      MARC::Field->new(  | 
            
            
              | 600 | 
                          100, ' ', ' ',  | 
            
            
              | 601 | 
                          0 => 'TestUpdated',  | 
            
            
              | 602 | 
                      ),  | 
            
            
              | 603 | 
                      MARC::Field->new(  | 
            
            
              | 604 | 
                          700, '1', '4',  | 
            
            
              | 605 | 
                          0 => '12345',  | 
            
            
              | 606 | 
                          a => 'The art of computer programming',  | 
            
            
              | 607 | 
                          c => 'Donald E. Knuth.',  | 
            
            
              | 608 | 
                      ),  | 
            
            
              | 609 | 
                  );  | 
            
            
              | 610 | 
                  $record->append_fields(@fields);  | 
            
            
              | 611 | 
                  return $record;  | 
            
            
              | 612 | 
              }  | 
            
            
              | 613 | 
               | 
            
            
              | 614 | 
              $record = new_record_0();  | 
            
            
              | 615 | 
              is( ModifyRecordWithTemplate( $template_id, $record ), undef, "The ModifyRecordWithTemplate returns undef" );  | 
            
            
              | 616 | 
               | 
            
            
              | 617 | 
              $template_id = AddModificationTemplate("template_test_subfield_0"); | 
            
            
              | 618 | 
              like( $template_id, qr|^\d+$|, "new template returns an id" );  | 
            
            
              | 619 | 
               | 
            
            
              | 620 | 
              # Delete subfield 100$0  | 
            
            
              | 621 | 
              is( AddModificationTemplateAction(  | 
            
            
              | 622 | 
                  $template_id, 'delete_field', 0,  | 
            
            
              | 623 | 
                  '100', '0', '', '', '',  | 
            
            
              | 624 | 
                  '', '', '',  | 
            
            
              | 625 | 
                  '', '', '', '', '', '',  | 
            
            
              | 626 | 
                  'Action 1: Delete subfield 100$0'  | 
            
            
              | 627 | 
              ), 1, 'Action 1: Delete subfield 100$0');  | 
            
            
              | 628 | 
               | 
            
            
              | 629 | 
              # Add new subfield 100$0 with value "Test"  | 
            
            
              | 630 | 
              is( AddModificationTemplateAction(  | 
            
            
              | 631 | 
                  $template_id, 'add_field', 0,  | 
            
            
              | 632 | 
                  '100', '0', 'Test', '', '',  | 
            
            
              | 633 | 
                  '', '', '',  | 
            
            
              | 634 | 
                  '', '', '', '', '', '',  | 
            
            
              | 635 | 
                  'Action 2: Add new subfield 100$0 with value "Test"'  | 
            
            
              | 636 | 
              ), 1, 'Action 2: Add new subfield 100$0');  | 
            
            
              | 637 | 
               | 
            
            
              | 638 | 
              # Update existing or add new subfield 100$0 with value "TestUpdated"  | 
            
            
              | 639 | 
              is( AddModificationTemplateAction(  | 
            
            
              | 640 | 
                  $template_id, 'update_field', 0,  | 
            
            
              | 641 | 
                  '100', '0', 'TestUpdated', '', '',  | 
            
            
              | 642 | 
                  '', '', '',  | 
            
            
              | 643 | 
                  '', '', '', '', '', '',  | 
            
            
              | 644 | 
                  'Action 3: Update existing or add new subfield 100$0 with value "TestUpdated"'  | 
            
            
              | 645 | 
              ), 1, 'Action 3: Update existing or add new subfield 100$0 with value "TestUpdated"');  | 
            
            
              | 646 | 
               | 
            
            
              | 647 | 
              # Move subfield 100$0 to 600$0  | 
            
            
              | 648 | 
              is( AddModificationTemplateAction(  | 
            
            
              | 649 | 
                  $template_id, 'move_field', 0,  | 
            
            
              | 650 | 
                  '100', '0', '', '600', '0',  | 
            
            
              | 651 | 
                  '', '', '',  | 
            
            
              | 652 | 
                  '', '', '', '', '', '',  | 
            
            
              | 653 | 
                  'Action 4: Move subfield 100$0 to 600$0'  | 
            
            
              | 654 | 
              ), 1, 'Action 4: Move subfield 100$0 to 600$0');  | 
            
            
              | 655 | 
               | 
            
            
              | 656 | 
              # Copy subfield 600$0 to 100$0  | 
            
            
              | 657 | 
              is( AddModificationTemplateAction(  | 
            
            
              | 658 | 
                  $template_id, 'copy_field', 0,  | 
            
            
              | 659 | 
                  '600', '0', '', '100', '0',  | 
            
            
              | 660 | 
                  '', '', '',  | 
            
            
              | 661 | 
                  '', '', '', '', '', '',  | 
            
            
              | 662 | 
                  'Action 5: Copy subfield 600$0 to 100$0'  | 
            
            
              | 663 | 
              ), 1, 'Action 5: Copy subfield 600$0 to 100$0');  | 
            
            
              | 664 | 
               | 
            
            
              | 665 | 
              # Copy and replace subfield 245$0 to 700$0  | 
            
            
              | 666 | 
              is( AddModificationTemplateAction(  | 
            
            
              | 667 | 
                  $template_id, 'copy_and_replace_field', 0,  | 
            
            
              | 668 | 
                  '245', '0', '', '700', '0',  | 
            
            
              | 669 | 
                  '', '', '',  | 
            
            
              | 670 | 
                  '', '', '', '', '', '',  | 
            
            
              | 671 | 
                  'Action 6: Copy and replace subfield 245$0 to 700$0'  | 
            
            
              | 672 | 
              ), 1, 'Action 6: Copy and replace subfield 245$0 to 700$0');  | 
            
            
              | 673 | 
               | 
            
            
              | 674 | 
              my @actions_0 = GetModificationTemplateActions( $template_id );  | 
            
            
              | 675 | 
              is( @actions_0, 6, "6 actions are inserted");  | 
            
            
              | 676 | 
               | 
            
            
              | 677 | 
              ModifyRecordWithTemplate( $template_id, $record );  | 
            
            
              | 678 | 
              my $expected_record_0 = expected_record_0();  | 
            
            
              | 679 | 
              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' );  |