base commit

This commit is contained in:
Mekan1206
2026-07-30 17:24:40 +05:00
commit a794dacd39
345 changed files with 29597 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
use App\Services\Leave\LeaveDaysCalculator;
use Carbon\Carbon;
beforeEach(function (): void {
$this->calculator = new LeaveDaysCalculator;
});
it('calculates inclusive calendar days between two dates', function (): void {
config(['hr.leave_calculation' => 'calendar']);
$days = $this->calculator->between(
Carbon::parse('2025-01-06'),
Carbon::parse('2025-01-12'),
);
expect($days)->toBe(7);
});
it('calculates business days excluding weekends', function (): void {
config(['hr.leave_calculation' => 'business']);
$days = $this->calculator->between(
Carbon::parse('2025-01-06'),
Carbon::parse('2025-01-12'),
);
expect($days)->toBe(5);
});
it('returns zero when the end date is before the start date', function (): void {
config(['hr.leave_calculation' => 'calendar']);
$days = $this->calculator->between(
Carbon::parse('2025-01-10'),
Carbon::parse('2025-01-06'),
);
expect($days)->toBe(0);
});
it('counts a single day when start and end are the same', function (): void {
config(['hr.leave_calculation' => 'calendar']);
$days = $this->calculator->between(
Carbon::parse('2025-01-06'),
Carbon::parse('2025-01-06'),
);
expect($days)->toBe(1);
});