Lines 67-80
subtest 'Test merge A1 to A2 (withing same authtype)' => sub {
Link Here
|
67 |
|
67 |
|
68 |
# Check the results |
68 |
# Check the results |
69 |
my $newbiblio1 = GetMarcBiblio($biblionumber1); |
69 |
my $newbiblio1 = GetMarcBiblio($biblionumber1); |
70 |
compare_field_count( $biblio1, $newbiblio1, 1 ); |
70 |
compare_field_count( $biblio1, $newbiblio1 ); |
71 |
compare_field_order( $biblio1, $newbiblio1, 1 ); |
71 |
compare_field_order( $biblio1, $newbiblio1 ); |
72 |
is( $newbiblio1->subfield('609', '9'), $authid1, 'Check biblio1 609$9' ); |
72 |
is( $newbiblio1->subfield('609', '9'), $authid1, 'Check biblio1 609$9' ); |
73 |
is( $newbiblio1->subfield('609', 'a'), 'George Orwell', |
73 |
is( $newbiblio1->subfield('609', 'a'), 'George Orwell', |
74 |
'Check biblio1 609$a' ); |
74 |
'Check biblio1 609$a' ); |
75 |
my $newbiblio2 = GetMarcBiblio($biblionumber2); |
75 |
my $newbiblio2 = GetMarcBiblio($biblionumber2); |
76 |
compare_field_count( $biblio2, $newbiblio2, 1 ); |
76 |
compare_field_count( $biblio2, $newbiblio2 ); |
77 |
compare_field_order( $biblio2, $newbiblio2, 1 ); |
77 |
compare_field_order( $biblio2, $newbiblio2 ); |
78 |
is( $newbiblio2->subfield('609', '9'), $authid1, 'Check biblio2 609$9' ); |
78 |
is( $newbiblio2->subfield('609', '9'), $authid1, 'Check biblio2 609$9' ); |
79 |
is( $newbiblio2->subfield('609', 'a'), 'George Orwell', |
79 |
is( $newbiblio2->subfield('609', 'a'), 'George Orwell', |
80 |
'Check biblio2 609$a' ); |
80 |
'Check biblio2 609$a' ); |
Lines 110-121
subtest 'Test merge A1 to modified A1' => sub {
Link Here
|
110 |
|
110 |
|
111 |
#Check the results |
111 |
#Check the results |
112 |
my $biblio1 = GetMarcBiblio($biblionumber1); |
112 |
my $biblio1 = GetMarcBiblio($biblionumber1); |
113 |
compare_field_count( $MARC1, $biblio1, 1 ); |
113 |
compare_field_count( $MARC1, $biblio1 ); |
114 |
compare_field_order( $MARC1, $biblio1, 1 ); |
114 |
compare_field_order( $MARC1, $biblio1 ); |
115 |
is( $auth1new->field(109)->subfield('a'), $biblio1->field(109)->subfield('a'), 'Record1 values updated correctly' ); |
115 |
is( $auth1new->field(109)->subfield('a'), $biblio1->field(109)->subfield('a'), 'Record1 values updated correctly' ); |
116 |
my $biblio2 = GetMarcBiblio($biblionumber1); |
116 |
my $biblio2 = GetMarcBiblio($biblionumber1); |
117 |
compare_field_count( $MARC2, $biblio2, 1 ); |
117 |
compare_field_count( $MARC2, $biblio2 ); |
118 |
compare_field_order( $MARC2, $biblio2, 1 ); |
118 |
compare_field_order( $MARC2, $biblio2 ); |
119 |
is( $auth1new->field(109)->subfield('a'), $biblio2->field(109)->subfield('a'), 'Record2 values updated correctly' ); |
119 |
is( $auth1new->field(109)->subfield('a'), $biblio2->field(109)->subfield('a'), 'Record2 values updated correctly' ); |
120 |
# This is only true in loose mode: |
120 |
# This is only true in loose mode: |
121 |
is( $biblio1->field(109)->subfield('b'), $MARC1->field(109)->subfield('b'), 'Subfield not overwritten in loose mode'); |
121 |
is( $biblio1->field(109)->subfield('b'), $MARC1->field(109)->subfield('b'), 'Subfield not overwritten in loose mode'); |
Lines 135-141
subtest 'Test merge A1 to B1 (changing authtype)' => sub {
Link Here
|
135 |
# Tests were aimed for bug 9988, moved to 17909 in adjusted form |
135 |
# Tests were aimed for bug 9988, moved to 17909 in adjusted form |
136 |
# Would not encourage this type of merge, but we should test what we offer |
136 |
# Would not encourage this type of merge, but we should test what we offer |
137 |
# The merge routine still needs the fixes on bug 17913 |
137 |
# The merge routine still needs the fixes on bug 17913 |
138 |
plan tests => 8; |
138 |
plan tests => 12; |
139 |
|
139 |
|
140 |
# create two auth recs of different type |
140 |
# create two auth recs of different type |
141 |
my $auth1 = MARC::Record->new; |
141 |
my $auth1 = MARC::Record->new; |
Lines 168-176
subtest 'Test merge A1 to B1 (changing authtype)' => sub {
Link Here
|
168 |
|
168 |
|
169 |
# Get new marc record for compares |
169 |
# Get new marc record for compares |
170 |
my $newbiblio = C4::Biblio::GetMarcBiblio( $biblionumber ); |
170 |
my $newbiblio = C4::Biblio::GetMarcBiblio( $biblionumber ); |
171 |
compare_field_count( $oldbiblio, $newbiblio, 1 ); |
171 |
compare_field_count( $oldbiblio, $newbiblio ); |
172 |
# TODO The following test will still fail; refined after 17913 |
172 |
# Exclude 109/609 and 112/612 in comparing order |
173 |
compare_field_order( $oldbiblio, $newbiblio, 0 ); |
173 |
compare_field_order( $oldbiblio, $newbiblio, |
|
|
174 |
{ '109' => 1, '112' => 1, '609' => 1, '612' => 1 }, |
175 |
); |
176 |
# Check position of 612s in the new record |
177 |
my $full_order = join q/,/, map { $_->tag } $newbiblio->fields; |
178 |
is( $full_order =~ /611(,612){3}/, 1, 'Check position of all 612s' ); |
174 |
|
179 |
|
175 |
# Check some fields |
180 |
# Check some fields |
176 |
is( $newbiblio->field('003')->data, |
181 |
is( $newbiblio->field('003')->data, |
Lines 184-192
subtest 'Test merge A1 to B1 (changing authtype)' => sub {
Link Here
|
184 |
is( $newbiblio->subfield( '112', 'c' ), |
189 |
is( $newbiblio->subfield( '112', 'c' ), |
185 |
$auth2->subfield( '112', 'c' ), 'Check new 112c' ); |
190 |
$auth2->subfield( '112', 'c' ), 'Check new 112c' ); |
186 |
|
191 |
|
187 |
#TODO Check the new 612s (after fix on 17913, they are 112s now) |
192 |
# Check the original 612 |
188 |
is( $newbiblio->subfield( '612', 'a' ), |
193 |
is( ( $newbiblio->field('612') )[0]->subfield( 'a' ), |
189 |
$oldbiblio->subfield( '612', 'a' ), 'Check untouched 612a' ); |
194 |
$oldbiblio->subfield( '612', 'a' ), 'Check untouched 612a' ); |
|
|
195 |
# Check second 612 |
196 |
is( ( $newbiblio->field('612') )[1]->subfield( 'a' ), |
197 |
$auth2->subfield( '112', 'a' ), 'Check second touched 612a' ); |
198 |
# Check second new 612ax (in LOOSE mode) |
199 |
is( ( $newbiblio->field('612') )[2]->subfield( 'a' ), |
200 |
$auth2->subfield( '112', 'a' ), 'Check touched 612a' ); |
201 |
is( ( $newbiblio->field('612') )[2]->subfield( 'x' ), |
202 |
( $oldbiblio->field('609') )[1]->subfield('x'), |
203 |
'Check 612x' ); |
190 |
}; |
204 |
}; |
191 |
|
205 |
|
192 |
sub set_mocks { |
206 |
sub set_mocks { |
Lines 243-249
sub modify_framework {
Link Here
|
243 |
}, |
257 |
}, |
244 |
}); |
258 |
}); |
245 |
|
259 |
|
246 |
# Link 112/712 to the second authtype |
260 |
# Link 112/612/712 to the second authtype |
247 |
$builder->build({ |
261 |
$builder->build({ |
248 |
source => 'MarcSubfieldStructure', |
262 |
source => 'MarcSubfieldStructure', |
249 |
value => { |
263 |
value => { |
Lines 256-261
sub modify_framework {
Link Here
|
256 |
$builder->build({ |
270 |
$builder->build({ |
257 |
source => 'MarcSubfieldStructure', |
271 |
source => 'MarcSubfieldStructure', |
258 |
value => { |
272 |
value => { |
|
|
273 |
tagfield => '612', |
274 |
tagsubfield => 'a', |
275 |
authtypecode => $authtype2->{authtypecode}, |
276 |
frameworkcode => '', |
277 |
}, |
278 |
}); |
279 |
$builder->build({ |
280 |
source => 'MarcSubfieldStructure', |
281 |
value => { |
259 |
tagfield => '712', |
282 |
tagfield => '712', |
260 |
tagsubfield => 'a', |
283 |
tagsubfield => 'a', |
261 |
authtypecode => $authtype2->{authtypecode}, |
284 |
authtypecode => $authtype2->{authtypecode}, |
Lines 267-292
sub modify_framework {
Link Here
|
267 |
} |
290 |
} |
268 |
|
291 |
|
269 |
sub compare_field_count { |
292 |
sub compare_field_count { |
270 |
my ( $oldmarc, $newmarc, $pass ) = @_; |
293 |
my ( $oldmarc, $newmarc ) = @_; |
271 |
my $t; |
294 |
my $t; |
272 |
if( $pass ) { |
295 |
is( scalar $newmarc->fields, $t = $oldmarc->fields, "Number of fields still equal to $t" ); |
273 |
is( scalar $newmarc->fields, $t = $oldmarc->fields, "Number of fields still equal to $t" ); |
|
|
274 |
} else { |
275 |
isnt( scalar $newmarc->fields, $t = $oldmarc->fields, "Number of fields not equal to $t" ); |
276 |
} |
277 |
} |
296 |
} |
278 |
|
297 |
|
279 |
sub compare_field_order { |
298 |
sub compare_field_order { |
280 |
my ( $oldmarc, $newmarc, $pass ) = @_; |
299 |
my ( $oldmarc, $newmarc, $exclude ) = @_; |
281 |
if( $pass ) { |
300 |
$exclude //= {}; |
282 |
is( ( join q/,/, map { $_->tag; } $newmarc->fields ), |
301 |
my @oldfields = map { $exclude->{$_->tag} ? () : $_->tag } $oldmarc->fields; |
283 |
( join q/,/, map { $_->tag; } $oldmarc->fields ), |
302 |
my @newfields = map { $exclude->{$_->tag} ? () : $_->tag } $newmarc->fields; |
284 |
'Order of fields unchanged' ); |
303 |
is( ( join q/,/, @newfields ), ( join q/,/, @oldfields ), |
285 |
} else { |
304 |
'Order of fields unchanged' ); |
286 |
isnt( ( join q/,/, map { $_->tag; } $newmarc->fields ), |
|
|
287 |
( join q/,/, map { $_->tag; } $oldmarc->fields ), |
288 |
'Order of fields changed' ); |
289 |
} |
290 |
} |
305 |
} |
291 |
|
306 |
|
292 |
$schema->storage->txn_rollback; |
307 |
$schema->storage->txn_rollback; |
293 |
- |
|
|