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

(-)a/Koha/Biblio.pm (-14 lines)
Lines 1687-1706 sub normalized_upc { Link Here
1687
    return $self->metadata_extractor->get_normalized_upc;
1687
    return $self->metadata_extractor->get_normalized_upc;
1688
}
1688
}
1689
1689
1690
=head3 opac_suppressed
1691
1692
    my $opac_suppressed = $biblio->opac_suppressed();
1693
1694
Returns whether the record is flagged as suppressed in the OPAC.
1695
FIXME: Revisit after 38330 discussion
1696
1697
=cut
1698
1699
sub opac_suppressed {
1700
    my ($self) = @_;
1701
    return $self->metadata_extractor->get_opac_suppression();
1702
}
1703
1704
=head3 normalized_oclc
1690
=head3 normalized_oclc
1705
1691
1706
    my $normalized_oclc = $biblio->normalized_oclc
1692
    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