Lines 1-8
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
|
2 |
|
3 |
use Modern::Perl; |
3 |
use Modern::Perl; |
|
|
4 |
use Time::Fake; |
5 |
|
4 |
use DateTime; |
6 |
use DateTime; |
5 |
use Test::More tests => 10; |
7 |
use Test::More tests => 125; |
6 |
|
8 |
|
7 |
use t::lib::Mocks; |
9 |
use t::lib::Mocks; |
8 |
|
10 |
|
Lines 17-34
is ( C4::Circulation::GetAgeRestriction('Age 16'), '16', 'Age 16 returns 16' );
Link Here
|
17 |
is ( C4::Circulation::GetAgeRestriction('K16'), '16', 'K16 returns 16' ); |
19 |
is ( C4::Circulation::GetAgeRestriction('K16'), '16', 'K16 returns 16' ); |
18 |
|
20 |
|
19 |
|
21 |
|
20 |
##Testing age restriction for a borrower. |
22 |
my $offset = 0; |
21 |
my $now = DateTime->now(); |
23 |
while ($offset<24) { |
22 |
my $borrower = {}; |
24 |
Time::Fake->offset("+${offset}h"); |
23 |
C4::Members::SetAge( $borrower, '0015-00-00' ); |
25 |
##Testing age restriction for a borrower. |
24 |
|
26 |
my $now = DateTime->now(); |
25 |
my ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('FSK 16', $borrower); |
27 |
print STDERR "$now\n"; |
26 |
is ( ($daysToAgeRestriction > 0), 1, 'FSK 16 blocked for a 15 year old' ); |
28 |
my $borrower = {}; |
27 |
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('PEGI 15', $borrower); |
29 |
C4::Members::SetAge( $borrower, '0015-00-00' ); |
28 |
is ( ($daysToAgeRestriction <= 0), 1, 'PEGI 15 allowed for a 15 year old' ); |
30 |
|
29 |
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('PEGI14', $borrower); |
31 |
my ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('FSK 16', $borrower); |
30 |
is ( ($daysToAgeRestriction <= 0), 1, 'PEGI14 allowed for a 15 year old' ); |
32 |
is ( ($daysToAgeRestriction > 0), 1, 'FSK 16 blocked for a 15 year old - $offset hours' ); |
31 |
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('Age 10', $borrower); |
33 |
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('PEGI 15', $borrower); |
32 |
is ( ($daysToAgeRestriction <= 0), 1, 'Age 10 allowed for a 15 year old' ); |
34 |
is ( ($daysToAgeRestriction <= 0), 1, 'PEGI 15 allowed for a 15 year old - $offset hours' ); |
33 |
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('K18', $borrower); |
35 |
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('PEGI14', $borrower); |
34 |
is ( ($daysToAgeRestriction > 0), 1, 'K18 blocked for a 15 year old' ); |
36 |
is ( ($daysToAgeRestriction <= 0), 1, 'PEGI14 allowed for a 15 year old - $offset hours' ); |
|
|
37 |
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('Age 10', $borrower); |
38 |
is ( ($daysToAgeRestriction <= 0), 1, 'Age 10 allowed for a 15 year old - $offset hours' ); |
39 |
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('K18', $borrower); |
40 |
is ( ($daysToAgeRestriction > 0), 1, 'K18 blocked for a 15 year old - $offset hours' ); |
41 |
$offset++; |
42 |
} |
35 |
- |
|
|