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

(-)a/Koha/Authority/ControlledIndicators.pm (-1 / +1 lines)
Lines 129-135 sub _thesaurus_info { Link Here
129
        ? substr($record->field('008')->data, 11, 1)
129
        ? substr($record->field('008')->data, 11, 1)
130
        : q{};
130
        : q{};
131
    my %thes_mapping = ( a => 0, b => 1, c => 2, d => 3, k => 5, n => 4, r => 7, s => 7, v => 6, z => 7, '|' => 4 );
131
    my %thes_mapping = ( a => 0, b => 1, c => 2, d => 3, k => 5, n => 4, r => 7, s => 7, v => 6, z => 7, '|' => 4 );
132
    my $ind = $thes_mapping{ $code } // $code // '4';
132
    my $ind = $thes_mapping{ $code } // '4';
133
133
134
    # Determine optional subfield $2
134
    # Determine optional subfield $2
135
    my $sub2;
135
    my $sub2;
(-)a/t/Koha/Authority/ControlledIndicators.t (-2 / +68 lines)
Lines 4-10 use Modern::Perl; Link Here
4
use Data::Dumper qw/Dumper/;
4
use Data::Dumper qw/Dumper/;
5
use MARC::Record;
5
use MARC::Record;
6
use MARC::Field;
6
use MARC::Field;
7
use Test::More tests => 1;
7
use Test::More tests => 2;
8
8
9
use t::lib::Mocks;
9
use t::lib::Mocks;
10
use Koha::Authority::ControlledIndicators;
10
use Koha::Authority::ControlledIndicators;
Lines 71-73 marc21,800,ind1:, Link Here
71
    });
71
    });
72
    is_deeply( $res, {}, 'Cache cleared' );
72
    is_deeply( $res, {}, 'Cache cleared' );
73
};
73
};
74
- 
74
75
subtest "Tests for sub _thesaurus_info" => sub {
76
    plan tests => 10;
77
78
    t::lib::Mocks::mock_preference('AuthorityControlledIndicators', q|marc21,600,ignored,ind2:thesaurus|);
79
    my $oInd = Koha::Authority::ControlledIndicators->new;
80
81
    my $record = MARC::Record->new;
82
    $record->append_fields(
83
        MARC::Field->new( '008', (' 'x11).'a' ),
84
        MARC::Field->new( '040', '', '', f => 'very_special' ),
85
    );
86
87
    # Case 1: LOC code a in auth record should become 0 in 6XX ind2
88
    my $res = $oInd->get({
89
        flavour => "MARC21",
90
        report_tag  => '100',
91
        auth_record => $record,
92
        biblio_tag  => '600',
93
    });
94
    is( $res->{ind2}, '0', 'Indicator matched for LOC headings' );
95
    is( $res->{sub2}, undef, 'No subfield 2' );
96
97
    # Case 2: Code n (Not applicable) should become 4 (source not specified)
98
    $record->field('008')->update( (' 'x11).'n' );
99
    $res = $oInd->get({
100
        flavour => "MARC21",
101
        report_tag  => '100',
102
        auth_record => $record,
103
        biblio_tag  => '600',
104
    });
105
    is( $res->{ind2}, '4', 'Source not specified' );
106
    is( $res->{sub2}, undef, 'No subfield 2' );
107
108
    # Case 3: AAT thesaurus (and subfield $2)
109
    $record->field('008')->update( (' 'x11).'r' );
110
    $res = $oInd->get({
111
        flavour => "MARC21",
112
        report_tag  => '100',
113
        auth_record => $record,
114
        biblio_tag  => '600',
115
    });
116
    is( $res->{ind2}, '7', 'AAT, see subfield 2' );
117
    is( $res->{sub2}, 'aat', 'Subfield 2 verified' );
118
119
    # Case 4: Code z triggers a fetch from 040$f (and subfield $2)
120
    $record->field('008')->update( (' 'x11).'z' );
121
    $res = $oInd->get({
122
        flavour => "MARC21",
123
        report_tag  => '100',
124
        auth_record => $record,
125
        biblio_tag  => '600',
126
    });
127
    is( $res->{ind2}, '7', 'Code z, see subfield 2' );
128
    is( $res->{sub2}, 'very_special', 'Subfield 2 from 040$f' );
129
130
    # Case 5: Code e does not belong in 008/11
131
    $record->field('008')->update( (' 'x11).'e' );
132
    $res = $oInd->get({
133
        flavour => "MARC21",
134
        report_tag  => '100',
135
        auth_record => $record,
136
        biblio_tag  => '600',
137
    });
138
    is( $res->{ind2}, '4', 'Code e triggers not specified' );
139
    is( $res->{sub2}, undef, 'No subfield 2' );
140
};

Return to bug 14769