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

(-)a/C4/Biblio.pm (-2 / +2 lines)
Lines 501-507 sub LinkBibHeadingsToAuthorities { Link Here
501
    $allowrelink = 1 unless defined $allowrelink;
501
    $allowrelink = 1 unless defined $allowrelink;
502
    my $num_headings_changed = 0;
502
    my $num_headings_changed = 0;
503
    foreach my $field ( $bib->fields() ) {
503
    foreach my $field ( $bib->fields() ) {
504
        my $heading = C4::Heading->new_from_bib_field( $field, $frameworkcode );
504
        my $heading = C4::Heading->new_from_field( $field, $frameworkcode );
505
        next unless defined $heading;
505
        next unless defined $heading;
506
506
507
        # check existing $9
507
        # check existing $9
Lines 548-554 sub LinkBibHeadingsToAuthorities { Link Here
548
                    map {
548
                    map {
549
                        $authfield->add_subfields( $_->[0] => $_->[1] )
549
                        $authfield->add_subfields( $_->[0] => $_->[1] )
550
                          if ( $_->[0] =~ /[A-z]/ && $_->[0] ne "a"
550
                          if ( $_->[0] =~ /[A-z]/ && $_->[0] ne "a"
551
                            && C4::Heading::valid_bib_heading_subfield(
551
                            && C4::Heading::valid_heading_subfield(
552
                                $field->tag, $_->[0] )
552
                                $field->tag, $_->[0] )
553
                            );
553
                            );
554
                    } $field->subfields();
554
                    } $field->subfields();
(-)a/C4/Heading.pm (-18 / +16 lines)
Lines 33-39 C4::Heading Link Here
33
=head1 SYNOPSIS
33
=head1 SYNOPSIS
34
34
35
 use C4::Heading;
35
 use C4::Heading;
36
 my $heading = C4::Heading->new_from_bib_field($field, $frameworkcode);
36
 my $heading = C4::Heading->new_from_field($field, $frameworkcode);
37
 my $thesaurus = $heading->thesaurus();
37
 my $thesaurus = $heading->thesaurus();
38
 my $type = $heading->type();
38
 my $type = $heading->type();
39
 my $display_heading = $heading->display_form();
39
 my $display_heading = $heading->display_form();
Lines 46-77 headings found in bibliographic and authority records. Link Here
46
46
47
=head1 METHODS
47
=head1 METHODS
48
48
49
=head2 new_from_bib_field
49
=head2 new_from_field
50
50
51
  my $heading = C4::Heading->new_from_bib_field($field, $frameworkcode, [, $marc_flavour]);
51
  my $heading = C4::Heading->new_from_field($field, $frameworkcode, [, $auth]);
52
52
53
Given a C<MARC::Field> object containing a heading from a 
53
Given a C<MARC::Field> object containing a heading from a 
54
bib record, create a C<C4::Heading> object.
54
bib record, create a C<C4::Heading> object.
55
55
56
The optional second parameter is the MARC flavour (i.e., MARC21
56
The optional third parameter is 'auth' - it is handled as boolean. If supplied we treat the field as an auth record field. Otherwise if it is a bib field. The fields checked are the same in a UNIMARC system and this parameter is ignored
57
or UNIMARC); if this parameter is not supplied, it is
58
taken from the Koha application context.
59
57
60
If the MARC field supplied is not a valid heading, undef
58
If the MARC field supplied is not a valid heading, undef
61
is returned.
59
is returned.
62
60
63
=cut
61
=cut
64
62
65
sub new_from_bib_field {
63
sub new_from_field {
66
    my $class         = shift;
64
    my $class         = shift;
67
    my $field         = shift;
65
    my $field         = shift;
68
    my $frameworkcode = shift;
66
    my $frameworkcode = shift; #FIXME this is not used?
69
    my $marcflavour   = @_ ? shift : C4::Context->preference('marcflavour');
67
    my $auth          = shift;
70
68
    my $marcflavour   = C4::Context->preference('marcflavour');
71
    my $marc_handler = _marc_format_handler($marcflavour);
69
    my $marc_handler = _marc_format_handler($marcflavour);
72
70
73
    my $tag = $field->tag();
71
    my $tag = $field->tag();
74
    return unless $marc_handler->valid_bib_heading_tag( $tag, $frameworkcode );
72
    return unless $marc_handler->valid_heading_tag( $tag, $frameworkcode, $auth );
75
    my $self = {};
73
    my $self = {};
76
74
77
    $self->{'field'} = $field;
75
    $self->{'field'} = $field;
Lines 79-85 sub new_from_bib_field { Link Here
79
        $self->{'auth_type'},   $self->{'thesaurus'},
77
        $self->{'auth_type'},   $self->{'thesaurus'},
80
        $self->{'search_form'}, $self->{'display_form'},
78
        $self->{'search_form'}, $self->{'display_form'},
81
        $self->{'match_type'}
79
        $self->{'match_type'}
82
    ) = $marc_handler->parse_heading($field);
80
    ) = $marc_handler->parse_heading($field, $auth );
83
81
84
    bless $self, $class;
82
    bless $self, $class;
85
    return $self;
83
    return $self;
Lines 170-189 sub preferred_authorities { Link Here
170
    return $results;
168
    return $results;
171
}
169
}
172
170
173
=head2 valid_bib_heading_subfield
171
=head2 valid_heading_subfield
174
172
175
    if (C4::Heading::valid_bib_heading_subfield('100', 'e', '')) ...
173
    if (C4::Heading::valid_heading_subfield('100', 'e', '')) ...
176
174
177
=cut
175
=cut
178
176
179
sub valid_bib_heading_subfield {
177
sub valid_heading_subfield {
180
    my $tag           = shift;
178
    my $tag           = shift;
181
    my $subfield      = shift;
179
    my $subfield      = shift;
182
    my $marcflavour   = @_ ? shift : C4::Context->preference('marcflavour');
180
    my $marcflavour   = C4::Context->preference('marcflavour');
181
    my $auth          = shift;
183
182
184
    my $marc_handler = _marc_format_handler($marcflavour);
183
    my $marc_handler = _marc_format_handler($marcflavour);
185
184
    return $marc_handler->valid_heading_subfield( $tag, $subfield, $auth );
186
    return $marc_handler->valid_bib_heading_subfield( $tag, $subfield );
187
}
185
}
188
186
189
=head1 INTERNAL METHODS
187
=head1 INTERNAL METHODS
(-)a/C4/Heading/MARC21.pm (-8 / +61 lines)
Lines 119-124 my $bib_heading_fields = { Link Here
119
      { auth_type => 'UNIF_TITLE', subfields => 'adfghklmnoprst', series => 1 },
119
      { auth_type => 'UNIF_TITLE', subfields => 'adfghklmnoprst', series => 1 },
120
};
120
};
121
121
122
my $auth_heading_fields = {
123
    '100' => {
124
        auth_type  => 'PERSO_NAME',
125
        subfields  => 'abcdfghjklmnopqrstvxyz',
126
        main_entry => 1
127
    },
128
    '110' => {
129
        auth_type  => 'CORPO_NAME',
130
        subfields  => 'abcdfghklmnoprstvxyz',
131
        main_entry => 1
132
    },
133
    '111' => {
134
        auth_type  => 'MEETI_NAME',
135
        subfields  => 'acdfghjklnpqstvxyz',
136
        main_entry => 1
137
    },
138
    '130' => {
139
        auth_type  => 'UNIF_TITLE',
140
        subfields  => 'adfghklmnoprstvxyz',
141
        main_entry => 1
142
    },
143
    '148' => {
144
        auth_type => 'CHRON_TERM',
145
        subfields => 'avxyz',
146
        main_entry => 1
147
    },
148
    '150' => {
149
        auth_type => 'TOPIC_TERM',
150
        subfields => 'abgvxyz',
151
        main_entry => 1
152
    },
153
    '151' => {
154
        auth_type => 'GEOG_NAME',
155
        subfields => 'agvxyz',
156
        main_entry => 1
157
    },
158
    '155' => {
159
        auth_type => 'GENRE/FORM',
160
        subfields => 'agvxyz',
161
        main_entry => 1
162
    }
163
};
164
122
=head2 subdivisions
165
=head2 subdivisions
123
166
124
=cut
167
=cut
Lines 143-158 sub new { Link Here
143
    return bless {}, $class;
186
    return bless {}, $class;
144
}
187
}
145
188
146
=head2 valid_bib_heading_tag
189
=head2 valid_heading_tag
147
190
148
=cut
191
=cut
149
192
150
sub valid_bib_heading_tag {
193
sub valid_heading_tag {
151
    my $self          = shift;
194
    my $self          = shift;
152
    my $tag           = shift;
195
    my $tag           = shift;
153
    my $frameworkcode = shift;
196
    my $frameworkcode = shift;
197
    my $auth          = shift;
198
    my $heading_fields = $auth ? { %$auth_heading_fields } : { %$bib_heading_fields };
154
199
155
    if ( exists $bib_heading_fields->{$tag} ) {
200
    if ( exists $heading_fields->{$tag} ) {
156
        return 1;
201
        return 1;
157
    }
202
    }
158
    else {
203
    else {
Lines 161-192 sub valid_bib_heading_tag { Link Here
161
206
162
}
207
}
163
208
164
=head2 valid_bib_heading_subfield
209
=head2 valid_heading_subfield
165
210
166
=cut
211
=cut
167
212
168
sub valid_bib_heading_subfield {
213
sub valid_heading_subfield {
169
    my $self          = shift;
214
    my $self          = shift;
170
    my $tag           = shift;
215
    my $tag           = shift;
171
    my $subfield      = shift;
216
    my $subfield      = shift;
217
    my $auth          = shift;
218
219
    my $heading_fields = $auth ? { %$auth_heading_fields } : { %$bib_heading_fields };
172
220
173
    if ( exists $bib_heading_fields->{$tag} ) {
221
    if ( exists $heading_fields->{$tag} ) {
174
        return 1 if ($bib_heading_fields->{$tag}->{subfields} =~ /$subfield/);
222
        return 1 if ($heading_fields->{$tag}->{subfields} =~ /$subfield/);
175
    }
223
    }
176
    return 0;
224
    return 0;
177
}
225
}
178
226
179
=head2 parse_heading
227
=head2 parse_heading
180
228
229
Given a field and an indicator to specify if it is an authority field or biblio field we return
230
the correct type, thesauarus, search form, and display form of the heading.
231
181
=cut
232
=cut
182
233
183
sub parse_heading {
234
sub parse_heading {
184
    my $self  = shift;
235
    my $self  = shift;
185
    my $field = shift;
236
    my $field = shift;
237
    my $auth  = shift;
186
238
187
    my $tag        = $field->tag;
239
    my $tag        = $field->tag;
188
    my $field_info = $bib_heading_fields->{$tag};
240
    my $heading_fields = $auth ? { %$auth_heading_fields } : { %$bib_heading_fields };
189
241
242
    my $field_info = $heading_fields->{$tag};
190
    my $auth_type = $field_info->{'auth_type'};
243
    my $auth_type = $field_info->{'auth_type'};
191
    my $thesaurus =
244
    my $thesaurus =
192
      $tag =~ m/6../
245
      $tag =~ m/6../
(-)a/C4/Heading/UNIMARC.pm (-4 / +4 lines)
Lines 87-106 sub new { Link Here
87
    return bless {}, $class;
87
    return bless {}, $class;
88
}
88
}
89
89
90
=head2 valid_bib_heading_tag
90
=head2 valid_heading_tag
91
91
92
=cut
92
=cut
93
93
94
sub valid_bib_heading_tag {
94
sub valid_heading_tag {
95
    my ( $self, $tag ) = @_;
95
    my ( $self, $tag ) = @_;
96
    return $bib_heading_fields->{$tag};
96
    return $bib_heading_fields->{$tag};
97
}
97
}
98
98
99
=head2 valid_bib_heading_subfield
99
=head2 valid_heading_subfield
100
100
101
=cut
101
=cut
102
102
103
sub valid_bib_heading_subfield {
103
sub valid_heading_subfield {
104
    my $self          = shift;
104
    my $self          = shift;
105
    my $tag           = shift;
105
    my $tag           = shift;
106
    my $subfield      = shift;
106
    my $subfield      = shift;
(-)a/C4/Linker/Default.pm (-1 / +1 lines)
Lines 68-74 sub get_link { Link Here
68
                        map { $_->[0] => $_->[1] } @subfields
68
                        map { $_->[0] => $_->[1] } @subfields
69
                    );
69
                    );
70
                ( $authid, $fuzzy ) =
70
                ( $authid, $fuzzy ) =
71
                  $self->get_link( C4::Heading->new_from_bib_field($field),
71
                  $self->get_link( C4::Heading->new_from_field($field),
72
                    $behavior );
72
                    $behavior );
73
            }
73
            }
74
        }
74
        }
(-)a/Koha/SearchEngine/Elasticsearch.pm (-1 / +15 lines)
Lines 26-31 use Koha::Exceptions::Config; Link Here
26
use Koha::Exceptions::Elasticsearch;
26
use Koha::Exceptions::Elasticsearch;
27
use Koha::SearchFields;
27
use Koha::SearchFields;
28
use Koha::SearchMarcMaps;
28
use Koha::SearchMarcMaps;
29
use C4::Heading;
29
30
30
use Carp;
31
use Carp;
31
use Clone qw(clone);
32
use Clone qw(clone);
Lines 470-476 sub marc_records_to_documents { Link Here
470
                }
471
                }
471
472
472
                my $data_field_rules = $data_fields_rules->{$tag};
473
                my $data_field_rules = $data_fields_rules->{$tag};
473
474
                if ($data_field_rules) {
474
                if ($data_field_rules) {
475
                    my $subfields_mappings = $data_field_rules->{subfields};
475
                    my $subfields_mappings = $data_field_rules->{subfields};
476
                    my $wildcard_mappings = $subfields_mappings->{'*'};
476
                    my $wildcard_mappings = $subfields_mappings->{'*'};
Lines 483-488 sub marc_records_to_documents { Link Here
483
                        if (@{$mappings}) {
483
                        if (@{$mappings}) {
484
                            $self->_process_mappings($mappings, $data, $record_document, $altscript);
484
                            $self->_process_mappings($mappings, $data, $record_document, $altscript);
485
                        }
485
                        }
486
                        if ( defined @{$mappings}[0] && grep /match-heading/, @{@{$mappings}[0]} ){
487
                            # Used by the authority linker the match-heading field requires a specific syntax
488
                            # that is specified in C4/Heading
489
                            my $heading = C4::Heading->new_from_field( $field, undef, 1 ); #new auth heading
490
                            next unless $heading;
491
                            push @{$record_document->{'match-heading'}}, $heading->search_form;
492
                        }
486
                    }
493
                    }
487
494
488
                    my $subfields_join_mappings = $data_field_rules->{subfields_join};
495
                    my $subfields_join_mappings = $data_field_rules->{subfields_join};
Lines 499-504 sub marc_records_to_documents { Link Here
499
                            if ($data) {
506
                            if ($data) {
500
                                $self->_process_mappings($subfields_join_mappings->{$subfields_group}, $data, $record_document, $altscript);
507
                                $self->_process_mappings($subfields_join_mappings->{$subfields_group}, $data, $record_document, $altscript);
501
                            }
508
                            }
509
                            if ( grep { $_->[0] eq 'match-heading' } @{$subfields_join_mappings->{$subfields_group}} ){
510
                                # Used by the authority linker the match-heading field requires a specific syntax
511
                                # that is specified in C4/Heading
512
                                my $heading = C4::Heading->new_from_field( $field, undef, 1 ); #new auth heading
513
                                next unless $heading;
514
                                push @{$record_document->{'match-heading'}}, $heading->search_form;
515
                            }
502
                        }
516
                        }
503
                    }
517
                    }
504
                }
518
                }
(-)a/t/Koha/SearchEngine/Elasticsearch.t (-1 / +91 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 5;
20
use Test::More tests => 6;
21
use Test::Exception;
21
use Test::Exception;
22
22
23
use t::lib::Mocks;
23
use t::lib::Mocks;
Lines 26-31 use Test::MockModule; Link Here
26
26
27
use MARC::Record;
27
use MARC::Record;
28
use Try::Tiny;
28
use Try::Tiny;
29
use List::Util qw( any );
29
30
30
use Koha::SearchEngine::Elasticsearch;
31
use Koha::SearchEngine::Elasticsearch;
31
use Koha::SearchEngine::Elasticsearch::Search;
32
use Koha::SearchEngine::Elasticsearch::Search;
Lines 610-612 subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents_array () t Link Here
610
    ok($decoded_marc_record->isa('MARC::Record'), "ARRAY record successfully decoded from result");
611
    ok($decoded_marc_record->isa('MARC::Record'), "ARRAY record successfully decoded from result");
611
    is($decoded_marc_record->as_usmarc(), $marc_record_1->as_usmarc(), "Decoded ARRAY record has same data as original record");
612
    is($decoded_marc_record->as_usmarc(), $marc_record_1->as_usmarc(), "Decoded ARRAY record has same data as original record");
612
};
613
};
614
615
subtest 'Koha::SearchEngine::Elasticsearch::marc_records_to_documents () authority tests' => sub {
616
617
    plan tests => 2;
618
619
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
620
    t::lib::Mocks::mock_preference('ElasticsearchMARCFormat', 'ISO2709');
621
622
    my @mappings = (
623
        {
624
            name => 'match-heading',
625
            type => 'string',
626
            facet => 0,
627
            suggestible => 0,
628
            searchable => 1,
629
            sort => undef,
630
            marc_type => 'marc21',
631
            marc_field => '150',
632
        },
633
        {
634
            name => 'match-heading',
635
            type => 'string',
636
            facet => 0,
637
            suggestible => 0,
638
            searchable => 1,
639
            sort => 0,
640
            marc_type => 'marc21',
641
            marc_field => '150a',
642
        },
643
        {
644
            name => 'match-heading',
645
            type => 'string',
646
            facet => 0,
647
            suggestible => 0,
648
            searchable => 1,
649
            sort => 0,
650
            marc_type => 'marc21',
651
            marc_field => '150(ae)',
652
        },
653
    );
654
655
    my $se = Test::MockModule->new('Koha::SearchEngine::Elasticsearch');
656
    $se->mock('_foreach_mapping', sub {
657
        my ($self, $sub) = @_;
658
659
        foreach my $map (@mappings) {
660
            $sub->(
661
                $map->{name},
662
                $map->{type},
663
                $map->{facet},
664
                $map->{suggestible},
665
                $map->{sort},
666
                $map->{searchable},
667
                $map->{marc_type},
668
                $map->{marc_field}
669
            );
670
        }
671
    });
672
673
    my $see = Koha::SearchEngine::Elasticsearch::Search->new({ index => $Koha::SearchEngine::Elasticsearch::AUTHORITIES_INDEX });
674
675
    my $marc_record_1 = MARC::Record->new();
676
    $marc_record_1->append_fields(
677
        MARC::Field->new('001', '123'),
678
        MARC::Field->new('007', 'ku'),
679
        MARC::Field->new('020', '', '', a => '1-56619-909-3'),
680
        MARC::Field->new('150', '', '', a => 'Subject', v => 'Genresubdiv', x => 'Generalsubdiv', z => 'Geosubdiv'),
681
    );
682
    my $marc_record_2 = MARC::Record->new();
683
    $marc_record_2->append_fields(
684
        MARC::Field->new('150', '', '', a => 'Subject', v => 'Genresubdiv', z => 'Geosubdiv', x => 'Generalsubdiv', e => 'wrongsubdiv' ),
685
    );
686
    my $records = [$marc_record_1, $marc_record_2];
687
688
    $see->get_elasticsearch_mappings(); #sort_fields will call this and use the actual db values unless we call it first
689
690
    my $docs = $see->marc_records_to_documents($records);
691
692
    ok(
693
        any { $_ eq "Subject formsubdiv Genresubdiv generalsubdiv Generalsubdiv geographicsubdiv Geosubdiv" }
694
        @{$docs->[0]->{'match-heading'}},
695
        "First record match-heading should contain the correctly formatted heading"
696
    );
697
    ok(
698
        any { $_ eq "Subject formsubdiv Genresubdiv geographicsubdiv Geosubdiv generalsubdiv Generalsubdiv" }
699
        @{$docs->[1]->{'match-heading'}},
700
        "Second record match-heading should contain the correctly formatted heading without wrong subfield"
701
    );
702
};
(-)a/t/db_dependent/Heading.t (-15 / +18 lines)
Lines 27-46 BEGIN { Link Here
27
}
27
}
28
28
29
subtest "MARC21 tests" => sub {
29
subtest "MARC21 tests" => sub {
30
    plan tests => 7;
30
    plan tests => 9;
31
31
32
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
32
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
33
33
34
    ok(C4::Heading::valid_bib_heading_subfield('100', 'a'), '100a valid');
34
    ok(C4::Heading::valid_heading_subfield('100', 'a'), '100a valid for bib');
35
    ok(!C4::Heading::valid_bib_heading_subfield('100', 'e'), '100e not valid');
35
    ok(!C4::Heading::valid_heading_subfield('100', 'e'), '100e not valid for bib');
36
37
    ok(C4::Heading::valid_heading_subfield('100', 'a', 1), '100a valid for authority');
38
    ok(!C4::Heading::valid_heading_subfield('100', 'e', 1), '100e not valid for authority');
36
39
37
    ok(C4::Heading::valid_bib_heading_subfield('110', 'a'), '110a valid');
40
    ok(C4::Heading::valid_heading_subfield('110', 'a'), '110a valid for bib');
38
    ok(!C4::Heading::valid_bib_heading_subfield('110', 'e'), '110e not valid');
41
    ok(!C4::Heading::valid_heading_subfield('110', 'e'), '110e not valid for bib');
39
42
40
    ok(C4::Heading::valid_bib_heading_subfield('600', 'a'), '600a valid');
43
    ok(C4::Heading::valid_heading_subfield('600', 'a'), '600a valid for bib');
41
    ok(!C4::Heading::valid_bib_heading_subfield('600', 'e'), '600e not valid');
44
    ok(!C4::Heading::valid_heading_subfield('600', 'e'), '600e not valid for bib');
42
45
43
    ok(!C4::Heading::valid_bib_heading_subfield('012', 'a'), '012a invalid field');
46
    ok(!C4::Heading::valid_heading_subfield('012', 'a'), '012a invalid field for bib');
44
};
47
};
45
48
46
subtest "UNIMARC tests" => sub {
49
subtest "UNIMARC tests" => sub {
Lines 48-61 subtest "UNIMARC tests" => sub { Link Here
48
51
49
    t::lib::Mocks::mock_preference('marcflavour', 'UNIMARC');
52
    t::lib::Mocks::mock_preference('marcflavour', 'UNIMARC');
50
53
51
    ok(C4::Heading::valid_bib_heading_subfield('100', 'a'), '100a valid');
54
    ok(C4::Heading::valid_heading_subfield('100', 'a'), '100a valid for bib');
52
    ok(!C4::Heading::valid_bib_heading_subfield('100', 'i'), '100i not valid');
55
    ok(!C4::Heading::valid_heading_subfield('100', 'i'), '100i not valid fir bib');
53
56
54
    ok(C4::Heading::valid_bib_heading_subfield('110', 'a'), '110a valid');
57
    ok(C4::Heading::valid_heading_subfield('110', 'a'), '110a valid for bib');
55
    ok(!C4::Heading::valid_bib_heading_subfield('110', 'i'), '110i not valid');
58
    ok(!C4::Heading::valid_heading_subfield('110', 'i'), '110i not valid for bib');
56
59
57
    ok(C4::Heading::valid_bib_heading_subfield('600', 'a'), '600a valid');
60
    ok(C4::Heading::valid_heading_subfield('600', 'a'), '600a valid for bib');
58
    ok(!C4::Heading::valid_bib_heading_subfield('600', 'i'), '600i not valid');
61
    ok(!C4::Heading::valid_heading_subfield('600', 'i'), '600i not valid for bib');
59
62
60
    ok(!C4::Heading::valid_bib_heading_subfield('012', 'a'), '012a invalid field');
63
    ok(!C4::Heading::valid_heading_subfield('012', 'a'), '012a invalid field for bib');
61
}
64
}
(-)a/t/db_dependent/Heading_MARC21.t (-1 / +1 lines)
Lines 16-22 BEGIN { Link Here
16
SKIP: {
16
SKIP: {
17
    skip "MARC21 heading tests not applicable to UNIMARC", 2 if C4::Context->preference('marcflavour') eq 'UNIMARC';
17
    skip "MARC21 heading tests not applicable to UNIMARC", 2 if C4::Context->preference('marcflavour') eq 'UNIMARC';
18
    my $field = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' );
18
    my $field = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' );
19
    my $heading = C4::Heading->new_from_bib_field($field);
19
    my $heading = C4::Heading->new_from_field($field);
20
    is($heading->display_form(), 'Uncles--Fiction', 'Display form generation');
20
    is($heading->display_form(), 'Uncles--Fiction', 'Display form generation');
21
    is($heading->search_form(), 'Uncles generalsubdiv Fiction', 'Search form generation');
21
    is($heading->search_form(), 'Uncles generalsubdiv Fiction', 'Search form generation');
22
}
22
}
(-)a/t/db_dependent/Linker_Default.t (-3 / +3 lines)
Lines 50-58 subtest 'Test caching in get_link and update_cache' => sub { Link Here
50
    my $subject_field2 = MARC::Field->new($tags[0],0,2,$tags[1]=>'Science fiction');
50
    my $subject_field2 = MARC::Field->new($tags[0],0,2,$tags[1]=>'Science fiction');
51
    my $genre_field = MARC::Field->new($tags[2],0,2,$tags[3]=>'Science fiction');
51
    my $genre_field = MARC::Field->new($tags[2],0,2,$tags[3]=>'Science fiction');
52
    # Can we build a heading from it?
52
    # Can we build a heading from it?
53
    my $subject_heading = C4::Heading->new_from_bib_field( $subject_field, q{} );
53
    my $subject_heading = C4::Heading->new_from_field( $subject_field, q{} );
54
    my $subject_heading2 = C4::Heading->new_from_bib_field( $subject_field, q{} );
54
    my $subject_heading2 = C4::Heading->new_from_field( $subject_field, q{} );
55
    my $genre_heading = C4::Heading->new_from_bib_field( $genre_field, q{} );
55
    my $genre_heading = C4::Heading->new_from_field( $genre_field, q{} );
56
56
57
57
58
    # Now test to see if C4::Linker can find it.
58
    # Now test to see if C4::Linker can find it.
(-)a/t/db_dependent/Linker_FirstMatch.t (-2 / +1 lines)
Lines 110-116 sub run_tests { Link Here
110
    my $heading;
110
    my $heading;
111
    ok(
111
    ok(
112
        defined(
112
        defined(
113
            $heading = C4::Heading->new_from_bib_field( $new_bibfield, q{} )
113
            $heading = C4::Heading->new_from_field( $new_bibfield, q{} )
114
        ),
114
        ),
115
        'Creating heading from bib field'
115
        'Creating heading from bib field'
116
    );
116
    );
117
- 

Return to bug 23596