chore: major code cleanup and type safety using phpstan
This commit is contained in:
1 parent
060cbea9da
commit
3da73d626b
103 files changed
+976
-1192
No files matched your search
@@ -59,7 +59,7 @@ XML;
|
||||
$result = $anonymizer->anonymize($xml);
|
||||
|
||||
$document = new \DOMDocument();
|
||||
$this->assertTrue($document->loadXML($result));
|
||||
self::assertTrue($document->loadXML($result));
|
||||
|
||||
$xpath = new \DOMXPath($document);
|
||||
|
||||
@@ -70,13 +70,13 @@ XML;
|
||||
$participantOneMobilePhone = trim((string) $xpath->evaluate('string(//teilnehmer[@id="1"]/kommunikation/telefonmobil)'));
|
||||
$participantTwoName = trim((string) $xpath->evaluate('string(//teilnehmer[@id="2"]/name)'));
|
||||
|
||||
$this->assertNotSame('Schlegelmilch', $applicantName);
|
||||
$this->assertSame($applicantName, $participantOneName);
|
||||
$this->assertStringEndsWith('@example.com', $participantOneEmail);
|
||||
$this->assertNotSame('02212722760', $participantOneMobilePhone);
|
||||
$this->assertSame($applicantMobilePhone, $participantOneMobilePhone);
|
||||
$this->assertNotSame($participantOneName, $participantTwoName);
|
||||
$this->assertSame(2, $anonymizer->getLastIdentityCount());
|
||||
self::assertNotSame('Schlegelmilch', $applicantName);
|
||||
self::assertSame($applicantName, $participantOneName);
|
||||
self::assertStringEndsWith('@example.com', $participantOneEmail);
|
||||
self::assertNotSame('02212722760', $participantOneMobilePhone);
|
||||
self::assertSame($applicantMobilePhone, $participantOneMobilePhone);
|
||||
self::assertNotSame($participantOneName, $participantTwoName);
|
||||
self::assertSame(2, $anonymizer->getLastIdentityCount());
|
||||
}
|
||||
|
||||
public function testAnonymizeReplacesKundeAttributes(): void
|
||||
@@ -99,15 +99,15 @@ XML;
|
||||
$result = $anonymizer->anonymize($xml);
|
||||
|
||||
$document = new \DOMDocument();
|
||||
$this->assertTrue($document->loadXML($result));
|
||||
self::assertTrue($document->loadXML($result));
|
||||
|
||||
$xpath = new \DOMXPath($document);
|
||||
|
||||
$firstCustomerLastName = trim((string) $xpath->evaluate('string(//kunde[@id="1"]/@name)'));
|
||||
$firstCustomerFirstName = trim((string) $xpath->evaluate('string(//kunde[@id="1"]/@vorname)'));
|
||||
|
||||
$this->assertNotSame('Fromme', $firstCustomerLastName);
|
||||
$this->assertNotSame('Björn', $firstCustomerFirstName);
|
||||
self::assertNotSame('Fromme', $firstCustomerLastName);
|
||||
self::assertNotSame('Björn', $firstCustomerFirstName);
|
||||
}
|
||||
|
||||
public function testAnonymizeThrowsOnInvalidXml(): void
|
||||
@@ -157,15 +157,15 @@ XML;
|
||||
$result = $anonymizer->anonymize($xml);
|
||||
|
||||
$document = new \DOMDocument();
|
||||
$this->assertTrue($document->loadXML($result));
|
||||
self::assertTrue($document->loadXML($result));
|
||||
|
||||
$xpath = new \DOMXPath($document);
|
||||
|
||||
$applicantName = trim((string) $xpath->evaluate('string(//anmelder/name)'));
|
||||
$participantName = trim((string) $xpath->evaluate('string(//teilnehmer[@id="1"]/name)'));
|
||||
|
||||
$this->assertSame($applicantName, $participantName);
|
||||
$this->assertSame(1, $anonymizer->getLastIdentityCount());
|
||||
self::assertSame($applicantName, $participantName);
|
||||
self::assertSame(1, $anonymizer->getLastIdentityCount());
|
||||
}
|
||||
|
||||
public function testAnonymizeCanReuseIdentityAcrossMultipleXmlDocuments(): void
|
||||
@@ -205,16 +205,16 @@ XML;
|
||||
$anonymizedResponse = $anonymizer->anonymize($responseXml, false);
|
||||
|
||||
$requestDocument = new \DOMDocument();
|
||||
$this->assertTrue($requestDocument->loadXML($anonymizedRequest));
|
||||
self::assertTrue($requestDocument->loadXML($anonymizedRequest));
|
||||
$requestXpath = new \DOMXPath($requestDocument);
|
||||
$requestName = trim((string) $requestXpath->evaluate('string(//anmelder/name)'));
|
||||
|
||||
$responseDocument = new \DOMDocument();
|
||||
$this->assertTrue($responseDocument->loadXML($anonymizedResponse));
|
||||
self::assertTrue($responseDocument->loadXML($anonymizedResponse));
|
||||
$responseXpath = new \DOMXPath($responseDocument);
|
||||
$responseName = trim((string) $responseXpath->evaluate('string(//teilnehmer[@id="1"]/name)'));
|
||||
|
||||
$this->assertSame($requestName, $responseName);
|
||||
$this->assertSame(1, $anonymizer->getLastIdentityCount());
|
||||
self::assertSame($requestName, $responseName);
|
||||
self::assertSame(1, $anonymizer->getLastIdentityCount());
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,9 @@ class DomainConfigProviderTest extends TestCase
|
||||
|
||||
$config = $provider->getConfig();
|
||||
|
||||
$this->assertSame('custom', $config->theme);
|
||||
$this->assertSame('GTM-123', $config->gtmId);
|
||||
$this->assertSame('https://cmp.example.com', $config->cmpUrl);
|
||||
self::assertSame('custom', $config->theme);
|
||||
self::assertSame('GTM-123', $config->gtmId);
|
||||
self::assertSame('https://cmp.example.com', $config->cmpUrl);
|
||||
}
|
||||
|
||||
public function testReturnsConfigForSubdomainMatch(): void
|
||||
@@ -41,8 +41,8 @@ class DomainConfigProviderTest extends TestCase
|
||||
|
||||
$config = $provider->getConfig();
|
||||
|
||||
$this->assertSame('custom', $config->theme);
|
||||
$this->assertSame('GTM-456', $config->gtmId);
|
||||
self::assertSame('custom', $config->theme);
|
||||
self::assertSame('GTM-456', $config->gtmId);
|
||||
}
|
||||
|
||||
public function testReturnsDefaultConfigForUnknownDomain(): void
|
||||
@@ -57,9 +57,9 @@ class DomainConfigProviderTest extends TestCase
|
||||
|
||||
$config = $provider->getConfig();
|
||||
|
||||
$this->assertSame(DomainConfig::DEFAULT_THEME, $config->theme);
|
||||
$this->assertSame('', $config->gtmId);
|
||||
$this->assertSame('', $config->cmpUrl);
|
||||
self::assertSame(DomainConfig::DEFAULT_THEME, $config->theme);
|
||||
self::assertSame('', $config->gtmId);
|
||||
self::assertSame('', $config->cmpUrl);
|
||||
}
|
||||
|
||||
public function testReturnsDefaultConfigWhenNoRequest(): void
|
||||
@@ -69,7 +69,7 @@ class DomainConfigProviderTest extends TestCase
|
||||
|
||||
$config = $provider->getConfig();
|
||||
|
||||
$this->assertSame(DomainConfig::DEFAULT_THEME, $config->theme);
|
||||
self::assertSame(DomainConfig::DEFAULT_THEME, $config->theme);
|
||||
}
|
||||
|
||||
public function testHandlesMissingConfigValues(): void
|
||||
@@ -82,9 +82,9 @@ class DomainConfigProviderTest extends TestCase
|
||||
|
||||
$config = $provider->getConfig();
|
||||
|
||||
$this->assertSame('custom', $config->theme);
|
||||
$this->assertSame('', $config->gtmId);
|
||||
$this->assertSame('', $config->cmpUrl);
|
||||
self::assertSame('custom', $config->theme);
|
||||
self::assertSame('', $config->gtmId);
|
||||
self::assertSame('', $config->cmpUrl);
|
||||
}
|
||||
|
||||
public function testCachesConfigForSameHost(): void
|
||||
@@ -100,7 +100,7 @@ class DomainConfigProviderTest extends TestCase
|
||||
$config1 = $provider->getConfigForHost('example.com');
|
||||
$config2 = $provider->getConfigForHost('example.com');
|
||||
|
||||
$this->assertSame($config1, $config2);
|
||||
self::assertSame($config1, $config2);
|
||||
}
|
||||
|
||||
public function testFirstMatchWins(): void
|
||||
@@ -115,7 +115,7 @@ class DomainConfigProviderTest extends TestCase
|
||||
|
||||
$config = $provider->getConfig();
|
||||
|
||||
$this->assertSame('portal', $config->theme);
|
||||
self::assertSame('portal', $config->theme);
|
||||
}
|
||||
|
||||
public function testCaseInsensitiveMatching(): void
|
||||
@@ -128,7 +128,7 @@ class DomainConfigProviderTest extends TestCase
|
||||
|
||||
$config = $provider->getConfig();
|
||||
|
||||
$this->assertSame('custom', $config->theme);
|
||||
self::assertSame('custom', $config->theme);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,7 +24,7 @@ class ErrorCodeGeneratorTest extends TestCase
|
||||
{
|
||||
$result = $this->service->getErrorCode();
|
||||
|
||||
$this->assertNull($result);
|
||||
self::assertNull($result);
|
||||
}
|
||||
|
||||
public function testReturnsNullWithoutRequestId(): void
|
||||
@@ -34,7 +34,7 @@ class ErrorCodeGeneratorTest extends TestCase
|
||||
|
||||
$result = $this->service->getErrorCode();
|
||||
|
||||
$this->assertNull($result);
|
||||
self::assertNull($result);
|
||||
}
|
||||
|
||||
public function testGeneratesCodeWithRequestId(): void
|
||||
@@ -45,8 +45,8 @@ class ErrorCodeGeneratorTest extends TestCase
|
||||
|
||||
$result = $this->service->getErrorCode();
|
||||
|
||||
$this->assertNotNull($result);
|
||||
$this->assertMatchesRegularExpression('/^E-[A-Z0-9]{8}$/', $result);
|
||||
self::assertNotNull($result);
|
||||
self::assertMatchesRegularExpression('/^E-[A-Z0-9]{8}$/', $result);
|
||||
}
|
||||
|
||||
public function testGeneratesConsistentCodeForSameRequestId(): void
|
||||
@@ -58,7 +58,7 @@ class ErrorCodeGeneratorTest extends TestCase
|
||||
$result1 = $this->service->getErrorCode();
|
||||
$result2 = $this->service->getErrorCode();
|
||||
|
||||
$this->assertSame($result1, $result2);
|
||||
self::assertSame($result1, $result2);
|
||||
}
|
||||
|
||||
public function testGeneratesDifferentCodesForDifferentRequestIds(): void
|
||||
@@ -79,7 +79,7 @@ class ErrorCodeGeneratorTest extends TestCase
|
||||
$service2 = new ErrorCodeGenerator($this->requestStack);
|
||||
$result2 = $service2->getErrorCode();
|
||||
|
||||
$this->assertNotSame($result1, $result2);
|
||||
self::assertNotSame($result1, $result2);
|
||||
}
|
||||
|
||||
public function testSequenceSuffixesProduceSameCode(): void
|
||||
@@ -100,7 +100,7 @@ class ErrorCodeGeneratorTest extends TestCase
|
||||
$service2 = new ErrorCodeGenerator($this->requestStack);
|
||||
$result2 = $service2->getErrorCode();
|
||||
|
||||
$this->assertSame($result1, $result2);
|
||||
self::assertSame($result1, $result2);
|
||||
}
|
||||
|
||||
public function testSequenceSuffixMatchesBaseId(): void
|
||||
@@ -121,19 +121,19 @@ class ErrorCodeGeneratorTest extends TestCase
|
||||
$service2 = new ErrorCodeGenerator($this->requestStack);
|
||||
$result2 = $service2->getErrorCode();
|
||||
|
||||
$this->assertSame($result1, $result2);
|
||||
self::assertSame($result1, $result2);
|
||||
}
|
||||
|
||||
public function testHasErrorReturnsFalseByDefault(): void
|
||||
{
|
||||
$this->assertFalse($this->service->hasError());
|
||||
self::assertFalse($this->service->hasError());
|
||||
}
|
||||
|
||||
public function testMarkErrorOccurredSetsFlag(): void
|
||||
{
|
||||
$this->service->markErrorOccurred();
|
||||
|
||||
$this->assertTrue($this->service->hasError());
|
||||
self::assertTrue($this->service->hasError());
|
||||
}
|
||||
|
||||
public function testHasErrorRemainsTrueAfterMultipleCalls(): void
|
||||
@@ -141,6 +141,6 @@ class ErrorCodeGeneratorTest extends TestCase
|
||||
$this->service->markErrorOccurred();
|
||||
$this->service->markErrorOccurred();
|
||||
|
||||
$this->assertTrue($this->service->hasError());
|
||||
self::assertTrue($this->service->hasError());
|
||||
}
|
||||
}
|
||||
@@ -42,8 +42,8 @@ class InsuranceManagerTest extends TestCase
|
||||
|
||||
$result = $this->service->getSelectableInsurances($travel);
|
||||
|
||||
$this->assertCount(1, $result);
|
||||
$this->assertSame($regularInsurance, $result[0]);
|
||||
self::assertCount(1, $result);
|
||||
self::assertSame($regularInsurance, $result[0]);
|
||||
}
|
||||
|
||||
public function testGetSelectableInsurancesCachesResults(): void
|
||||
@@ -58,7 +58,7 @@ class InsuranceManagerTest extends TestCase
|
||||
$result1 = $this->service->getSelectableInsurances($travel);
|
||||
$result2 = $this->service->getSelectableInsurances($travel);
|
||||
|
||||
$this->assertSame($result1, $result2);
|
||||
self::assertSame($result1, $result2);
|
||||
}
|
||||
|
||||
public function testGetEligibleInsurancesWithMatchingCriteria(): void
|
||||
@@ -81,8 +81,8 @@ class InsuranceManagerTest extends TestCase
|
||||
|
||||
$result = $this->service->getEligibleInsurances([$insurance], $participant, $booking, 500.0);
|
||||
|
||||
$this->assertCount(1, $result);
|
||||
$this->assertContains($insurance, $result);
|
||||
self::assertCount(1, $result);
|
||||
self::assertContains($insurance, $result);
|
||||
}
|
||||
|
||||
public function testGetEligibleInsurancesExcludesInsuranceWithAgeTooYoung(): void
|
||||
@@ -94,7 +94,7 @@ class InsuranceManagerTest extends TestCase
|
||||
|
||||
$result = $this->service->getEligibleInsurances([$insurance], $participant, $booking, 500.0);
|
||||
|
||||
$this->assertEmpty($result);
|
||||
self::assertEmpty($result);
|
||||
}
|
||||
|
||||
public function testGetEligibleInsurancesExcludesInsuranceWithAgeTooOld(): void
|
||||
@@ -106,7 +106,7 @@ class InsuranceManagerTest extends TestCase
|
||||
|
||||
$result = $this->service->getEligibleInsurances([$insurance], $participant, $booking, 500.0);
|
||||
|
||||
$this->assertEmpty($result);
|
||||
self::assertEmpty($result);
|
||||
}
|
||||
|
||||
public function testGetEligibleInsurancesExcludesInsuranceWithTravelDateTooEarly(): void
|
||||
@@ -121,7 +121,7 @@ class InsuranceManagerTest extends TestCase
|
||||
|
||||
$result = $this->service->getEligibleInsurances([$insurance], $participant, $booking, 500.0);
|
||||
|
||||
$this->assertEmpty($result);
|
||||
self::assertEmpty($result);
|
||||
}
|
||||
|
||||
public function testGetEligibleInsurancesExcludesInsuranceWithTravelDateTooLate(): void
|
||||
@@ -136,7 +136,7 @@ class InsuranceManagerTest extends TestCase
|
||||
|
||||
$result = $this->service->getEligibleInsurances([$insurance], $participant, $booking, 500.0);
|
||||
|
||||
$this->assertEmpty($result);
|
||||
self::assertEmpty($result);
|
||||
}
|
||||
|
||||
public function testGetEligibleInsurancesExcludesInsuranceWithBookingDateTooEarly(): void
|
||||
@@ -151,7 +151,7 @@ class InsuranceManagerTest extends TestCase
|
||||
|
||||
$result = $this->service->getEligibleInsurances([$insurance], $participant, $booking, 500.0);
|
||||
|
||||
$this->assertEmpty($result);
|
||||
self::assertEmpty($result);
|
||||
}
|
||||
|
||||
public function testGetEligibleInsurancesExcludesInsuranceWithBookingDateTooLate(): void
|
||||
@@ -166,7 +166,7 @@ class InsuranceManagerTest extends TestCase
|
||||
|
||||
$result = $this->service->getEligibleInsurances([$insurance], $participant, $booking, 500.0);
|
||||
|
||||
$this->assertEmpty($result);
|
||||
self::assertEmpty($result);
|
||||
}
|
||||
|
||||
public function testGetEligibleInsurancesExcludesInsuranceWithTravelPriceTooLow(): void
|
||||
@@ -179,7 +179,7 @@ class InsuranceManagerTest extends TestCase
|
||||
|
||||
$result = $this->service->getEligibleInsurances([$insurance], $participant, $booking, 500.0);
|
||||
|
||||
$this->assertEmpty($result);
|
||||
self::assertEmpty($result);
|
||||
}
|
||||
|
||||
public function testGetEligibleInsurancesExcludesInsuranceWithTravelPriceTooHigh(): void
|
||||
@@ -192,7 +192,7 @@ class InsuranceManagerTest extends TestCase
|
||||
|
||||
$result = $this->service->getEligibleInsurances([$insurance], $participant, $booking, 500.0);
|
||||
|
||||
$this->assertEmpty($result);
|
||||
self::assertEmpty($result);
|
||||
}
|
||||
|
||||
public function testGetEligibleInsurancesExcludesInsuranceWithTravelDurationTooShort(): void
|
||||
@@ -204,7 +204,7 @@ class InsuranceManagerTest extends TestCase
|
||||
|
||||
$result = $this->service->getEligibleInsurances([$insurance], $participant, $booking, 500.0);
|
||||
|
||||
$this->assertEmpty($result);
|
||||
self::assertEmpty($result);
|
||||
}
|
||||
|
||||
public function testGetEligibleInsurancesExcludesInsuranceWithTravelDurationTooLong(): void
|
||||
@@ -216,7 +216,7 @@ class InsuranceManagerTest extends TestCase
|
||||
|
||||
$result = $this->service->getEligibleInsurances([$insurance], $participant, $booking, 500.0);
|
||||
|
||||
$this->assertEmpty($result);
|
||||
self::assertEmpty($result);
|
||||
}
|
||||
|
||||
public function testGetEligibleInsurancesHandlesParticipantWithoutBirthDate(): void
|
||||
@@ -232,9 +232,9 @@ class InsuranceManagerTest extends TestCase
|
||||
|
||||
// Participants without birth date should have insurances available
|
||||
// (field visibility is controlled by field state conditions, not service logic)
|
||||
$this->assertNotEmpty($result);
|
||||
$this->assertCount(1, $result);
|
||||
$this->assertSame($insurance, $result[0]);
|
||||
self::assertNotEmpty($result);
|
||||
self::assertCount(1, $result);
|
||||
self::assertSame($insurance, $result[0]);
|
||||
}
|
||||
|
||||
public function testGetEligibleInsurancesWithNullConstraints(): void
|
||||
@@ -247,8 +247,8 @@ class InsuranceManagerTest extends TestCase
|
||||
|
||||
$result = $this->service->getEligibleInsurances([$insurance], $participant, $booking, 500.0);
|
||||
|
||||
$this->assertCount(1, $result);
|
||||
$this->assertContains($insurance, $result);
|
||||
self::assertCount(1, $result);
|
||||
self::assertContains($insurance, $result);
|
||||
}
|
||||
|
||||
public function testGetEligibleInsurancesWithMultipleInsurances(): void
|
||||
@@ -263,10 +263,10 @@ class InsuranceManagerTest extends TestCase
|
||||
$insurances = [$eligibleInsurance1, $eligibleInsurance2, $ineligibleInsurance];
|
||||
$result = $this->service->getEligibleInsurances($insurances, $participant, $booking, 500.0);
|
||||
|
||||
$this->assertCount(2, $result);
|
||||
$this->assertContains($eligibleInsurance1, $result);
|
||||
$this->assertContains($eligibleInsurance2, $result);
|
||||
$this->assertNotContains($ineligibleInsurance, $result);
|
||||
self::assertCount(2, $result);
|
||||
self::assertContains($eligibleInsurance1, $result);
|
||||
self::assertContains($eligibleInsurance2, $result);
|
||||
self::assertNotContains($ineligibleInsurance, $result);
|
||||
}
|
||||
|
||||
public function testGetEligibleInsurancesWithAgeExactlyAtBoundary(): void
|
||||
@@ -278,8 +278,8 @@ class InsuranceManagerTest extends TestCase
|
||||
|
||||
$result = $this->service->getEligibleInsurances([$insurance], $participant, $booking, 500.0);
|
||||
|
||||
$this->assertCount(1, $result);
|
||||
$this->assertContains($insurance, $result);
|
||||
self::assertCount(1, $result);
|
||||
self::assertContains($insurance, $result);
|
||||
}
|
||||
|
||||
public function testGetEligibleInsurancesWithTravelDurationExactlyAtBoundary(): void
|
||||
@@ -291,8 +291,8 @@ class InsuranceManagerTest extends TestCase
|
||||
|
||||
$result = $this->service->getEligibleInsurances([$insurance], $participant, $booking, 500.0);
|
||||
|
||||
$this->assertCount(1, $result);
|
||||
$this->assertContains($insurance, $result);
|
||||
self::assertCount(1, $result);
|
||||
self::assertContains($insurance, $result);
|
||||
}
|
||||
|
||||
public function testFilterByTypeForPackages(): void
|
||||
@@ -319,9 +319,9 @@ class InsuranceManagerTest extends TestCase
|
||||
$insurances = [$packageInsurance1, $packageInsurance2, $differentPackage];
|
||||
$result = $this->service->filterByType($insurances, $packageInsurance1);
|
||||
|
||||
$this->assertCount(2, $result);
|
||||
$this->assertContains($packageInsurance1, $result);
|
||||
$this->assertContains($packageInsurance2, $result);
|
||||
self::assertCount(2, $result);
|
||||
self::assertContains($packageInsurance1, $result);
|
||||
self::assertContains($packageInsurance2, $result);
|
||||
}
|
||||
|
||||
public function testFilterByTypeForIndividualInsurances(): void
|
||||
@@ -348,9 +348,9 @@ class InsuranceManagerTest extends TestCase
|
||||
$insurances = [$insurance1, $insurance2, $differentType];
|
||||
$result = $this->service->filterByType($insurances, $insurance1);
|
||||
|
||||
$this->assertCount(2, $result);
|
||||
$this->assertContains($insurance1, $result);
|
||||
$this->assertContains($insurance2, $result);
|
||||
self::assertCount(2, $result);
|
||||
self::assertContains($insurance1, $result);
|
||||
self::assertContains($insurance2, $result);
|
||||
}
|
||||
|
||||
public function testReassignInsuranceForPriceChange(): void
|
||||
@@ -384,7 +384,7 @@ class InsuranceManagerTest extends TestCase
|
||||
500.0
|
||||
);
|
||||
|
||||
$this->assertSame($newTierInsurance, $result);
|
||||
self::assertSame($newTierInsurance, $result);
|
||||
}
|
||||
|
||||
public function testBatchAssignInsuranceToParticipants(): void
|
||||
@@ -420,9 +420,9 @@ class InsuranceManagerTest extends TestCase
|
||||
$participantPrices
|
||||
);
|
||||
|
||||
$this->assertCount(2, $result);
|
||||
$this->assertNotNull($result[0]);
|
||||
$this->assertNotNull($result[1]);
|
||||
self::assertCount(2, $result);
|
||||
self::assertNotNull($result[0]);
|
||||
self::assertNotNull($result[1]);
|
||||
}
|
||||
|
||||
private function createParticipant(string $dateOfBirth): ParticipantDto
|
||||
@@ -452,6 +452,9 @@ class InsuranceManagerTest extends TestCase
|
||||
return $travel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $properties
|
||||
*/
|
||||
private function createInsurance(array $properties = []): Insurance
|
||||
{
|
||||
$insurance = new Insurance();
|
||||
@@ -462,7 +465,25 @@ class InsuranceManagerTest extends TestCase
|
||||
$insurance->familyInsurance = false;
|
||||
|
||||
foreach ($properties as $property => $value) {
|
||||
$insurance->$property = $value;
|
||||
match ($property) {
|
||||
'id' => $insurance->id = (string) $value,
|
||||
'complementary' => $insurance->complementary = (bool) $value,
|
||||
'package' => $insurance->package = (bool) $value,
|
||||
'familyInsurance' => $insurance->familyInsurance = (bool) $value,
|
||||
'label' => $insurance->label = (string) $value,
|
||||
'subType' => $insurance->subType = null === $value ? null : (string) $value,
|
||||
'travelDateFrom' => $insurance->travelDateFrom = $value,
|
||||
'travelDateTo' => $insurance->travelDateTo = $value,
|
||||
'bookingDateFrom' => $insurance->bookingDateFrom = $value,
|
||||
'bookingDateTo' => $insurance->bookingDateTo = $value,
|
||||
'travelPriceFrom' => $insurance->travelPriceFrom = null === $value ? null : (float) $value,
|
||||
'travelPriceTo' => $insurance->travelPriceTo = null === $value ? null : (float) $value,
|
||||
'travelDurationFrom' => $insurance->travelDurationFrom = null === $value ? null : (int) $value,
|
||||
'travelDurationTo' => $insurance->travelDurationTo = null === $value ? null : (int) $value,
|
||||
'ageFrom' => $insurance->ageFrom = null === $value ? null : (int) $value,
|
||||
'ageTo' => $insurance->ageTo = null === $value ? null : (int) $value,
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
return $insurance;
|
||||
|
||||
@@ -34,7 +34,7 @@ class ParticipantEligibilityCheckerTest extends TestCase
|
||||
|
||||
$result = $this->service->isParticipantEligible($bookingDto, 0);
|
||||
|
||||
$this->assertTrue($result, 'Baby participant (1 year old) should be eligible regardless of ski pass availability');
|
||||
self::assertTrue($result, 'Baby participant (1 year old) should be eligible regardless of ski pass availability');
|
||||
}
|
||||
|
||||
public function testTwoYearOldParticipantIsEligibleAsBaby(): void
|
||||
@@ -50,7 +50,7 @@ class ParticipantEligibilityCheckerTest extends TestCase
|
||||
|
||||
$result = $this->service->isParticipantEligible($bookingDto, 0);
|
||||
|
||||
$this->assertTrue($result, 'Participant at BABY_MAX_AGE (2 years) should be eligible');
|
||||
self::assertTrue($result, 'Participant at BABY_MAX_AGE (2 years) should be eligible');
|
||||
}
|
||||
|
||||
public function testThreeYearOldParticipantIsNotBabyEligible(): void
|
||||
@@ -66,7 +66,7 @@ class ParticipantEligibilityCheckerTest extends TestCase
|
||||
|
||||
$result = $this->service->isParticipantEligible($bookingDto, 0);
|
||||
|
||||
$this->assertFalse($result, 'Participant over BABY_MAX_AGE (3 years) should not be eligible without ski passes');
|
||||
self::assertFalse($result, 'Participant over BABY_MAX_AGE (3 years) should not be eligible without ski passes');
|
||||
}
|
||||
|
||||
public function testAdultParticipantWithSkiPassIsEligible(): void
|
||||
@@ -82,7 +82,7 @@ class ParticipantEligibilityCheckerTest extends TestCase
|
||||
|
||||
$result = $this->service->isParticipantEligible($bookingDto, 0);
|
||||
|
||||
$this->assertTrue($result, 'Adult participant with available ski passes should be eligible');
|
||||
self::assertTrue($result, 'Adult participant with available ski passes should be eligible');
|
||||
}
|
||||
|
||||
public function testParticipantWithoutDateOfBirthIsNotEligible(): void
|
||||
@@ -98,7 +98,7 @@ class ParticipantEligibilityCheckerTest extends TestCase
|
||||
|
||||
$result = $this->service->isParticipantEligible($bookingDto, 0);
|
||||
|
||||
$this->assertFalse($result, 'Participant without date of birth should not be eligible');
|
||||
self::assertFalse($result, 'Participant without date of birth should not be eligible');
|
||||
}
|
||||
|
||||
public function testNewbornBabyIsEligible(): void
|
||||
@@ -114,7 +114,7 @@ class ParticipantEligibilityCheckerTest extends TestCase
|
||||
|
||||
$result = $this->service->isParticipantEligible($bookingDto, 0);
|
||||
|
||||
$this->assertTrue($result, 'Newborn baby (0 years old) should be eligible');
|
||||
self::assertTrue($result, 'Newborn baby (0 years old) should be eligible');
|
||||
}
|
||||
|
||||
public function testBabyAgeIsCalculatedAtTravelDate(): void
|
||||
@@ -135,7 +135,7 @@ class ParticipantEligibilityCheckerTest extends TestCase
|
||||
|
||||
$result = $this->service->isParticipantEligible($bookingDto, 0);
|
||||
|
||||
$this->assertTrue($result, 'Age should be calculated at travel date, not current date');
|
||||
self::assertTrue($result, 'Age should be calculated at travel date, not current date');
|
||||
}
|
||||
|
||||
private function createTravelWithNoSkiPasses(): Travel
|
||||
|
||||
@@ -293,6 +293,9 @@ class RoomAssignerTest extends TestCase
|
||||
self::assertNull($bookingDto->participants[1]->assignedRoomId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, array{roomId: int, quantity: int|null, capacity?: int}> $selections
|
||||
*/
|
||||
private function createBookingDtoWithRoomSelections(array $selections): BookingDto
|
||||
{
|
||||
$travel = new Travel();
|
||||
|
||||
Reference in new issue
Block a user