Bug 35989: (QA follow-up) Add test and limit variable scope
Before this patch if a record had a 751 and a 781 you could have fields repeated.
This patch reduces the scope of the fields to subdivision variable as it is only used in processing 7xx
fields and should not be shared between fields.
I also add unit tests
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 95f2aecc1b)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
6dfb1dd931
commit
4ca639a5f6
|
|
@ -1015,8 +1015,7 @@ sub BuildSummary {
|
|||
use C4::Heading::MARC21;
|
||||
my $handler = C4::Heading::MARC21->new();
|
||||
my $subfields_to_report;
|
||||
my $subfields_to_subdivision = "";
|
||||
my $delimiter = C4::Context->preference('AuthoritySeparator');
|
||||
my $delimiter = C4::Context->preference('AuthoritySeparator');
|
||||
|
||||
foreach my $field ($record->field('1..')) {
|
||||
my $tag = $field->tag();
|
||||
|
|
@ -1095,7 +1094,8 @@ sub BuildSummary {
|
|||
push @notes, { note => $field->as_string(), field => $field->tag() };
|
||||
}
|
||||
|
||||
foreach my $field ( $record->field('7..') ) {
|
||||
foreach my $field ( $record->field('7..') ) {
|
||||
my $subfields_to_subdivision;
|
||||
my $tag = $field->tag();
|
||||
|
||||
if ( $tag eq '700' ) {
|
||||
|
|
|
|||
|
|
@ -41,8 +41,10 @@ $module->mock('GetAuthority', sub {
|
|||
$record->add_fields(
|
||||
[ '001', '2' ],
|
||||
[ '151', ' ', ' ', a => 'New York (State)' ],
|
||||
[ '551', ' ', ' ', a => 'United States', w => 'g', 9 => '1' ]
|
||||
);
|
||||
[ '551', ' ', ' ', a => 'United States', w => 'g', 9 => '1' ],
|
||||
[ '751', ' ', ' ', a => 'United States', w => 'g', 9 => '1' ],
|
||||
[ '781', ' ', ' ', a => 'New York', x => 'General subdivision', 9 => '1' ]
|
||||
);
|
||||
} elsif ($authid eq '3') {
|
||||
$record->add_fields(
|
||||
[ '001', '3' ],
|
||||
|
|
@ -151,14 +153,25 @@ my $expected_marc21_summary = {
|
|||
'type' => 'broader'
|
||||
}
|
||||
],
|
||||
'seefrom' => [],
|
||||
'label' => 'Geographic Name',
|
||||
'type' => 'Geographic Name',
|
||||
'equalterm' => []
|
||||
'equalterm' => [
|
||||
{
|
||||
'field' => '751',
|
||||
'hemain' => 'United States',
|
||||
'heading' => 'United States'
|
||||
},
|
||||
{
|
||||
'hemain' => undef,
|
||||
'field' => '781',
|
||||
'heading' => 'General subdivision'
|
||||
}
|
||||
],
|
||||
'seefrom' => [],
|
||||
'label' => 'Geographic Name',
|
||||
'type' => 'Geographic Name',
|
||||
};
|
||||
|
||||
is_deeply(
|
||||
BuildSummary(C4::AuthoritiesMarc::GetAuthority(2), 2, 'GEOGR_NAME'),
|
||||
BuildSummary( C4::AuthoritiesMarc::GetAuthority(2), 2, 'GEOGR_NAME' ),
|
||||
$expected_marc21_summary,
|
||||
'test BuildSummary for MARC21'
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue