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

(-)a/Koha/Biblio.pm (-14 lines)
Lines 1681-1700 sub normalized_upc { Link Here
1681
    return $self->metadata_extractor->get_normalized_upc;
1681
    return $self->metadata_extractor->get_normalized_upc;
1682
}
1682
}
1683
1683
1684
=head3 opac_suppressed
1685
1686
    my $opac_suppressed = $biblio->opac_suppressed();
1687
1688
Returns whether the record is flagged as suppressed in the OPAC.
1689
FIXME: Revisit after 38330 discussion
1690
1691
=cut
1692
1693
sub opac_suppressed {
1694
    my ($self) = @_;
1695
    return $self->metadata_extractor->get_opac_suppression();
1696
}
1697
1698
=head3 normalized_oclc
1684
=head3 normalized_oclc
1699
1685
1700
    my $normalized_oclc = $biblio->normalized_oclc
1686
    my $normalized_oclc = $biblio->normalized_oclc
(-)a/Koha/Biblio/Metadata/Extractor/MARC.pm (-17 lines)
Lines 100-122 sub get_control_number { Link Here
100
    return $control_number;
100
    return $control_number;
101
}
101
}
102
102
103
=head2 get_opac_suppression
104
105
    my $opac_suppressed = $extractor->get_opac_suppression();
106
107
Returns whether the record is flagged as suppressed in the OPAC.
108
FIXME: Revisit after 38330 discussion
109
110
=cut
111
112
sub get_opac_suppression {
113
    my ($self) = @_;
114
115
    my $record = $self->metadata;
116
117
    return $record->subfield( '942', 'n' ) ? 1 : 0;
118
}
119
120
=head3 _normalize_string
103
=head3 _normalize_string
121
104
122
    my $normalized_string = $self->_normalize_string($string);
105
    my $normalized_string = $self->_normalize_string($string);
(-)a/t/db_dependent/Koha/Biblio/Metadata/Extractor/MARC.t (-25 / +1 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::NoWarnings;
22
use Test::NoWarnings;
23
use Test::More tests => 3;
23
use Test::More tests => 2;
24
use Test::Exception;
24
use Test::Exception;
25
25
26
use t::lib::TestBuilder;
26
use t::lib::TestBuilder;
Lines 55-80 subtest 'get_control_number() tests' => sub { Link Here
55
        is( $extractor->get_control_number, $identifier, 'Returns the right value' );
55
        is( $extractor->get_control_number, $identifier, 'Returns the right value' );
56
    }
56
    }
57
};
57
};
58
59
subtest 'get_opac_suppression() tests' => sub {
60
61
    plan tests => 8;
62
63
    foreach my $marcflavour (qw( MARC21 UNIMARC )) {
64
        t::lib::Mocks::mock_preference( 'marcflavour', $marcflavour );
65
66
        my $record    = MARC::Record->new();
67
        my $extractor = Koha::Biblio::Metadata::Extractor->new( { metadata => $record } );
68
69
        is( $extractor->get_opac_suppression(), 0, 'If 942$n absent, then not suppressed' );
70
71
        $record->append_fields( MARC::Field->new( '942', q{}, q{}, n => '' ) );
72
        is( $extractor->get_opac_suppression(), 0, 'If 942$n has empty string, then not suppressed' );
73
74
        $record->field('942')->replace_with( MARC::Field->new( '942', q{}, q{}, n => 'potato' ) );
75
        is( $extractor->get_opac_suppression(), 1, 'If 942$n has something different than false, then suppressed' );
76
77
        $record->field('942')->replace_with( MARC::Field->new( '942', q{}, q{}, n => '1' ) );
78
        is( $extractor->get_opac_suppression(), 1, 'If 942$n is 1, then suppressed' );
79
    }
80
};
81
- 

Return to bug 38330