File Coverage

File:t/Kalendar.t
Coverage:100.0%

linestmtbrancondsubtimecode
1
1
1
1
1.33283529693511e+15
23
26
use strict;
2
1
1
1
5
1
30
use warnings;
3
1
1
1
1
1
1
74
51
18
905
23
8
use 5.010;
4
1
1
1
155
183889
28
use DateTime;
5
1
1
1
10
1
18
use DateTime::TimeZone;
6
7
1
1
1
206
28
34
use C4::Context;
8
1
1
1
870
17814
56
use Test::More tests => 9;
9
10
1
1476
BEGIN { use_ok('Koha::Calendar'); }
11
12
1
445655
my $cal = Koha::Calendar->new( TEST_MODE => 1 );
13
14
1
24
isa_ok( $cal, 'Koha::Calendar', 'Calendar class returned' );
15
16
1
996
my $saturday = DateTime->new(
17    year => 2011,
18    month => 6,
19    day => 25,
20    time_zone => 'Europe/London',
21);
22
1
723
my $sunday = DateTime->new(
23    year => 2011,
24    month => 6,
25    day => 26,
26    time_zone => 'Europe/London',
27);
28
1
598
my $monday = DateTime->new(
29    year => 2011,
30    month => 6,
31    day => 27,
32    time_zone => 'Europe/London',
33);
34
1
602
my $bloomsday = DateTime->new(
35    year => 2011,
36    month => 6,
37    day => 16,
38    time_zone => 'Europe/London',
39); # should be a holiday
40
1
611
my $special = DateTime->new(
41    year => 2011,
42    month => 6,
43    day => 1,
44    time_zone => 'Europe/London',
45); # should be a holiday
46
1
919
my $notspecial = DateTime->new(
47    year => 2011,
48    month => 6,
49    day => 2,
50    time_zone => 'Europe/London',
51); # should NOT be a holiday
52
1
692
is( $cal->is_holiday($sunday), 1, 'Sunday is a closed day' ); # wee free test;
53
1
859
is( $cal->is_holiday($monday), 0, 'Monday is not a closed day' ); # alas
54
1
702
is( $cal->is_holiday($bloomsday), 1, 'month/day closed day test' );
55
1
1802
is( $cal->is_holiday($special), 1, 'special closed day test' );
56
1
629
is( $cal->is_holiday($notspecial), 0, 'open day test' );
57
58
1
673
my $dt = $cal->addDate( $saturday, 1, 'days' );
59
1
7
is( $dt->day_of_week, 1, 'addDate skips closed Sunday' );
60
61
1
686
$dt = $cal->addDate( $bloomsday, -1 );
62
1
10
cmp_ok( $dt->ymd(), 'cmp', '2011-06-15', 'Negative call to addDate' );