Bug 42529: Remove GetAgeRestriction from C4::Circulation
GetAgeRestriction is no longer used by any caller. This patch removes
it from the exports list and deletes the old test file.
Test plan:
1. Run tests without this patch:
$ ktd --shell
k$ prove t/db_dependent/Circulation.t \
t/db_dependent/Reserves.t \
t/Circulation/AgeRestrictionMarkers.t
=> SUCCESS: Tests pass!
2. Apply this patch
3. Run:
k$ prove t/db_dependent/Circulation.t \
t/db_dependent/Reserves.t \
t/db_dependent/Koha/Policy/Biblio/AgeRestriction.t
=> SUCCESS: Tests pass!
4. Sign off :-D
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Amended-by: Jonathan Druart
Removed this from the commit message:
"The function body is kept for now as it is not harmful and could be
used by third-party code. It is no longer exported."
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
parent
b9868ce2d2
commit
e89478d560
|
|
@ -4908,54 +4908,6 @@ sub IsItemIssued {
|
|||
return $sth->fetchrow;
|
||||
}
|
||||
|
||||
=head2 GetAgeRestriction
|
||||
|
||||
my $ageRestriction = GetAgeRestriction($record_restrictions);
|
||||
|
||||
@PARAM1 the koha.biblioitems.agerestriction value, like K18, PEGI 13, ...
|
||||
@RETURNS The age restriction age in years.
|
||||
|
||||
=cut
|
||||
|
||||
sub GetAgeRestriction {
|
||||
my ($record_restrictions) = @_;
|
||||
my $markers = C4::Context->preference('AgeRestrictionMarker');
|
||||
|
||||
return unless $record_restrictions;
|
||||
|
||||
# Split $record_restrictions to something like FSK 16 or PEGI 6
|
||||
my @values = split ' ', uc($record_restrictions);
|
||||
return unless @values;
|
||||
|
||||
# Search first occurrence of one of the markers
|
||||
my @markers = split /\|/, uc($markers);
|
||||
return unless @markers;
|
||||
|
||||
my $index = 0;
|
||||
my $restriction_year = 0;
|
||||
for my $value (@values) {
|
||||
$index++;
|
||||
for my $marker (@markers) {
|
||||
$marker =~ s/^\s+//; #remove leading spaces
|
||||
$marker =~ s/\s+$//; #remove trailing spaces
|
||||
if ( $marker eq $value ) {
|
||||
if ( $index <= $#values ) {
|
||||
$restriction_year += $values[$index];
|
||||
}
|
||||
last;
|
||||
} elsif ( $value =~ /^\Q$marker\E(\d+)$/ ) {
|
||||
|
||||
# Perhaps it is something like "K16" (as in Finland)
|
||||
$restriction_year += $1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
last if ( $restriction_year > 0 );
|
||||
}
|
||||
|
||||
return $restriction_year;
|
||||
}
|
||||
|
||||
=head2 GetPendingOnSiteCheckouts
|
||||
|
||||
=cut
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# This file is part of Koha.
|
||||
#
|
||||
# Copyright 2015 Koha Development Team
|
||||
# Copyright (C) 2015 Mark Tompsett (Time Zone Shifts)
|
||||
#
|
||||
# Koha is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Koha is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Koha; if not, see <https://www.gnu.org/licenses>.
|
||||
|
||||
use Modern::Perl;
|
||||
|
||||
use DateTime;
|
||||
use Koha::DateUtils qw( dt_from_string );
|
||||
use Test::NoWarnings;
|
||||
use Test::More tests => 7;
|
||||
use Test::Warn;
|
||||
|
||||
use t::lib::Mocks;
|
||||
|
||||
use C4::Circulation qw( GetAgeRestriction );
|
||||
|
||||
t::lib::Mocks::mock_preference( 'AgeRestrictionMarker', 'FSK|PEGI|Age|K' );
|
||||
|
||||
is( C4::Circulation::GetAgeRestriction('FSK 16'), '16', 'FSK 16 returns 16' );
|
||||
is( C4::Circulation::GetAgeRestriction('PEGI 16'), '16', 'PEGI 16 returns 16' );
|
||||
is( C4::Circulation::GetAgeRestriction('PEGI16'), '16', 'PEGI16 returns 16' );
|
||||
is( C4::Circulation::GetAgeRestriction('Age 16'), '16', 'Age 16 returns 16' );
|
||||
is( C4::Circulation::GetAgeRestriction('K16'), '16', 'K16 returns 16' );
|
||||
|
||||
subtest 'No age restriction' => sub {
|
||||
plan tests => 1;
|
||||
|
||||
warning_is {
|
||||
C4::Circulation::GetAgeRestriction();
|
||||
}
|
||||
undef, "No warning if GetAgeRestriction is called without restriction";
|
||||
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue