Lines 1-8
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
|
2 |
|
3 |
use Modern::Perl; |
3 |
use Modern::Perl; |
|
|
4 |
|
4 |
use DateTime; |
5 |
use DateTime; |
5 |
use Test::More tests => 10; |
6 |
use Test::More tests => 7; |
6 |
|
7 |
|
7 |
use t::lib::Mocks; |
8 |
use t::lib::Mocks; |
8 |
|
9 |
|
Lines 16-34
is ( C4::Circulation::GetAgeRestriction('PEGI16'), '16', 'PEGI16 returns 16' );
Link Here
|
16 |
is ( C4::Circulation::GetAgeRestriction('Age 16'), '16', 'Age 16 returns 16' ); |
17 |
is ( C4::Circulation::GetAgeRestriction('Age 16'), '16', 'Age 16 returns 16' ); |
17 |
is ( C4::Circulation::GetAgeRestriction('K16'), '16', 'K16 returns 16' ); |
18 |
is ( C4::Circulation::GetAgeRestriction('K16'), '16', 'K16 returns 16' ); |
18 |
|
19 |
|
|
|
20 |
subtest 'Patron tests - 15 years old (+0)' => sub { |
21 |
plan tests => 5; |
22 |
##Testing age restriction for a borrower. |
23 |
my $now = DateTime->now(); |
24 |
my $borrower = {}; |
25 |
C4::Members::SetAge( $borrower, '0015-00-00' ); |
26 |
PEGI15($borrower,0); |
27 |
}; |
28 |
|
29 |
subtest 'Patron tests - 15 years old (+1 - +23)' => sub { |
30 |
my $CheckTimeFake = eval { require Time::Fake; 1; } || 0; |
31 |
SKIP: { |
32 |
skip "Install Time::Fake to regression test for Bug 14362.", 115 if $CheckTimeFake!=1; |
33 |
# 115 regression tests = 5 tests (see PEGI15) for 23 timezones. |
34 |
plan tests => 115; |
35 |
my $offset = 1; |
36 |
# <24 hours in a day. |
37 |
while ($offset<24) { |
38 |
Time::Fake->offset("+${offset}h"); |
39 |
|
40 |
##Testing age restriction for a borrower. |
41 |
my $now = DateTime->now(); |
42 |
my $borrower = {}; |
43 |
C4::Members::SetAge( $borrower, '0015-00-00' ); |
44 |
PEGI15($borrower,$offset); |
45 |
|
46 |
$offset++; |
47 |
} |
48 |
} |
49 |
}; |
50 |
|
51 |
# The 15 year old tests. |
52 |
sub PEGI15 { |
53 |
my ($borrower,$offset) = @_; |
19 |
|
54 |
|
20 |
##Testing age restriction for a borrower. |
55 |
my ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('FSK 16', $borrower); |
21 |
my $now = DateTime->now(); |
56 |
is ( ($daysToAgeRestriction > 0), 1, "FSK 16 blocked for a 15 year old - $offset hours" ); |
22 |
my $borrower = {}; |
57 |
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('PEGI 15', $borrower); |
23 |
C4::Members::SetAge( $borrower, '0015-00-00' ); |
58 |
is ( ($daysToAgeRestriction <= 0), 1, "PEGI 15 allowed for a 15 year old - $offset hours" ); |
24 |
|
59 |
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('PEGI14', $borrower); |
25 |
my ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('FSK 16', $borrower); |
60 |
is ( ($daysToAgeRestriction <= 0), 1, "PEGI14 allowed for a 15 year old - $offset hours" ); |
26 |
is ( ($daysToAgeRestriction > 0), 1, 'FSK 16 blocked for a 15 year old' ); |
61 |
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('Age 10', $borrower); |
27 |
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('PEGI 15', $borrower); |
62 |
is ( ($daysToAgeRestriction <= 0), 1, "Age 10 allowed for a 15 year old - $offset hours" ); |
28 |
is ( ($daysToAgeRestriction <= 0), 1, 'PEGI 15 allowed for a 15 year old' ); |
63 |
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('K18', $borrower); |
29 |
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('PEGI14', $borrower); |
64 |
is ( ($daysToAgeRestriction > 0), 1, "K18 blocked for a 15 year old - $offset hours" ); |
30 |
is ( ($daysToAgeRestriction <= 0), 1, 'PEGI14 allowed for a 15 year old' ); |
65 |
return; |
31 |
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('Age 10', $borrower); |
66 |
} |
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' ); |
35 |
- |
|
|