|
Lines 18-24
Link Here
|
| 18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
use Test::More tests => 50; |
21 |
use Test::More tests => 56; |
| 22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
| 23 |
|
23 |
|
| 24 |
use t::lib::TestBuilder; |
24 |
use t::lib::TestBuilder; |
|
Lines 459-464
$calendar->copy_to_branch($branch2);
Link Here
|
| 459 |
#Check if branch2 is also closed tomorrow after copying from branch1 |
459 |
#Check if branch2 is also closed tomorrow after copying from branch1 |
| 460 |
is($calendar2->is_opened($tomorrow), 0, "$branch2 close tomorrow after copying from $branch1"); |
460 |
is($calendar2->is_opened($tomorrow), 0, "$branch2 close tomorrow after copying from $branch1"); |
| 461 |
|
461 |
|
|
|
462 |
my $calendar3 = Koha::DiscreteCalendar->new( { branchcode => $branch1 } ); |
| 463 |
|
| 464 |
# Base date |
| 465 |
my $monday = dt_from_string('2026-06-01'); # Monday |
| 466 |
my $tuesday = dt_from_string('2026-06-02'); # Tuesday |
| 467 |
my $wednesday = dt_from_string('2026-06-03'); # Wednesday |
| 468 |
my $thursday = dt_from_string('2026-06-04'); # Thursday |
| 469 |
my $friday = dt_from_string('2026-06-05'); # Friday |
| 470 |
my $saturday = dt_from_string('2026-06-06'); # Saturday |
| 471 |
$sunday = dt_from_string('2026-06-07'); # Sunday |
| 472 |
|
| 473 |
# Add holidays (exceptions = closed days) |
| 474 |
$calendar3->edit_holiday( |
| 475 |
{ |
| 476 |
title => "Holiday", |
| 477 |
holiday_type => $Koha::DiscreteCalendar::HOLIDAYS->{EXCEPTION}, |
| 478 |
start_date => $wednesday, |
| 479 |
end_date => $wednesday, |
| 480 |
} |
| 481 |
); |
| 482 |
|
| 483 |
$calendar3->edit_holiday( |
| 484 |
{ |
| 485 |
title => "Holiday", |
| 486 |
holiday_type => $Koha::DiscreteCalendar::HOLIDAYS->{EXCEPTION}, |
| 487 |
start_date => $saturday, |
| 488 |
end_date => $saturday, |
| 489 |
} |
| 490 |
); |
| 491 |
|
| 492 |
$calendar3->edit_holiday( |
| 493 |
{ |
| 494 |
title => "Holiday ", |
| 495 |
holiday_type => $Koha::DiscreteCalendar::HOLIDAYS->{EXCEPTION}, |
| 496 |
start_date => $sunday, |
| 497 |
end_date => $sunday, |
| 498 |
} |
| 499 |
); |
| 500 |
|
| 501 |
# Test 1: Business day between two business days |
| 502 |
is( |
| 503 |
$calendar->has_business_days_between( $monday, $wednesday ), 1, |
| 504 |
'Should find business day (Tuesday) between Monday and Wednesday' |
| 505 |
); |
| 506 |
|
| 507 |
# Test 2: No business days between consecutive business days |
| 508 |
is( |
| 509 |
$calendar->has_business_days_between( $monday, $tuesday ), 0, |
| 510 |
'Should find no business days between consecutive days' |
| 511 |
); |
| 512 |
|
| 513 |
# Test 3: Holiday between two business days |
| 514 |
is( |
| 515 |
$calendar->has_business_days_between( $tuesday, $thursday ), 0, |
| 516 |
'Should find no business days when only holiday (Wednesday) is between' |
| 517 |
); |
| 518 |
|
| 519 |
# Test 4: Multiple days with business days |
| 520 |
is( |
| 521 |
$calendar->has_business_days_between( $monday, $friday ), 1, |
| 522 |
'Should find business days between Monday and Friday' |
| 523 |
); |
| 524 |
|
| 525 |
# Test 5: Only holidays between dates |
| 526 |
is( |
| 527 |
$calendar->has_business_days_between( $friday, $sunday ), 0, |
| 528 |
'Should find no business days between Friday and Sunday (Saturday is holiday)' |
| 529 |
); |
| 530 |
|
| 531 |
# Test 6: Same date |
| 532 |
is( |
| 533 |
$calendar->has_business_days_between( $monday, $monday ), 0, |
| 534 |
'Should find no business days between same date' |
| 535 |
); |
| 536 |
|
| 462 |
$schema->storage->txn_rollback; |
537 |
$schema->storage->txn_rollback; |
| 463 |
|
538 |
|
| 464 |
1; |
539 |
1; |
| 465 |
- |
|
|