|
Lines 7-12
use DateTime::TimeZone;
Link Here
|
| 7 |
use C4::Context; |
7 |
use C4::Context; |
| 8 |
use Koha::DateUtils; |
8 |
use Koha::DateUtils; |
| 9 |
use Test::More tests => 12; |
9 |
use Test::More tests => 12; |
|
|
10 |
use C4::Branch; |
| 10 |
|
11 |
|
| 11 |
BEGIN { use_ok('Koha::Calendar'); } |
12 |
BEGIN { use_ok('Koha::Calendar'); } |
| 12 |
BEGIN { use_ok('C4::Calendar'); } |
13 |
BEGIN { use_ok('C4::Calendar'); } |
|
Lines 16-21
my $dbh = C4::Context->dbh();
Link Here
|
| 16 |
$dbh->{AutoCommit} = 0; |
17 |
$dbh->{AutoCommit} = 0; |
| 17 |
$dbh->{RaiseError} = 1; |
18 |
$dbh->{RaiseError} = 1; |
| 18 |
|
19 |
|
|
|
20 |
# Add branches if they don't exist |
| 21 |
if (not defined GetBranchDetail('CPL')) { |
| 22 |
ModBranch({add => 1, branchcode => 'CPL', branchname => 'Centerville'}); |
| 23 |
} |
| 24 |
if (not defined GetBranchDetail('MPL')) { |
| 25 |
ModBranch({add => 1, branchcode => 'MPL', branchname => 'Midway'}); |
| 26 |
} |
| 27 |
|
| 28 |
# Make the repeatable_holidays table ONLY the default data. |
| 29 |
$dbh->do("DELETE FROM repeatable_holidays"); |
| 30 |
C4::Calendar->new( branchcode => 'MPL' )->insert_week_day_holiday( |
| 31 |
weekday => 0, |
| 32 |
title => '', |
| 33 |
description => 'Sundays', |
| 34 |
); |
| 35 |
my $holiday2add = dt_from_string("2015-01-01"); |
| 36 |
C4::Calendar->new( branchcode => 'MPL' )->insert_day_month_holiday( |
| 37 |
day => $holiday2add->day(), |
| 38 |
month => $holiday2add->month(), |
| 39 |
year => $holiday2add->year(), |
| 40 |
title => '', |
| 41 |
description => "New Year's Day", |
| 42 |
); |
| 43 |
$holiday2add = dt_from_string("2014-12-25"); |
| 44 |
C4::Calendar->new( branchcode => 'MPL' )->insert_day_month_holiday( |
| 45 |
day => $holiday2add->day(), |
| 46 |
month => $holiday2add->month(), |
| 47 |
year => $holiday2add->year(), |
| 48 |
title => '', |
| 49 |
description => 'Christmas', |
| 50 |
); |
| 51 |
|
| 19 |
my $branchcode = 'MPL'; |
52 |
my $branchcode = 'MPL'; |
| 20 |
|
53 |
|
| 21 |
my $koha_calendar = Koha::Calendar->new( branchcode => $branchcode ); |
54 |
my $koha_calendar = Koha::Calendar->new( branchcode => $branchcode ); |
|
Lines 72-74
C4::Calendar->new( branchcode => 'CPL' )->insert_single_holiday(
Link Here
|
| 72 |
); |
105 |
); |
| 73 |
is( Koha::Calendar->new( branchcode => 'CPL' )->is_holiday( $today ), 1, "Today is a holiday for CPL" ); |
106 |
is( Koha::Calendar->new( branchcode => 'CPL' )->is_holiday( $today ), 1, "Today is a holiday for CPL" ); |
| 74 |
is( Koha::Calendar->new( branchcode => 'MPL' )->is_holiday( $today ), 0, "Today is not a holiday for MPL"); |
107 |
is( Koha::Calendar->new( branchcode => 'MPL' )->is_holiday( $today ), 0, "Today is not a holiday for MPL"); |
| 75 |
- |
108 |
|
|
|
109 |
$dbh->rollback; |