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

(-)a/t/Calendar.t (-2 / +52 lines)
Lines 3-9 Link Here
3
use strict;
3
use strict;
4
use warnings;
4
use warnings;
5
use DateTime;
5
use DateTime;
6
use Test::More tests => 14;
6
use Test::More tests => 21;
7
use Koha::DateUtils;
7
use Koha::DateUtils;
8
8
9
BEGIN {
9
BEGIN {
Lines 16-22 BEGIN { Link Here
16
16
17
my $cal = Koha::Calendar->new( TEST_MODE => 1 );
17
my $cal = Koha::Calendar->new( TEST_MODE => 1 );
18
18
19
isa_ok( $cal, 'Koha::Calendar' );
19
isa_ok( $cal, 'Koha::Calendar', 'Calendar class returned' );
20
21
my $saturday = DateTime->new(
22
    year      => 2011,
23
    month     => 6,
24
    day       => 25,
25
    time_zone => 'Europe/London',
26
);
27
my $sunday = DateTime->new(
28
    year      => 2011,
29
    month     => 6,
30
    day       => 26,
31
    time_zone => 'Europe/London',
32
);
33
my $monday = DateTime->new(
34
    year      => 2011,
35
    month     => 6,
36
    day       => 27,
37
    time_zone => 'Europe/London',
38
);
39
my $bloomsday = DateTime->new(
40
    year      => 2011,
41
    month     => 6,
42
    day       => 16,
43
    time_zone => 'Europe/London',
44
);    # should be a holiday
45
my $special = DateTime->new(
46
    year      => 2011,
47
    month     => 6,
48
    day       => 1,
49
    time_zone => 'Europe/London',
50
);    # should be a holiday
51
my $notspecial = DateTime->new(
52
    year      => 2011,
53
    month     => 6,
54
    day       => 2,
55
    time_zone => 'Europe/London',
56
);    # should NOT be a holiday
57
58
is( $cal->is_holiday($sunday), 1, 'Sunday is a closed day' );   # wee free test;
59
is( $cal->is_holiday($monday),     0, 'Monday is not a closed day' );    # alas
60
is( $cal->is_holiday($bloomsday),  1, 'month/day closed day test' );
61
is( $cal->is_holiday($special),    1, 'special closed day test' );
62
is( $cal->is_holiday($notspecial), 0, 'open day test' );
63
64
my $dt = $cal->addDate( $saturday, 1, 'days' );
65
is( $dt->day_of_week, 1, 'addDate skips closed Sunday' );
66
67
$dt = $cal->addDate( $bloomsday, -1 );
68
is( $dt->ymd(), '2011-06-15', 'Negative call to addDate' );
20
69
21
my $test_dt = DateTime->new(    # Monday
70
my $test_dt = DateTime->new(    # Monday
22
    year      => 2012,
71
    year      => 2012,
Lines 78-80 $cal->add_holiday( dt_from_string('2012-07-07') ); Link Here
78
$daycount = $cal->days_between( dt_from_string("2012-07-01"),
127
$daycount = $cal->days_between( dt_from_string("2012-07-01"),
79
    dt_from_string("2012-07-15") )->in_units('days');
128
    dt_from_string("2012-07-15") )->in_units('days');
80
cmp_ok( $daycount, '==', 12, 'multiple holidays correctly recognized' );
129
cmp_ok( $daycount, '==', 12, 'multiple holidays correctly recognized' );
130
(-)a/t/Kalendar.t (-63 lines)
Lines 1-62 Link Here
1
use strict;
2
use warnings;
3
use 5.010;
4
use DateTime;
5
use DateTime::TimeZone;
6
7
use C4::Context;
8
use Test::More tests => 9;
9
10
BEGIN { use_ok('Koha::Calendar'); }
11
12
my $cal = Koha::Calendar->new( TEST_MODE => 1 );
13
14
isa_ok( $cal, 'Koha::Calendar', 'Calendar class returned' );
15
16
my $saturday = DateTime->new(
17
    year      => 2011,
18
    month     => 6,
19
    day       => 25,
20
    time_zone => 'Europe/London',
21
);
22
my $sunday = DateTime->new(
23
    year      => 2011,
24
    month     => 6,
25
    day       => 26,
26
    time_zone => 'Europe/London',
27
);
28
my $monday = DateTime->new(
29
    year      => 2011,
30
    month     => 6,
31
    day       => 27,
32
    time_zone => 'Europe/London',
33
);
34
my $bloomsday = DateTime->new(
35
    year      => 2011,
36
    month     => 6,
37
    day       => 16,
38
    time_zone => 'Europe/London',
39
);    # should be a holiday
40
my $special = DateTime->new(
41
    year      => 2011,
42
    month     => 6,
43
    day       => 1,
44
    time_zone => 'Europe/London',
45
);    # should be a holiday
46
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
is( $cal->is_holiday($sunday), 1, 'Sunday is a closed day' );   # wee free test;
53
is( $cal->is_holiday($monday),     0, 'Monday is not a closed day' );    # alas
54
is( $cal->is_holiday($bloomsday),  1, 'month/day closed day test' );
55
is( $cal->is_holiday($special),    1, 'special closed day test' );
56
is( $cal->is_holiday($notspecial), 0, 'open day test' );
57
58
my $dt = $cal->addDate( $saturday, 1, 'days' );
59
is( $dt->day_of_week, 1, 'addDate skips closed Sunday' );
60
61
$dt = $cal->addDate( $bloomsday, -1 );
62
is( $dt->ymd(), '2011-06-15', 'Negative call to addDate' );
63
- 

Return to bug 8486