From cacae5910456858f7f89c5215e8710cd87d543a8 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Mon, 9 Jun 2014 09:55:28 +0200 Subject: [PATCH] Bug 8064: Fix unit tests for createMergeHash Signed-off-by: Bernardo Gonzalez Kriegel --- t/Koha_MetadataRecord.t | 58 ++++++++++++++++++++----------------------------- t/Koha_Util_MARC.t | 58 ++++++++++++++++++++----------------------------- 2 files changed, 46 insertions(+), 70 deletions(-) diff --git a/t/Koha_MetadataRecord.t b/t/Koha_MetadataRecord.t index 53f25a1..473e7a6 100755 --- a/t/Koha_MetadataRecord.t +++ b/t/Koha_MetadataRecord.t @@ -39,55 +39,43 @@ is(ref($record), 'Koha::MetadataRecord', 'Created valid Koha::MetadataRecord obj my $samplehash = [ { - 'field' => [ - { - 'value' => '1234', - 'tag' => '001', - } - ] + 'value' => '1234', + 'tag' => '001', }, { - 'field' => [ + 'subfield' => [ { - 'subfield' => [ - { - 'value' => 'Cooking', - 'subtag' => 'a' - } - ], - 'indicator2' => ' ', - 'tag' => 150, - 'indicator1' => ' ', + 'value' => 'Cooking', + 'subtag' => 'a' } - ] + ], + 'indicator2' => ' ', + 'tag' => 150, + 'indicator1' => ' ', }, { - 'field' => [ + 'subfield' => [ + { + 'value' => 'Cookery', + 'subtag' => 'a' + }, { - 'subfield' => [ - { - 'value' => 'Cookery', - 'subtag' => 'a' - }, - { - 'value' => 'Instructional manuals', - 'subtag' => 'z' - } - ], - 'indicator2' => ' ', - 'tag' => 450, - 'indicator1' => ' ', + 'value' => 'Instructional manuals', + 'subtag' => 'z' } - ] + ], + 'indicator2' => ' ', + 'tag' => 450, + 'indicator1' => ' ', } ]; my $hash = $record->createMergeHash(); my %fieldkeys; foreach my $field (@$hash) { - $fieldkeys{delete $field->{'field'}->[0]->{'key'}}++; - if (defined $field->{'field'}->[0]->{'subfield'}) { - foreach my $subfield (@{$field->{'field'}->[0]->{'subfield'}}) { + $fieldkeys{delete $field->{'key'}}++; + if (defined $field->{'subfield'}) { + foreach my $subfield (@{$field->{'subfield'}}) { $fieldkeys{delete $subfield->{'subkey'}}++; } } diff --git a/t/Koha_Util_MARC.t b/t/Koha_Util_MARC.t index daf91f0..2859647 100755 --- a/t/Koha_Util_MARC.t +++ b/t/Koha_Util_MARC.t @@ -38,55 +38,43 @@ $marcrecord->add_fields( ); my $samplehash = [ { - 'field' => [ - { - 'value' => '1234', - 'tag' => '001', - } - ] + 'value' => '1234', + 'tag' => '001', }, { - 'field' => [ + 'subfield' => [ { - 'subfield' => [ - { - 'value' => 'Cooking', - 'subtag' => 'a' - } - ], - 'indicator2' => ' ', - 'tag' => 150, - 'indicator1' => ' ', + 'value' => 'Cooking', + 'subtag' => 'a' } - ] + ], + 'indicator2' => ' ', + 'tag' => 150, + 'indicator1' => ' ', }, { - 'field' => [ + 'subfield' => [ + { + 'value' => 'Cookery', + 'subtag' => 'a' + }, { - 'subfield' => [ - { - 'value' => 'Cookery', - 'subtag' => 'a' - }, - { - 'value' => 'Instructional manuals', - 'subtag' => 'z' - } - ], - 'indicator2' => ' ', - 'tag' => 450, - 'indicator1' => ' ', + 'value' => 'Instructional manuals', + 'subtag' => 'z' } - ] + ], + 'indicator2' => ' ', + 'tag' => 450, + 'indicator1' => ' ', } ]; my $hash = Koha::Util::MARC::createMergeHash($marcrecord); my %fieldkeys; foreach my $field (@$hash) { - $fieldkeys{delete $field->{'field'}->[0]->{'key'}}++; - if (defined $field->{'field'}->[0]->{'subfield'}) { - foreach my $subfield (@{$field->{'field'}->[0]->{'subfield'}}) { + $fieldkeys{delete $field->{'key'}}++; + if (defined $field->{'subfield'}) { + foreach my $subfield (@{$field->{'subfield'}}) { $fieldkeys{delete $subfield->{'subkey'}}++; } } -- 1.9.1