View | Details | Raw Unified | Return to bug 8064
Collapse All | Expand All

(-)a/t/Koha_MetadataRecord.t (-35 / +23 lines)
Lines 39-93 is(ref($record), 'Koha::MetadataRecord', 'Created valid Koha::MetadataRecord obj Link Here
39
39
40
my $samplehash = [
40
my $samplehash = [
41
    {
41
    {
42
        'field' => [
42
        'value' => '1234',
43
            {
43
        'tag'   => '001',
44
                'value' => '1234',
45
                'tag'   => '001',
46
            }
47
        ]
48
    },
44
    },
49
    {
45
    {
50
        'field' => [
46
        'subfield' => [
51
            {
47
            {
52
                'subfield' => [
48
                'value'  => 'Cooking',
53
                    {
49
                'subtag' => 'a'
54
                        'value'  => 'Cooking',
55
                        'subtag' => 'a'
56
                    }
57
                ],
58
                'indicator2' => ' ',
59
                'tag'        => 150,
60
                'indicator1' => ' ',
61
            }
50
            }
62
        ]
51
        ],
52
        'indicator2' => ' ',
53
        'tag'        => 150,
54
        'indicator1' => ' ',
63
    },
55
    },
64
    {
56
    {
65
        'field' => [
57
        'subfield' => [
58
            {
59
                'value'  => 'Cookery',
60
                'subtag' => 'a'
61
            },
66
            {
62
            {
67
                'subfield' => [
63
                'value'  => 'Instructional manuals',
68
                    {
64
                'subtag' => 'z'
69
                        'value'  => 'Cookery',
70
                        'subtag' => 'a'
71
                    },
72
                    {
73
                        'value' => 'Instructional manuals',
74
                        'subtag' => 'z'
75
                    }
76
                ],
77
                'indicator2' => ' ',
78
                'tag'        => 450,
79
                'indicator1' => ' ',
80
            }
65
            }
81
        ]
66
        ],
67
        'indicator2' => ' ',
68
        'tag'        => 450,
69
        'indicator1' => ' ',
82
    }
70
    }
83
];
71
];
84
72
85
my $hash = $record->createMergeHash();
73
my $hash = $record->createMergeHash();
86
my %fieldkeys;
74
my %fieldkeys;
87
foreach my $field (@$hash) {
75
foreach my $field (@$hash) {
88
    $fieldkeys{delete $field->{'field'}->[0]->{'key'}}++;
76
    $fieldkeys{delete $field->{'key'}}++;
89
    if (defined $field->{'field'}->[0]->{'subfield'}) {
77
    if (defined $field->{'subfield'}) {
90
        foreach my $subfield (@{$field->{'field'}->[0]->{'subfield'}}) {
78
        foreach my $subfield (@{$field->{'subfield'}}) {
91
            $fieldkeys{delete $subfield->{'subkey'}}++;
79
            $fieldkeys{delete $subfield->{'subkey'}}++;
92
        }
80
        }
93
    }
81
    }
(-)a/t/Koha_Util_MARC.t (-36 / +23 lines)
Lines 38-92 $marcrecord->add_fields( Link Here
38
        );
38
        );
39
my $samplehash = [
39
my $samplehash = [
40
    {
40
    {
41
        'field' => [
41
        'value' => '1234',
42
            {
42
        'tag'   => '001',
43
                'value' => '1234',
44
                'tag'   => '001',
45
            }
46
        ]
47
    },
43
    },
48
    {
44
    {
49
        'field' => [
45
        'subfield' => [
50
            {
46
            {
51
                'subfield' => [
47
                'value'  => 'Cooking',
52
                    {
48
                'subtag' => 'a'
53
                        'value'  => 'Cooking',
54
                        'subtag' => 'a'
55
                    }
56
                ],
57
                'indicator2' => ' ',
58
                'tag'        => 150,
59
                'indicator1' => ' ',
60
            }
49
            }
61
        ]
50
        ],
51
        'indicator2' => ' ',
52
        'tag'        => 150,
53
        'indicator1' => ' ',
62
    },
54
    },
63
    {
55
    {
64
        'field' => [
56
        'subfield' => [
57
            {
58
                'value'  => 'Cookery',
59
                'subtag' => 'a'
60
            },
65
            {
61
            {
66
                'subfield' => [
62
                'value'  => 'Instructional manuals',
67
                    {
63
                'subtag' => 'z'
68
                        'value'  => 'Cookery',
69
                        'subtag' => 'a'
70
                    },
71
                    {
72
                        'value' => 'Instructional manuals',
73
                        'subtag' => 'z'
74
                    }
75
                ],
76
                'indicator2' => ' ',
77
                'tag'        => 450,
78
                'indicator1' => ' ',
79
            }
64
            }
80
        ]
65
        ],
66
        'indicator2' => ' ',
67
        'tag'        => 450,
68
        'indicator1' => ' ',
81
    }
69
    }
82
];
70
];
83
71
84
my $hash = Koha::Util::MARC::createMergeHash($marcrecord);
72
my $hash = Koha::Util::MARC::createMergeHash($marcrecord);
85
my %fieldkeys;
73
my %fieldkeys;
86
foreach my $field (@$hash) {
74
foreach my $field (@$hash) {
87
    $fieldkeys{delete $field->{'field'}->[0]->{'key'}}++;
75
    $fieldkeys{delete $field->{'key'}}++;
88
    if (defined $field->{'field'}->[0]->{'subfield'}) {
76
    if (defined $field->{'subfield'}) {
89
        foreach my $subfield (@{$field->{'field'}->[0]->{'subfield'}}) {
77
        foreach my $subfield (@{$field->{'subfield'}}) {
90
            $fieldkeys{delete $subfield->{'subkey'}}++;
78
            $fieldkeys{delete $subfield->{'subkey'}}++;
91
        }
79
        }
92
    }
80
    }
93
- 

Return to bug 8064