@@ -, +, @@ --------- -- should fail some times. -- should work all the time. --- t/Circulation/AgeRestrictionMarkers.t | 39 +++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 16 deletions(-) --- a/t/Circulation/AgeRestrictionMarkers.t +++ a/t/Circulation/AgeRestrictionMarkers.t @@ -1,8 +1,10 @@ #!/usr/bin/perl use Modern::Perl; +use Time::Fake; + use DateTime; -use Test::More tests => 10; +use Test::More tests => 125; use t::lib::Mocks; @@ -17,18 +19,23 @@ is ( C4::Circulation::GetAgeRestriction('Age 16'), '16', 'Age 16 returns 16' ); is ( C4::Circulation::GetAgeRestriction('K16'), '16', 'K16 returns 16' ); -##Testing age restriction for a borrower. -my $now = DateTime->now(); -my $borrower = {}; -C4::Members::SetAge( $borrower, '0015-00-00' ); - -my ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('FSK 16', $borrower); -is ( ($daysToAgeRestriction > 0), 1, 'FSK 16 blocked for a 15 year old' ); -($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('PEGI 15', $borrower); -is ( ($daysToAgeRestriction <= 0), 1, 'PEGI 15 allowed for a 15 year old' ); -($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('PEGI14', $borrower); -is ( ($daysToAgeRestriction <= 0), 1, 'PEGI14 allowed for a 15 year old' ); -($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('Age 10', $borrower); -is ( ($daysToAgeRestriction <= 0), 1, 'Age 10 allowed for a 15 year old' ); -($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('K18', $borrower); -is ( ($daysToAgeRestriction > 0), 1, 'K18 blocked for a 15 year old' ); +my $offset = 0; +while ($offset<24) { + Time::Fake->offset("+${offset}h"); + ##Testing age restriction for a borrower. + my $now = DateTime->now(); + my $borrower = {}; + C4::Members::SetAge( $borrower, '0015-00-00' ); + + my ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('FSK 16', $borrower); + is ( ($daysToAgeRestriction > 0), 1, 'FSK 16 blocked for a 15 year old - $offset hours' ); + ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('PEGI 15', $borrower); + is ( ($daysToAgeRestriction <= 0), 1, 'PEGI 15 allowed for a 15 year old - $offset hours' ); + ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('PEGI14', $borrower); + is ( ($daysToAgeRestriction <= 0), 1, 'PEGI14 allowed for a 15 year old - $offset hours' ); + ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('Age 10', $borrower); + is ( ($daysToAgeRestriction <= 0), 1, 'Age 10 allowed for a 15 year old - $offset hours' ); + ($restriction_age, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction('K18', $borrower); + is ( ($daysToAgeRestriction > 0), 1, 'K18 blocked for a 15 year old - $offset hours' ); + $offset++; +} --