Bug 13133: Fix mangled titles on pay fines page
[koha.git] / t / Circulation / AgeRestrictionMarkers.t
1 #!/usr/bin/perl
2
3 use Modern::Perl;
4 use DateTime;
5 use Test::More tests => 10;
6
7 use t::lib::Mocks;
8
9 use C4::Circulation;
10
11 t::lib::Mocks::mock_preference( 'AgeRestrictionMarker', 'FSK|PEGI|Age|K' );
12
13 is ( C4::Circulation::GetAgeRestriction('FSK 16'), '16', 'FSK 16 returns 16' );
14 is ( C4::Circulation::GetAgeRestriction('PEGI 16'), '16', 'PEGI 16 returns 16' );
15 is ( C4::Circulation::GetAgeRestriction('PEGI16'), '16', 'PEGI16 returns 16' );
16 is ( C4::Circulation::GetAgeRestriction('Age 16'), '16', 'Age 16 returns 16' );
17 is ( C4::Circulation::GetAgeRestriction('K16'), '16', 'K16 returns 16' );
18
19
20 ##Testing age restriction for a borrower.
21 my $now = DateTime->now();
22 my $borrower = {};
23 C4::Members::SetAge( $borrower, '0015-00-00' );
24
25 my ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('FSK 16', $borrower);
26 is ( ($daysToAgeRestriction > 0), 1, 'FSK 16 blocked for a 15 year old' );
27 ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('PEGI 15', $borrower);
28 is ( ($daysToAgeRestriction <= 0), 1, 'PEGI 15 allowed for a 15 year old' );
29 ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('PEGI14', $borrower);
30 is ( ($daysToAgeRestriction <= 0), 1, 'PEGI14 allowed for a 15 year old' );
31 ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('Age 10', $borrower);
32 is ( ($daysToAgeRestriction <= 0), 1, 'Age 10 allowed for a 15 year old' );
33 ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('K18', $borrower);
34 is ( ($daysToAgeRestriction > 0), 1, 'K18 blocked for a 15 year old' );