wip: insurance booking phase 4

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent 6c9da6537e
commit c67fa18ad3
2 changed files with 116 additions and 0 deletions
+82
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Tests\Form\Model;
use App\BusProNet\Model\Insurance;
use App\Form\Model\ParticipantDto;
use PHPUnit\Framework\TestCase;
@@ -122,4 +123,85 @@ class ParticipantDtoTest extends TestCase
$this->assertEquals(84, $result);
}
public function testHasInsuranceReturnsFalseWhenNoInsuranceSelected(): void
{
$participant = new ParticipantDto();
$participant->insurance = null;
$result = $participant->hasInsurance();
$this->assertFalse($result);
}
public function testHasInsuranceReturnsTrueWhenInsuranceSelected(): void
{
$participant = new ParticipantDto();
$participant->insurance = $this->createInsurance();
$result = $participant->hasInsurance();
$this->assertTrue($result);
}
public function testGetInsuranceLabelReturnsNullWhenNoInsurance(): void
{
$participant = new ParticipantDto();
$participant->insurance = null;
$result = $participant->getInsuranceLabel();
$this->assertNull($result);
}
public function testGetInsuranceLabelReturnsLabelWhenInsuranceSelected(): void
{
$participant = new ParticipantDto();
$participant->insurance = $this->createInsurance('Reise-Rücktritt');
$result = $participant->getInsuranceLabel();
$this->assertEquals('Reise-Rücktritt', $result);
}
public function testGetInsurancePriceReturnsZeroWhenNoInsurance(): void
{
$participant = new ParticipantDto();
$participant->insurance = null;
$result = $participant->getInsurancePrice();
$this->assertEquals(0.0, $result);
}
public function testGetInsurancePriceReturnsPriceWhenInsuranceSelected(): void
{
$participant = new ParticipantDto();
$participant->insurance = $this->createInsurance('Travel Insurance', 25.50);
$result = $participant->getInsurancePrice();
$this->assertEquals(25.50, $result);
}
public function testGetInsurancePriceReturnsZeroWhenInsuranceHasNullPrice(): void
{
$participant = new ParticipantDto();
$insurance = $this->createInsurance('Free Insurance');
$insurance->price = null;
$participant->insurance = $insurance;
$result = $participant->getInsurancePrice();
$this->assertEquals(0.0, $result);
}
private function createInsurance(string $label = 'Test Insurance', float $price = 10.0): Insurance
{
$insurance = new Insurance();
$insurance->label = $label;
$insurance->price = $price;
return $insurance;
}
}