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 61-63 marc21,700,ind1:auth2 Link Here
61
    });
61
    });
62
    is_deeply( $res, {}, 'Cache cleared' );
62
    is_deeply( $res, {}, 'Cache cleared' );
63
};
63
};
64
- 
64
65
subtest "Tests for sub _thesaurus_info" => sub {
66
    plan tests => 10;
67
68
    t::lib::Mocks::mock_preference('AuthorityControlledIndicators', q|marc21,600,ignored,ind2:thesaurus|);
69
    my $oInd = Koha::Authority::ControlledIndicators->new;
70
71
    my $record = MARC::Record->new;
72
    $record->append_fields(
73
        MARC::Field->new( '008', (' 'x11).'a' ),
74
        MARC::Field->new( '040', '', '', f => 'very_special' ),
75
    );
76
77
    # Case 1: LOC code a in auth record should become 0 in 6XX ind2
78
    my $res = $oInd->get({
79
        flavour => "MARC21",
80
        report_tag  => '100',
81
        auth_record => $record,
82
        biblio_tag  => '600',
83
    });
84
    is( $res->{ind2}, '0', 'Indicator matched for LOC headings' );
85
    is( $res->{sub2}, undef, 'No subfield 2' );
86
87
    # Case 2: Code n (Not applicable) should become 4 (source not specified)
88
    $record->field('008')->update( (' 'x11).'n' );
89
    $res = $oInd->get({
90
        flavour => "MARC21",
91
        report_tag  => '100',
92
        auth_record => $record,
93
        biblio_tag  => '600',
94
    });
95
    is( $res->{ind2}, '4', 'Source not specified' );
96
    is( $res->{sub2}, undef, 'No subfield 2' );
97
98
    # Case 3: AAT thesaurus (and subfield $2)
99
    $record->field('008')->update( (' 'x11).'r' );
100
    $res = $oInd->get({
101
        flavour => "MARC21",
102
        report_tag  => '100',
103
        auth_record => $record,
104
        biblio_tag  => '600',
105
    });
106
    is( $res->{ind2}, '7', 'AAT, see subfield 2' );
107
    is( $res->{sub2}, 'aat', 'Subfield 2 verified' );
108
109
    # Case 4: Code z triggers a fetch from 040$f (and subfield $2)
110
    $record->field('008')->update( (' 'x11).'z' );
111
    $res = $oInd->get({
112
        flavour => "MARC21",
113
        report_tag  => '100',
114
        auth_record => $record,
115
        biblio_tag  => '600',
116
    });
117
    is( $res->{ind2}, '7', 'Code z, see subfield 2' );
118
    is( $res->{sub2}, 'very_special', 'Subfield 2 from 040$f' );
119
120
    # Case 5: Code e does not belong in 008/11
121
    $record->field('008')->update( (' 'x11).'e' );
122
    $res = $oInd->get({
123
        flavour => "MARC21",
124
        report_tag  => '100',
125
        auth_record => $record,
126
        biblio_tag  => '600',
127
    });
128
    is( $res->{ind2}, '4', 'Code e triggers not specified' );
129
    is( $res->{sub2}, undef, 'No subfield 2' );
130
};

Return to bug 14769