| 
      
            Lines 4-10
          
      
      
        Link Here
      
     | 
  
        
          | 4 | 
           | 
          4 | 
           | 
        
        
          | 5 | 
          use Modern::Perl;  | 
          5 | 
          use Modern::Perl;  | 
        
        
          | 6 | 
           | 
          6 | 
           | 
        
          
            
              | 7 | 
              use Test::More tests => 2;  | 
              7 | 
              use Test::More tests => 3;  | 
            
        
          | 8 | 
           | 
          8 | 
           | 
        
        
          | 9 | 
          use MARC::Record;  | 
          9 | 
          use MARC::Record;  | 
        
        
          | 10 | 
          use Test::MockModule;  | 
          10 | 
          use Test::MockModule;  | 
        
  
    | 
      
            Lines 77-82
          subtest 'Test merge A1 to A2 (withing same authtype)' => sub {
      
      
        Link Here
      
     | 
  
        
          | 77 | 
                  'Check biblio2 609$a' );  | 
          77 | 
                  'Check biblio2 609$a' );  | 
        
        
          | 78 | 
          };  | 
          78 | 
          };  | 
        
        
          | 79 | 
           | 
          79 | 
           | 
        
            
               | 
               | 
              80 | 
              subtest 'Test merge A1 to modified A1' => sub { | 
            
            
              | 81 | 
              # Tests originate from bug 11700  | 
            
            
              | 82 | 
                  plan tests => 4;  | 
            
            
              | 83 | 
               | 
            
            
              | 84 | 
                  $dbh->do("INSERT IGNORE INTO marc_subfield_structure(tagfield, tagsubfield, liblibrarian, libopac, repeatable, mandatory, kohafield, tab, authorised_value, authtypecode, value_builder, isurl, hidden, frameworkcode, seealso, link, defaultvalue) VALUES('109', 'a', 'Personal name', 'Personal name', 0, 0, '', 6, '', 'TEST_PERSO', '', NULL, 0, '', '', '', NULL)"); | 
            
            
              | 85 | 
                  $dbh->do("UPDATE marc_subfield_structure SET authtypecode = 'TEST_PERSO' WHERE tagfield='109' AND tagsubfield='a' AND frameworkcode='';"); | 
            
            
              | 86 | 
               | 
            
            
              | 87 | 
                  my $auth1old = MARC::Record->new;  | 
            
            
              | 88 | 
                  $auth1old->append_fields( MARC::Field->new( '109', '0', '0', 'a' => 'Bruce Wayne' ));  | 
            
            
              | 89 | 
                  my $auth1new = $auth1old->clone;  | 
            
            
              | 90 | 
                  $auth1new->field('109')->update( a => 'Batman' ); | 
            
            
              | 91 | 
                  my $authid1 = AddAuthority( $auth1new, undef, 'TEST_PERSO' );  | 
            
            
              | 92 | 
               | 
            
            
              | 93 | 
                  my $MARC1 = MARC::Record->new();  | 
            
            
              | 94 | 
                  $MARC1->append_fields( MARC::Field->new( '245', '', '', 'a' => 'From the depths' ));  | 
            
            
              | 95 | 
                  $MARC1->append_fields( MARC::Field->new( '109', '', '', 'a' => 'Bruce Wayne', 'b' => '2014', '9' => $authid1 ));  | 
            
            
              | 96 | 
                  my $MARC2 = MARC::Record->new();  | 
            
            
              | 97 | 
                  $MARC2->append_fields( MARC::Field->new( '245', '', '', 'a' => 'All the way to heaven' ));  | 
            
            
              | 98 | 
                  $MARC2->append_fields( MARC::Field->new( '109', '', '', 'a' => 'Batman', '9' => $authid1 ));  | 
            
            
              | 99 | 
                  my ( $biblionumber1 ) = AddBiblio( $MARC1, '');  | 
            
            
              | 100 | 
                  my ( $biblionumber2 ) = AddBiblio( $MARC2, '');  | 
            
            
              | 101 | 
               | 
            
            
              | 102 | 
                  @zebrarecords = ( $MARC1, $MARC2 );  | 
            
            
              | 103 | 
                  $index = 0;  | 
            
            
              | 104 | 
               | 
            
            
              | 105 | 
                  my $rv = C4::AuthoritiesMarc::merge( $authid1, $auth1old, $authid1, $auth1new );  | 
            
            
              | 106 | 
                  is( $rv, 2, 'Both records are updated now' );  | 
            
            
              | 107 | 
               | 
            
            
              | 108 | 
                  my $biblio1 = GetMarcBiblio($biblionumber1);  | 
            
            
              | 109 | 
                  my $biblio2 = GetMarcBiblio($biblionumber1);  | 
            
            
              | 110 | 
               | 
            
            
              | 111 | 
                  my $auth_field = $auth1new->field(109)->subfield('a'); | 
            
            
              | 112 | 
                  is( $auth_field, $biblio1->field(109)->subfield('a'), 'Record1 values updated correctly' ); | 
            
            
              | 113 | 
                  is( $auth_field, $biblio2->field(109)->subfield('a'), 'Record2 values updated correctly' ); | 
            
            
              | 114 | 
               | 
            
            
              | 115 | 
                  # TODO Following test will change when we improve merge  | 
            
            
              | 116 | 
                  # Will depend on a preference  | 
            
            
              | 117 | 
                  is( $biblio1->field(109)->subfield('b'), $MARC1->field(109)->subfield('b'), 'Record not overwritten while merging'); | 
            
            
              | 118 | 
              };  | 
            
            
              | 119 | 
               | 
            
        
          | 80 | 
          sub set_mocks { | 
          120 | 
          sub set_mocks { | 
        
        
          | 81 | 
              # Mock ZOOM objects: They do nothing actually  | 
          121 | 
              # Mock ZOOM objects: They do nothing actually  | 
        
        
          | 82 | 
              # Get new_record_from_zebra to return the records  | 
          122 | 
              # Get new_record_from_zebra to return the records  | 
        
            
              | 83 | 
              -   | 
               | 
               |