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

(-)a/t/db_dependent/Holidays.t (-44 / +2 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 17;
20
use Test::More tests => 12;
21
21
22
use DateTime;
22
use DateTime;
23
use DateTime::TimeZone;
23
use DateTime::TimeZone;
Lines 37-43 my $schema = Koha::Database->new->schema; Link Here
37
my $dbh = C4::Context->dbh;
37
my $dbh = C4::Context->dbh;
38
my $builder = t::lib::TestBuilder->new;
38
my $builder = t::lib::TestBuilder->new;
39
39
40
subtest 'exception_holidays() tests' => sub {
40
subtest 'is_holiday timezone tests' => sub {
41
41
42
    plan tests => 1;
42
    plan tests => 1;
43
43
Lines 160-206 C4::Calendar->new( branchcode => $branch_2 )->insert_single_holiday( Link Here
160
is( Koha::Calendar->new( branchcode => $branch_2 )->is_holiday( $today ), 1, "Today is a holiday for $branch_2" );
160
is( Koha::Calendar->new( branchcode => $branch_2 )->is_holiday( $today ), 1, "Today is a holiday for $branch_2" );
161
is( Koha::Calendar->new( branchcode => $branch_1 )->is_holiday( $today ), 0, "Today is not a holiday for $branch_1");
161
is( Koha::Calendar->new( branchcode => $branch_1 )->is_holiday( $today ), 0, "Today is not a holiday for $branch_1");
162
162
163
# Few tests for exception holidays
164
my ( $diff, $cal, $special );
165
$dbh->do("DELETE FROM special_holidays");
166
_add_exception( $today, $branch_1, 'Today' );
167
$cal = Koha::Calendar->new( branchcode => $branch_1 );
168
$special = $cal->exception_holidays;
169
is( keys %{$special}, 1, 'One exception holiday added' );
170
171
my $tomorrow= dt_from_string();
172
$tomorrow->add_duration( DateTime::Duration->new(days => 1) );
173
_add_exception( $tomorrow, $branch_1, 'Tomorrow' );
174
$cal = Koha::Calendar->new( branchcode => $branch_1 );
175
$special = $cal->exception_holidays;
176
is( keys %{$special}, 2, 'Set of exception holidays contains two dates' );
177
178
$diff = $today->delta_days( $today )->in_units('days');
179
is( $diff, 0, 'Lowest exception holiday is today' );
180
$diff = $tomorrow->delta_days( $tomorrow )->in_units('days');
181
is( $diff, 0, 'Highest exception holiday is tomorrow' );
182
183
C4::Calendar->new( branchcode => $branch_1 )->delete_holiday(
184
    weekday => $tomorrow->day_of_week,
185
    day     => $tomorrow->day,
186
    month   => $tomorrow->month,
187
    year    => $tomorrow->year,
188
);
189
$cal = Koha::Calendar->new( branchcode => $branch_1 );
190
$special = $cal->exception_holidays;
191
is( keys %{$special}, 1, 'Set of exception holidays back to one' );
192
193
sub _add_exception {
194
    my ( $dt, $branch, $descr ) = @_;
195
    C4::Calendar->new( branchcode => $branch )->insert_exception_holiday(
196
        day         => $dt->day,
197
        month       => $dt->month,
198
        year        => $dt->year,
199
        title       => $descr,
200
        description => $descr,
201
    );
202
}
203
204
$schema->storage->txn_rollback;
163
$schema->storage->txn_rollback;
205
164
206
subtest 'copy_to_branch' => sub {
165
subtest 'copy_to_branch' => sub {
207
- 

Return to bug 14315