From 09002ac16a8f4d1d947cbc39b41aabe3fae10bc1 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Wed, 25 Jul 2012 10:55:56 +0100 Subject: [PATCH] Bug 8486 Merge Calendar test files Moves the tests previously in t/Kalendar.t to t/Calendar.t and removes the old file. Note the existing minimal test of C4/Calendar still called in t/Calendar --- t/Calendar.t | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++-- t/Kalendar.t | 62 ------------------------------------------------------------ 2 files changed, 52 insertions(+), 64 deletions(-) delete mode 100755 t/Kalendar.t diff --git a/t/Calendar.t b/t/Calendar.t index 65c2622..23c264d 100755 --- a/t/Calendar.t +++ b/t/Calendar.t @@ -3,7 +3,7 @@ use strict; use warnings; use DateTime; -use Test::More tests => 14; +use Test::More tests => 21; use Koha::DateUtils; BEGIN { @@ -16,7 +16,56 @@ BEGIN { my $cal = Koha::Calendar->new( TEST_MODE => 1 ); -isa_ok( $cal, 'Koha::Calendar' ); +isa_ok( $cal, 'Koha::Calendar', 'Calendar class returned' ); + +my $saturday = DateTime->new( + year => 2011, + month => 6, + day => 25, + time_zone => 'Europe/London', +); +my $sunday = DateTime->new( + year => 2011, + month => 6, + day => 26, + time_zone => 'Europe/London', +); +my $monday = DateTime->new( + year => 2011, + month => 6, + day => 27, + time_zone => 'Europe/London', +); +my $bloomsday = DateTime->new( + year => 2011, + month => 6, + day => 16, + time_zone => 'Europe/London', +); # should be a holiday +my $special = DateTime->new( + year => 2011, + month => 6, + day => 1, + time_zone => 'Europe/London', +); # should be a holiday +my $notspecial = DateTime->new( + year => 2011, + month => 6, + day => 2, + time_zone => 'Europe/London', +); # should NOT be a holiday + +is( $cal->is_holiday($sunday), 1, 'Sunday is a closed day' ); # wee free test; +is( $cal->is_holiday($monday), 0, 'Monday is not a closed day' ); # alas +is( $cal->is_holiday($bloomsday), 1, 'month/day closed day test' ); +is( $cal->is_holiday($special), 1, 'special closed day test' ); +is( $cal->is_holiday($notspecial), 0, 'open day test' ); + +my $dt = $cal->addDate( $saturday, 1, 'days' ); +is( $dt->day_of_week, 1, 'addDate skips closed Sunday' ); + +$dt = $cal->addDate( $bloomsday, -1 ); +is( $dt->ymd(), '2011-06-15', 'Negative call to addDate' ); my $test_dt = DateTime->new( # Monday year => 2012, @@ -78,3 +127,4 @@ $cal->add_holiday( dt_from_string('2012-07-07') ); $daycount = $cal->days_between( dt_from_string("2012-07-01"), dt_from_string("2012-07-15") )->in_units('days'); cmp_ok( $daycount, '==', 12, 'multiple holidays correctly recognized' ); + diff --git a/t/Kalendar.t b/t/Kalendar.t deleted file mode 100755 index 5d219b2..0000000 --- a/t/Kalendar.t +++ /dev/null @@ -1,62 +0,0 @@ -use strict; -use warnings; -use 5.010; -use DateTime; -use DateTime::TimeZone; - -use C4::Context; -use Test::More tests => 9; - -BEGIN { use_ok('Koha::Calendar'); } - -my $cal = Koha::Calendar->new( TEST_MODE => 1 ); - -isa_ok( $cal, 'Koha::Calendar', 'Calendar class returned' ); - -my $saturday = DateTime->new( - year => 2011, - month => 6, - day => 25, - time_zone => 'Europe/London', -); -my $sunday = DateTime->new( - year => 2011, - month => 6, - day => 26, - time_zone => 'Europe/London', -); -my $monday = DateTime->new( - year => 2011, - month => 6, - day => 27, - time_zone => 'Europe/London', -); -my $bloomsday = DateTime->new( - year => 2011, - month => 6, - day => 16, - time_zone => 'Europe/London', -); # should be a holiday -my $special = DateTime->new( - year => 2011, - month => 6, - day => 1, - time_zone => 'Europe/London', -); # should be a holiday -my $notspecial = DateTime->new( - year => 2011, - month => 6, - day => 2, - time_zone => 'Europe/London', -); # should NOT be a holiday -is( $cal->is_holiday($sunday), 1, 'Sunday is a closed day' ); # wee free test; -is( $cal->is_holiday($monday), 0, 'Monday is not a closed day' ); # alas -is( $cal->is_holiday($bloomsday), 1, 'month/day closed day test' ); -is( $cal->is_holiday($special), 1, 'special closed day test' ); -is( $cal->is_holiday($notspecial), 0, 'open day test' ); - -my $dt = $cal->addDate( $saturday, 1, 'days' ); -is( $dt->day_of_week, 1, 'addDate skips closed Sunday' ); - -$dt = $cal->addDate( $bloomsday, -1 ); -is( $dt->ymd(), '2011-06-15', 'Negative call to addDate' ); -- 1.7.11.2.249.g31c7954