|
Lines 60-66
subtest 'Test merge A1 to A2 (within same authtype)' => sub {
Link Here
|
| 60 |
# Time to merge |
60 |
# Time to merge |
| 61 |
@zebrarecords = ( $biblio1, $biblio2 ); |
61 |
@zebrarecords = ( $biblio1, $biblio2 ); |
| 62 |
$index = 0; |
62 |
$index = 0; |
| 63 |
my $rv = C4::AuthoritiesMarc::merge( $authid2, $auth2, $authid1, $auth1 ); |
63 |
my $rv = C4::AuthoritiesMarc::merge({ mergefrom => $authid2, MARCfrom => $auth2, mergeto => $authid1, MARCto => $auth1 }); |
| 64 |
is( $rv, 1, 'We expect one biblio record (out of two) to be updated' ); |
64 |
is( $rv, 1, 'We expect one biblio record (out of two) to be updated' ); |
| 65 |
|
65 |
|
| 66 |
# Check the results |
66 |
# Check the results |
|
Lines 105-111
subtest 'Test merge A1 to modified A1, test strict mode' => sub {
Link Here
|
| 105 |
@zebrarecords = ( $MARC1, $MARC2 ); |
105 |
@zebrarecords = ( $MARC1, $MARC2 ); |
| 106 |
$index = 0; |
106 |
$index = 0; |
| 107 |
t::lib::Mocks::mock_preference('AuthorityMergeMode', 'loose'); |
107 |
t::lib::Mocks::mock_preference('AuthorityMergeMode', 'loose'); |
| 108 |
my $rv = C4::AuthoritiesMarc::merge( $authid1, $auth1old, $authid1, $auth1new ); |
108 |
my $rv = C4::AuthoritiesMarc::merge({ mergefrom => $authid1, MARCfrom => $auth1old, mergeto => $authid1, MARCto => $auth1new }); |
| 109 |
is( $rv, 2, 'Both records are updated now' ); |
109 |
is( $rv, 2, 'Both records are updated now' ); |
| 110 |
|
110 |
|
| 111 |
#Check the results |
111 |
#Check the results |
|
Lines 125-131
subtest 'Test merge A1 to modified A1, test strict mode' => sub {
Link Here
|
| 125 |
ModBiblio( $MARC1, $biblionumber1, '' ); |
125 |
ModBiblio( $MARC1, $biblionumber1, '' ); |
| 126 |
@zebrarecords = ( $MARC1 ); |
126 |
@zebrarecords = ( $MARC1 ); |
| 127 |
$index = 0; |
127 |
$index = 0; |
| 128 |
$rv = C4::AuthoritiesMarc::merge( $authid1, $auth1old, $authid1, $auth1new ); |
128 |
$rv = C4::AuthoritiesMarc::merge({ mergefrom => $authid1, MARCfrom => $auth1old, mergeto => $authid1, MARCto => $auth1new }); |
| 129 |
$biblio1 = GetMarcBiblio($biblionumber1); |
129 |
$biblio1 = GetMarcBiblio($biblionumber1); |
| 130 |
is( $biblio1->field(109)->subfield('b'), undef, 'Subfield overwritten in strict mode' ); |
130 |
is( $biblio1->field(109)->subfield('b'), undef, 'Subfield overwritten in strict mode' ); |
| 131 |
compare_fields( $MARC1, $biblio1, { 609 => 1 }, 'count' ); |
131 |
compare_fields( $MARC1, $biblio1, { 609 => 1 }, 'count' ); |
|
Lines 172-178
subtest 'Test merge A1 to B1 (changing authtype)' => sub {
Link Here
|
| 172 |
# Time to merge |
172 |
# Time to merge |
| 173 |
@zebrarecords = ( $marc ); |
173 |
@zebrarecords = ( $marc ); |
| 174 |
$index = 0; |
174 |
$index = 0; |
| 175 |
my $retval = C4::AuthoritiesMarc::merge( $authid1, $auth1, $authid2, $auth2 ); |
175 |
my $retval = C4::AuthoritiesMarc::merge({ mergefrom => $authid1, MARCfrom => $auth1, mergeto => $authid2, MARCto => $auth2 }); |
| 176 |
is( $retval, 1, 'We touched only one biblio' ); |
176 |
is( $retval, 1, 'We touched only one biblio' ); |
| 177 |
|
177 |
|
| 178 |
# Get new marc record for compares |
178 |
# Get new marc record for compares |
|
Lines 234-240
subtest 'Merging authorities should handle deletes (BZ 18070)' => sub {
Link Here
|
| 234 |
my ( $biblionumber ) = C4::Biblio::AddBiblio( $bib1, '' ); |
234 |
my ( $biblionumber ) = C4::Biblio::AddBiblio( $bib1, '' ); |
| 235 |
@zebrarecords = ( $bib1 ); |
235 |
@zebrarecords = ( $bib1 ); |
| 236 |
$index = 0; |
236 |
$index = 0; |
| 237 |
DelAuthority( $authid1 ); # this triggers a merge call |
237 |
DelAuthority({ authid => $authid1 }); # this triggers a merge call |
| 238 |
|
238 |
|
| 239 |
# See what happened in the biblio record |
239 |
# See what happened in the biblio record |
| 240 |
my $marc1 = C4::Biblio::GetMarcBiblio( $biblionumber ); |
240 |
my $marc1 = C4::Biblio::GetMarcBiblio( $biblionumber ); |
|
Lines 256-262
subtest 'Merging authorities should handle deletes (BZ 18070)' => sub {
Link Here
|
| 256 |
C4::Context->dbh->do( "DELETE FROM auth_header WHERE authid=?", undef, $authid1 ); |
256 |
C4::Context->dbh->do( "DELETE FROM auth_header WHERE authid=?", undef, $authid1 ); |
| 257 |
@zebrarecords = ( $marc1 ); |
257 |
@zebrarecords = ( $marc1 ); |
| 258 |
$index = 0; |
258 |
$index = 0; |
| 259 |
merge( $authid1, undef ); |
259 |
merge({ mergefrom => $authid1 }); |
| 260 |
# Final check |
260 |
# Final check |
| 261 |
$marc1 = C4::Biblio::GetMarcBiblio( $biblionumber ); |
261 |
$marc1 = C4::Biblio::GetMarcBiblio( $biblionumber ); |
| 262 |
is( $marc1->field('609'), undef, 'Merge removed the 609 again even after deleting the authority record' ); |
262 |
is( $marc1->field('609'), undef, 'Merge removed the 609 again even after deleting the authority record' ); |