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 commit95f2aecc1b) Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> (cherry picked from commit4ca639a5f6) Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
1b95828e79
commit
4118a526ba
|
|
@ -999,8 +999,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();
|
||||
|
|
@ -1079,7 +1078,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