10.April 2026
This commit is contained in:
parent
a00c42e770
commit
f58c709945
208 changed files with 19280 additions and 2914 deletions
53
tests/Unit/Services/AboHelperGetFirstAboDateTest.php
Normal file
53
tests/Unit/Services/AboHelperGetFirstAboDateTest.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
use App\Services\AboHelper;
|
||||
use Carbon\Carbon;
|
||||
|
||||
describe('getFirstAboDate', function () {
|
||||
beforeEach(function () {
|
||||
Carbon::setTestNow(Carbon::parse('2026-03-31 12:00:00', 'Europe/Berlin'));
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
Carbon::setTestNow();
|
||||
});
|
||||
|
||||
it('schiebt Liefertag 5 vom 31. März auf Mai, weil April unter 10 Tagen liegt', function () {
|
||||
$first = AboHelper::getFirstAboDate(now(), 5);
|
||||
|
||||
expect($first->format('Y-m-d'))->toBe('2026-05-05');
|
||||
});
|
||||
|
||||
it('behält Liefertag 10 im April, wenn genau 10 Tage Abstand', function () {
|
||||
$first = AboHelper::getFirstAboDate(now(), 10);
|
||||
|
||||
expect($first->format('Y-m-d'))->toBe('2026-04-10');
|
||||
});
|
||||
|
||||
it('schiebt Liefertag 9 auf Mai, wenn der April-Termin nur 9 Tage Abstand hat', function () {
|
||||
// 31. März 2026 -> nächster Kandidat 9. April (9 Tage), muss auf Mai rutschen
|
||||
$first = AboHelper::getFirstAboDate(now(), 9);
|
||||
|
||||
expect($first->format('Y-m-d'))->toBe('2026-05-09');
|
||||
});
|
||||
});
|
||||
|
||||
describe('calendarDaysUntil', function () {
|
||||
it('zählt Kalendertage, nicht 24h-Intervalle bei Tageszeit von now()', function () {
|
||||
Carbon::setTestNow(Carbon::parse('2026-03-31 14:30:00', 'Europe/Berlin'));
|
||||
|
||||
$apr10 = Carbon::parse('2026-04-10')->startOfDay();
|
||||
expect(AboHelper::calendarDaysUntil(now(), $apr10))->toBe(10);
|
||||
|
||||
Carbon::setTestNow();
|
||||
});
|
||||
|
||||
it('liefert für Liefertag 5 (Mai) genug Tage, dass die Warnung unter 20 Tage nicht greift', function () {
|
||||
Carbon::setTestNow(Carbon::parse('2026-03-31 12:00:00', 'Europe/Berlin'));
|
||||
$may5 = AboHelper::getFirstAboDate(now(), 5);
|
||||
|
||||
expect(AboHelper::calendarDaysUntil(now(), $may5))->toBeGreaterThanOrEqual(20);
|
||||
|
||||
Carbon::setTestNow();
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue