wip: insurance booking in edit flow

This commit is contained in:
Björn Fromme
2025-10-07 18:09:16 +02:00
parent 7304fb50c6
commit c3008d7f7a
10 changed files with 1215 additions and 0 deletions
+66
View File
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Tests\BusProNet\Model;
use App\BusProNet\Model\Booking;
use App\BusProNet\Model\Insurance;
use App\BusProNet\Model\Service;
use PHPUnit\Framework\TestCase;
@@ -69,4 +70,69 @@ class BookingTest extends TestCase
$result = $booking->getSkiPassForParticipant(0);
$this->assertNull($result);
}
public function testGetInsuranceForParticipantReturnsCorrectInsurance(): void
{
$booking = new Booking();
// Create insurance for participants 0 and 2
$insurance1 = new Insurance();
$insurance1->id = 100;
$insurance1->label = 'Reiseschutz Platin';
$insurance1->mapping = [0, 2];
// Create insurance for participant 1
$insurance2 = new Insurance();
$insurance2->id = 200;
$insurance2->label = 'Reiseschutz Gold';
$insurance2->mapping = [1];
$booking->insurances = [
100 => $insurance1,
200 => $insurance2,
];
// Test: participant 0 should get insurance1
$result = $booking->getInsuranceForParticipant(0);
$this->assertSame($insurance1, $result);
$this->assertEquals(100, $result->id);
// Test: participant 1 should get insurance2
$result = $booking->getInsuranceForParticipant(1);
$this->assertSame($insurance2, $result);
$this->assertEquals(200, $result->id);
// Test: participant 2 should get insurance1
$result = $booking->getInsuranceForParticipant(2);
$this->assertSame($insurance1, $result);
// Test: participant 3 should get null (no insurance assigned)
$result = $booking->getInsuranceForParticipant(3);
$this->assertNull($result);
}
public function testGetInsuranceForParticipantReturnsNullWhenNoInsurances(): void
{
$booking = new Booking();
$booking->insurances = [];
$result = $booking->getInsuranceForParticipant(0);
$this->assertNull($result);
}
public function testGetInsuranceForParticipantHandlesEmptyMapping(): void
{
$booking = new Booking();
// Create insurance with empty mapping
$insurance = new Insurance();
$insurance->id = 100;
$insurance->label = 'Reiseschutz';
$insurance->mapping = [];
$booking->insurances = [100 => $insurance];
$result = $booking->getInsuranceForParticipant(0);
$this->assertNull($result, 'Should return null when mapping is empty');
}
}