| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- declare(strict_types=1);
- namespace Tests\Unit\Services;
- use App\Models\ProductionCalendarDay;
- use App\Services\ProductionCalendarService;
- use Illuminate\Foundation\Testing\RefreshDatabase;
- use InvalidArgumentException;
- use Tests\TestCase;
- class ProductionCalendarServiceTest extends TestCase
- {
- use RefreshDatabase;
- public function test_it_skips_weekends_by_default(): void
- {
- $result = app(ProductionCalendarService::class)->addWorkingDays('2024-01-05', 1);
- $this->assertSame('2024-01-08', $result->toDateString());
- }
- public function test_calendar_override_can_mark_a_weekday_as_non_working(): void
- {
- ProductionCalendarDay::factory()->create([
- 'date' => '2024-01-08',
- 'is_working_day' => false,
- 'name' => 'Праздник',
- ]);
- $result = app(ProductionCalendarService::class)->addWorkingDays('2024-01-05', 1);
- $this->assertSame('2024-01-09', $result->toDateString());
- }
- public function test_calendar_override_can_mark_a_weekend_as_working(): void
- {
- ProductionCalendarDay::factory()->create([
- 'date' => '2024-01-06',
- 'is_working_day' => true,
- 'name' => 'Рабочая суббота',
- ]);
- $result = app(ProductionCalendarService::class)->addWorkingDays('2024-01-05', 1);
- $this->assertSame('2024-01-06', $result->toDateString());
- }
- public function test_negative_working_days_are_rejected(): void
- {
- $this->expectException(InvalidArgumentException::class);
- app(ProductionCalendarService::class)->addWorkingDays('2024-01-05', -1);
- }
- }
|