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

(-)a/t/Circulation/AgeRestrictionMarkers.t (-17 / +23 lines)
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
    my $borrower = {};
26
is ( ($daysToAgeRestriction > 0), 1, 'FSK 16 blocked for a 15 year old' );
28
    C4::Members::SetAge( $borrower, '0015-00-00' );
27
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('PEGI 15', $borrower);
29
28
is ( ($daysToAgeRestriction <= 0), 1, 'PEGI 15 allowed for a 15 year old' );
30
    my ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('FSK 16', $borrower);
29
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('PEGI14', $borrower);
31
    is ( ($daysToAgeRestriction > 0), 1, 'FSK 16 blocked for a 15 year old - $offset hours' );
30
is ( ($daysToAgeRestriction <= 0), 1, 'PEGI14 allowed for a 15 year old' );
32
    ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('PEGI 15', $borrower);
31
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('Age 10', $borrower);
33
    is ( ($daysToAgeRestriction <= 0), 1, 'PEGI 15 allowed for a 15 year old - $offset hours' );
32
is ( ($daysToAgeRestriction <= 0), 1, 'Age 10 allowed for a 15 year old' );
34
    ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('PEGI14', $borrower);
33
($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('K18', $borrower);
35
    is ( ($daysToAgeRestriction <= 0), 1, 'PEGI14 allowed for a 15 year old - $offset hours' );
34
is ( ($daysToAgeRestriction > 0), 1, 'K18 blocked for a 15 year old' );
36
    ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('Age 10', $borrower);
37
    is ( ($daysToAgeRestriction <= 0), 1, 'Age 10 allowed for a 15 year old - $offset hours' );
38
    ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('K18', $borrower);
39
    is ( ($daysToAgeRestriction > 0), 1, 'K18 blocked for a 15 year old - $offset hours' );
40
    $offset++;
41
}
35
- 

Return to bug 14362