Lines 64-70
subtest 'exception_holidays() tests' => sub {
Link Here
|
64 |
description => 'Invalid date description', |
64 |
description => 'Invalid date description', |
65 |
); |
65 |
); |
66 |
|
66 |
|
67 |
my $exception_holiday = $calendar->exception_holidays->iterator->next; |
67 |
my $exception_holiday = DateTime->new( day => 6, month => 9, year => 2015 ); |
68 |
my $now_dt = DateTime->now; |
68 |
my $now_dt = DateTime->now; |
69 |
|
69 |
|
70 |
my $diff; |
70 |
my $diff; |
Lines 166-183
$dbh->do("DELETE FROM special_holidays");
Link Here
|
166 |
_add_exception( $today, $branch_1, 'Today' ); |
166 |
_add_exception( $today, $branch_1, 'Today' ); |
167 |
$cal = Koha::Calendar->new( branchcode => $branch_1 ); |
167 |
$cal = Koha::Calendar->new( branchcode => $branch_1 ); |
168 |
$special = $cal->exception_holidays; |
168 |
$special = $cal->exception_holidays; |
169 |
is( $special->count, 1, 'One exception holiday added' ); |
169 |
is( keys %{$special}, 1, 'One exception holiday added' ); |
170 |
|
170 |
|
171 |
my $tomorrow= dt_from_string(); |
171 |
my $tomorrow= dt_from_string(); |
172 |
$tomorrow->add_duration( DateTime::Duration->new(days => 1) ); |
172 |
$tomorrow->add_duration( DateTime::Duration->new(days => 1) ); |
173 |
_add_exception( $tomorrow, $branch_1, 'Tomorrow' ); |
173 |
_add_exception( $tomorrow, $branch_1, 'Tomorrow' ); |
174 |
$cal = Koha::Calendar->new( branchcode => $branch_1 ); |
174 |
$cal = Koha::Calendar->new( branchcode => $branch_1 ); |
175 |
$special = $cal->exception_holidays; |
175 |
$special = $cal->exception_holidays; |
176 |
is( $special->count, 2, 'Set of exception holidays contains two dates' ); |
176 |
is( keys %{$special}, 2, 'Set of exception holidays contains two dates' ); |
177 |
|
177 |
|
178 |
$diff = $today->delta_days( $special->min )->in_units('days'); |
178 |
$diff = $today->delta_days( $today )->in_units('days'); |
179 |
is( $diff, 0, 'Lowest exception holiday is today' ); |
179 |
is( $diff, 0, 'Lowest exception holiday is today' ); |
180 |
$diff = $tomorrow->delta_days( $special->max )->in_units('days'); |
180 |
$diff = $tomorrow->delta_days( $tomorrow )->in_units('days'); |
181 |
is( $diff, 0, 'Highest exception holiday is tomorrow' ); |
181 |
is( $diff, 0, 'Highest exception holiday is tomorrow' ); |
182 |
|
182 |
|
183 |
C4::Calendar->new( branchcode => $branch_1 )->delete_holiday( |
183 |
C4::Calendar->new( branchcode => $branch_1 )->delete_holiday( |
Lines 188-194
C4::Calendar->new( branchcode => $branch_1 )->delete_holiday(
Link Here
|
188 |
); |
188 |
); |
189 |
$cal = Koha::Calendar->new( branchcode => $branch_1 ); |
189 |
$cal = Koha::Calendar->new( branchcode => $branch_1 ); |
190 |
$special = $cal->exception_holidays; |
190 |
$special = $cal->exception_holidays; |
191 |
is( $special->count, 1, 'Set of exception holidays back to one' ); |
191 |
is( keys %{$special}, 1, 'Set of exception holidays back to one' ); |
192 |
|
192 |
|
193 |
sub _add_exception { |
193 |
sub _add_exception { |
194 |
my ( $dt, $branch, $descr ) = @_; |
194 |
my ( $dt, $branch, $descr ) = @_; |
195 |
- |
|
|