Teilnahmerechnungen erstellen
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Support\DateRange;
|
||||
use DateTime;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DateRangeTest extends TestCase
|
||||
{
|
||||
public function test_a_single_day_counts_as_one(): void
|
||||
{
|
||||
$day = new DateTime('2026-07-16');
|
||||
|
||||
$this->assertSame(1, DateRange::inclusiveDays($day, $day));
|
||||
}
|
||||
|
||||
public function test_both_ends_are_counted(): void
|
||||
{
|
||||
// An- und Abreisetag zählen beide mit.
|
||||
$this->assertSame(2, DateRange::inclusiveDays(new DateTime('2026-07-16'), new DateTime('2026-07-17')));
|
||||
$this->assertSame(5, DateRange::inclusiveDays(new DateTime('2026-07-16'), new DateTime('2026-07-20')));
|
||||
}
|
||||
|
||||
public function test_the_order_of_the_arguments_does_not_matter(): void
|
||||
{
|
||||
$early = new DateTime('2026-07-16');
|
||||
$late = new DateTime('2026-07-20');
|
||||
|
||||
$this->assertSame(
|
||||
DateRange::inclusiveDays($early, $late),
|
||||
DateRange::inclusiveDays($late, $early)
|
||||
);
|
||||
}
|
||||
|
||||
public function test_month_and_year_boundaries_are_handled(): void
|
||||
{
|
||||
$this->assertSame(3, DateRange::inclusiveDays(new DateTime('2026-07-30'), new DateTime('2026-08-01')));
|
||||
$this->assertSame(3, DateRange::inclusiveDays(new DateTime('2026-12-31'), new DateTime('2027-01-02')));
|
||||
// 2028 ist ein Schaltjahr.
|
||||
$this->assertSame(2, DateRange::inclusiveDays(new DateTime('2028-02-28'), new DateTime('2028-02-29')));
|
||||
}
|
||||
}
|
||||
@@ -55,10 +55,9 @@ class EventPaymentModuleRegistryTest extends TestCase
|
||||
// Überweisung: keine payer-seitigen Eingaben.
|
||||
$this->assertSame([], (new AccountTransferPaymentModule())->getParticipantOptions());
|
||||
|
||||
// Sonstiges: exemplarische Teilnehmer-Eingaben (Betrag + Passend-Checkbox).
|
||||
$undefined = (new UndefinedPaymentModule())->getParticipantOptions();
|
||||
$this->assertSame(['amount_brought', 'has_exact_amount'], array_column($undefined, 'name'));
|
||||
$this->assertSame('checkbox', $undefined[1]['type']);
|
||||
// Sonstiges (Barzahlung vor Ort): ebenfalls keine payer-seitigen Eingaben -- die Zahlungsart
|
||||
// beschreibt sich allein über den vom Veranstalter gepflegten Freitext.
|
||||
$this->assertSame([], (new UndefinedPaymentModule())->getParticipantOptions());
|
||||
}
|
||||
|
||||
public function test_participant_option_helpers(): void
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Support\Text;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TextTest extends TestCase
|
||||
{
|
||||
public function test_blank_input_becomes_null(): void
|
||||
{
|
||||
// Optionale Formularfelder kommen als Leerstring an, nicht als null.
|
||||
$this->assertNull(Text::nullIfBlank(null));
|
||||
$this->assertNull(Text::nullIfBlank(''));
|
||||
$this->assertNull(Text::nullIfBlank(' '));
|
||||
$this->assertNull(Text::nullIfBlank("\t\n"));
|
||||
}
|
||||
|
||||
public function test_content_is_kept_and_trimmed(): void
|
||||
{
|
||||
$this->assertSame('Musterweg 1', Text::nullIfBlank(' Musterweg 1 '));
|
||||
$this->assertSame('WM', Text::nullIfBlank('WM'));
|
||||
}
|
||||
|
||||
public function test_a_zero_is_content_not_emptiness(): void
|
||||
{
|
||||
// "0" ist falsy -- eine naive Prüfung mit `empty()` würde die Angabe verschlucken.
|
||||
$this->assertSame('0', Text::nullIfBlank('0'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user