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
@@ -71,16 +71,16 @@ class BookingDataProcessorTest extends TestCase
|
||||
|
||||
$result = $this->processor->createUpdateRequestPayload($formData);
|
||||
|
||||
$this->assertIsArray($result);
|
||||
$this->assertArrayHasKey('idbuchung', $result);
|
||||
$this->assertArrayHasKey('teilnehmerliste', $result);
|
||||
$this->assertArrayHasKey('zusatzleistungen', $result);
|
||||
$this->assertArrayHasKey('beförderungen', $result);
|
||||
$this->assertArrayHasKey('ferienzielunterbringungen', $result);
|
||||
self::assertIsArray($result);
|
||||
self::assertArrayHasKey('idbuchung', $result);
|
||||
self::assertArrayHasKey('teilnehmerliste', $result);
|
||||
self::assertArrayHasKey('zusatzleistungen', $result);
|
||||
self::assertArrayHasKey('beförderungen', $result);
|
||||
self::assertArrayHasKey('ferienzielunterbringungen', $result);
|
||||
|
||||
$this->assertEquals(123, $result['idbuchung']);
|
||||
$this->assertEquals('ACTIVE', $result['status']);
|
||||
$this->assertCount(2, $result['teilnehmerliste']['teilnehmer']);
|
||||
self::assertEquals(123, $result['idbuchung']);
|
||||
self::assertEquals('ACTIVE', $result['status']);
|
||||
self::assertCount(2, $result['teilnehmerliste']['teilnehmer']);
|
||||
}
|
||||
|
||||
public function testCanceledParticipantsAreSkipped(): void
|
||||
@@ -89,9 +89,9 @@ class BookingDataProcessorTest extends TestCase
|
||||
|
||||
$result = $this->processor->createUpdateRequestPayload($formData);
|
||||
|
||||
$this->assertCount(2, $result['teilnehmerliste']['teilnehmer']);
|
||||
$this->assertEquals(1, $result['teilnehmerliste']['teilnehmer'][0]['@id']);
|
||||
$this->assertEquals(2, $result['teilnehmerliste']['teilnehmer'][1]['@id']);
|
||||
self::assertCount(2, $result['teilnehmerliste']['teilnehmer']);
|
||||
self::assertEquals(1, $result['teilnehmerliste']['teilnehmer'][0]['@id']);
|
||||
self::assertEquals(2, $result['teilnehmerliste']['teilnehmer'][1]['@id']);
|
||||
}
|
||||
|
||||
public function testAdditionalServicesProcessing(): void
|
||||
@@ -100,13 +100,13 @@ class BookingDataProcessorTest extends TestCase
|
||||
|
||||
$result = $this->processor->createUpdateRequestPayload($formData);
|
||||
|
||||
$this->assertNotEmpty($result['zusatzleistungen']['zusatzleistung']);
|
||||
$this->assertCount(2, $result['zusatzleistungen']['zusatzleistung']);
|
||||
self::assertNotEmpty($result['zusatzleistungen']['zusatzleistung']);
|
||||
self::assertCount(2, $result['zusatzleistungen']['zusatzleistung']);
|
||||
|
||||
$service = $result['zusatzleistungen']['zusatzleistung'][0];
|
||||
$this->assertEquals(1, $service['@idleistung']);
|
||||
$this->assertEquals(1, $service['@anzahl']);
|
||||
$this->assertEquals('1', $service['@zuordnung']);
|
||||
self::assertEquals(1, $service['@idleistung']);
|
||||
self::assertEquals(1, $service['@anzahl']);
|
||||
self::assertEquals('1', $service['@zuordnung']);
|
||||
}
|
||||
|
||||
public function testTransportationServicesProcessing(): void
|
||||
@@ -115,8 +115,8 @@ class BookingDataProcessorTest extends TestCase
|
||||
|
||||
$result = $this->processor->createUpdateRequestPayload($formData);
|
||||
|
||||
$this->assertNotEmpty($result['beförderungen']['beförderung']);
|
||||
$this->assertCount(2, $result['beförderungen']['beförderung']);
|
||||
self::assertNotEmpty($result['beförderungen']['beförderung']);
|
||||
self::assertCount(2, $result['beförderungen']['beförderung']);
|
||||
}
|
||||
|
||||
public function testBusPickupLocationsProcessing(): void
|
||||
@@ -125,9 +125,9 @@ class BookingDataProcessorTest extends TestCase
|
||||
|
||||
$result = $this->processor->createUpdateRequestPayload($formData);
|
||||
|
||||
$this->assertArrayHasKey('zustiege', $result);
|
||||
$this->assertNotEmpty($result['zustiege']['zustieg']);
|
||||
$this->assertEquals(1, $result['zustiege']['zustieg'][0]['@idzustieg']);
|
||||
self::assertArrayHasKey('zustiege', $result);
|
||||
self::assertNotEmpty($result['zustiege']['zustieg']);
|
||||
self::assertEquals(1, $result['zustiege']['zustieg'][0]['@idzustieg']);
|
||||
}
|
||||
|
||||
public function testNonBusTransportationSkipsPickup(): void
|
||||
@@ -136,8 +136,8 @@ class BookingDataProcessorTest extends TestCase
|
||||
|
||||
$result = $this->processor->createUpdateRequestPayload($formData);
|
||||
|
||||
$this->assertArrayHasKey('zustiege', $result);
|
||||
$this->assertSame([], $result['zustiege']);
|
||||
self::assertArrayHasKey('zustiege', $result);
|
||||
self::assertSame([], $result['zustiege']);
|
||||
}
|
||||
|
||||
public function testUnusedServicesAreRemoved(): void
|
||||
@@ -146,8 +146,8 @@ class BookingDataProcessorTest extends TestCase
|
||||
|
||||
$result = $this->processor->createUpdateRequestPayload($formData);
|
||||
|
||||
$this->assertEmpty($result['zusatzleistungen']['zusatzleistung']);
|
||||
$this->assertEmpty($result['beförderungen']['beförderung']);
|
||||
self::assertEmpty($result['zusatzleistungen']['zusatzleistung']);
|
||||
self::assertEmpty($result['beförderungen']['beförderung']);
|
||||
}
|
||||
|
||||
public function testParticipantPersonalDataUpdate(): void
|
||||
@@ -157,10 +157,10 @@ class BookingDataProcessorTest extends TestCase
|
||||
$this->processor->createUpdateRequestPayload($formData);
|
||||
|
||||
$participant = $formData->booking->participants[0];
|
||||
$this->assertEquals('Updated', $participant->firstName);
|
||||
$this->assertEquals('Participant', $participant->name);
|
||||
$this->assertEquals('[email protected]', $participant->communication->email);
|
||||
$this->assertEquals('+49123456789', $participant->communication->mobile);
|
||||
self::assertEquals('Updated', $participant->firstName);
|
||||
self::assertEquals('Participant', $participant->name);
|
||||
self::assertEquals('[email protected]', $participant->communication->email);
|
||||
self::assertEquals('+49123456789', $participant->communication->mobile);
|
||||
}
|
||||
|
||||
public function testCanceledParticipantsPersonalDataIsUpdated(): void
|
||||
@@ -170,8 +170,8 @@ class BookingDataProcessorTest extends TestCase
|
||||
$this->processor->createUpdateRequestPayload($formData);
|
||||
|
||||
$participant = $formData->booking->participants[0];
|
||||
$this->assertEquals('Updated', $participant->firstName);
|
||||
$this->assertEquals('Participant', $participant->name);
|
||||
self::assertEquals('Updated', $participant->firstName);
|
||||
self::assertEquals('Participant', $participant->name);
|
||||
}
|
||||
|
||||
public function testApplicantDataSyncWithFirstParticipant(): void
|
||||
@@ -183,9 +183,9 @@ class BookingDataProcessorTest extends TestCase
|
||||
$applicant = $formData->booking->applicant;
|
||||
$firstParticipant = $formData->booking->participants[0];
|
||||
|
||||
$this->assertEquals($firstParticipant->height, $applicant->height);
|
||||
$this->assertEquals($firstParticipant->weight, $applicant->weight);
|
||||
$this->assertEquals($firstParticipant->shoeSize, $applicant->shoeSize);
|
||||
self::assertEquals($firstParticipant->height, $applicant->height);
|
||||
self::assertEquals($firstParticipant->weight, $applicant->weight);
|
||||
self::assertEquals($firstParticipant->shoeSize, $applicant->shoeSize);
|
||||
}
|
||||
|
||||
public function testBankAccountIncludedInPayload(): void
|
||||
@@ -194,9 +194,9 @@ class BookingDataProcessorTest extends TestCase
|
||||
|
||||
$result = $this->processor->createUpdateRequestPayload($formData);
|
||||
|
||||
$this->assertArrayHasKey('bankverbindung', $result['zahlung']);
|
||||
$this->assertEquals('Test Bank', $result['zahlung']['bankverbindung']['@kreditinstitut']);
|
||||
$this->assertEquals('DE89370400440532013000', $result['zahlung']['bankverbindung']['@iban']);
|
||||
self::assertArrayHasKey('bankverbindung', $result['zahlung']);
|
||||
self::assertEquals('Test Bank', $result['zahlung']['bankverbindung']['@kreditinstitut']);
|
||||
self::assertEquals('DE89370400440532013000', $result['zahlung']['bankverbindung']['@iban']);
|
||||
}
|
||||
|
||||
public function testBankAccountNotIncludedWhenNull(): void
|
||||
@@ -205,7 +205,7 @@ class BookingDataProcessorTest extends TestCase
|
||||
|
||||
$result = $this->processor->createUpdateRequestPayload($formData);
|
||||
|
||||
$this->assertArrayNotHasKey('bankverbindung', $result['zahlung']);
|
||||
self::assertArrayNotHasKey('bankverbindung', $result['zahlung']);
|
||||
}
|
||||
|
||||
public function testAccommodationRoomsProcessing(): void
|
||||
@@ -214,13 +214,13 @@ class BookingDataProcessorTest extends TestCase
|
||||
|
||||
$result = $this->processor->createUpdateRequestPayload($formData);
|
||||
|
||||
$this->assertNotEmpty($result['ferienzielunterbringungen']['ferienzielunterbringung']);
|
||||
self::assertNotEmpty($result['ferienzielunterbringungen']['ferienzielunterbringung']);
|
||||
|
||||
$room = $result['ferienzielunterbringungen']['ferienzielunterbringung'][0];
|
||||
$this->assertEquals(1, $room['@idzimmer']);
|
||||
$this->assertEquals('DOUBLE', $room['@kategorie']);
|
||||
$this->assertEquals('01.01.2024', $room['@anreise']);
|
||||
$this->assertEquals('07.01.2024', $room['@abreise']);
|
||||
self::assertEquals(1, $room['@idzimmer']);
|
||||
self::assertEquals('DOUBLE', $room['@kategorie']);
|
||||
self::assertEquals('01.01.2024', $room['@anreise']);
|
||||
self::assertEquals('07.01.2024', $room['@abreise']);
|
||||
}
|
||||
|
||||
public function testCommunicationObjectCreation(): void
|
||||
@@ -230,8 +230,8 @@ class BookingDataProcessorTest extends TestCase
|
||||
$this->processor->createUpdateRequestPayload($formData);
|
||||
|
||||
$participant = $formData->booking->participants[0];
|
||||
$this->assertInstanceOf(Communication::class, $participant->communication);
|
||||
$this->assertEquals('[email protected]', $participant->communication->email);
|
||||
self::assertInstanceOf(Communication::class, $participant->communication);
|
||||
self::assertEquals('[email protected]', $participant->communication->email);
|
||||
}
|
||||
|
||||
public function testEmptyPickupsToDoesNotCreateZustiegeSection(): void
|
||||
@@ -240,8 +240,8 @@ class BookingDataProcessorTest extends TestCase
|
||||
|
||||
$result = $this->processor->createUpdateRequestPayload($formData);
|
||||
|
||||
$this->assertArrayHasKey('zustiege', $result);
|
||||
$this->assertSame([], $result['zustiege']);
|
||||
self::assertArrayHasKey('zustiege', $result);
|
||||
self::assertSame([], $result['zustiege']);
|
||||
}
|
||||
|
||||
private function createCompleteFormData(): BookingDto
|
||||
@@ -543,13 +543,13 @@ class BookingDataProcessorTest extends TestCase
|
||||
|
||||
// Canceled participant (index 1) should have default names filled
|
||||
$canceledParticipant = $formData->booking->participants[1];
|
||||
$this->assertEquals('Teilnehmer:in 2', $canceledParticipant->firstName);
|
||||
$this->assertEquals('Teilnehmer:in 2', $canceledParticipant->name);
|
||||
self::assertEquals('Teilnehmer:in 2', $canceledParticipant->firstName);
|
||||
self::assertEquals('Teilnehmer:in 2', $canceledParticipant->name);
|
||||
|
||||
// Active participant (index 0) should retain original names from form
|
||||
$activeParticipant = $formData->booking->participants[0];
|
||||
$this->assertEquals('Participant0', $activeParticipant->firstName);
|
||||
$this->assertEquals('LastName', $activeParticipant->name);
|
||||
self::assertEquals('Participant0', $activeParticipant->firstName);
|
||||
self::assertEquals('LastName', $activeParticipant->name);
|
||||
}
|
||||
|
||||
public function testCanceledParticipantNamesNotFilledForNonAgencyBooking(): void
|
||||
@@ -560,8 +560,8 @@ class BookingDataProcessorTest extends TestCase
|
||||
|
||||
// Canceled participant should retain empty names (non-agency booking)
|
||||
$canceledParticipant = $formData->booking->participants[1];
|
||||
$this->assertEquals('', $canceledParticipant->firstName);
|
||||
$this->assertEquals('', $canceledParticipant->name);
|
||||
self::assertEquals('', $canceledParticipant->firstName);
|
||||
self::assertEquals('', $canceledParticipant->name);
|
||||
}
|
||||
|
||||
public function testConfirmedParticipantEmptyNamesFilledForAgencyBooking(): void
|
||||
@@ -572,13 +572,13 @@ class BookingDataProcessorTest extends TestCase
|
||||
|
||||
// Confirmed participant (index 1) with empty names should have default names filled
|
||||
$participant = $formData->booking->participants[1];
|
||||
$this->assertEquals('Teilnehmer:in 2', $participant->firstName);
|
||||
$this->assertEquals('Teilnehmer:in 2', $participant->name);
|
||||
self::assertEquals('Teilnehmer:in 2', $participant->firstName);
|
||||
self::assertEquals('Teilnehmer:in 2', $participant->name);
|
||||
|
||||
// Active participant (index 0) should retain original names from form
|
||||
$activeParticipant = $formData->booking->participants[0];
|
||||
$this->assertEquals('Participant0', $activeParticipant->firstName);
|
||||
$this->assertEquals('LastName', $activeParticipant->name);
|
||||
self::assertEquals('Participant0', $activeParticipant->firstName);
|
||||
self::assertEquals('LastName', $activeParticipant->name);
|
||||
}
|
||||
|
||||
public function testConfirmedParticipantPartialEmptyNameFilledForAgencyBooking(): void
|
||||
@@ -589,8 +589,8 @@ class BookingDataProcessorTest extends TestCase
|
||||
|
||||
// Participant with lastName but empty firstName should get default firstName only
|
||||
$participant = $formData->booking->participants[1];
|
||||
$this->assertEquals('Teilnehmer:in 2', $participant->firstName);
|
||||
$this->assertEquals('Schnekenburger', $participant->name);
|
||||
self::assertEquals('Teilnehmer:in 2', $participant->firstName);
|
||||
self::assertEquals('Schnekenburger', $participant->name);
|
||||
}
|
||||
|
||||
private function createFormDataWithConfirmedParticipantEmptyNames(): BookingDto
|
||||
|
||||
Reference in new issue
Block a user