From 525b1692f3d19268f0269f9ccf3bee6ef464c3eb 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 Signed-off-by: Kyle M Hall --- 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 f53e13d..48d9c40 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 8449469..3e205c9 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