chore: code cleanup with rector and php-cs-fixer

This commit is contained in:
Björn Fromme
2026-05-04 17:20:01 +02:00
parent d211425ff2
commit 1fa8f88a6d
38 changed files with 130 additions and 98 deletions
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Tests\BusProNet\Service;
use App\BusProNet\Model\Travel;
use App\BusProNet\Service\BookingStatusRuleRegistry;
use App\BusProNet\Service\Contract\BookingStatusRuleInterface;
use App\Form\Model\BookingDto;
@@ -98,9 +99,9 @@ class BookingStatusRuleRegistryTest extends TestCase
$this->assertSame('L', $registry->evaluateStatus($bookingDto));
}
private function createMockTravel(): \App\BusProNet\Model\Travel
private function createMockTravel(): Travel
{
$travel = new \App\BusProNet\Model\Travel();
$travel = new Travel();
$travel->id = 1;
$travel->hotelId = 1;
$travel->dateFrom = new \DateTimeImmutable('2030-01-01');
@@ -17,7 +17,6 @@ use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
+17 -12
View File
@@ -4,6 +4,11 @@ declare(strict_types=1);
namespace App\Tests\Form\Model;
use App\BusProNet\Model\Booking;
use App\BusProNet\Model\Address;
use App\Form\Model\AddressDto;
use App\BusProNet\Model\Service;
use App\BusProNet\Model\Insurance;
use App\BusProNet\Model\Travel;
use App\BusProNet\XmlLoader\AgencyLoader;
use App\Form\Model\BookingDto;
@@ -314,7 +319,7 @@ class ParticipantEditDtoTest extends TestCase
$bookingDto = new BookingDto($travel, 1); // hotelId must be int
// Create mock booking to simulate edit mode
$mockBooking = new \App\BusProNet\Model\Booking();
$mockBooking = new Booking();
$bookingDto->booking = $mockBooking;
// Create valid participants with all required fields for strict validation
@@ -322,7 +327,7 @@ class ParticipantEditDtoTest extends TestCase
$participant1->index = 0;
$participant1->mutable = false; // Immutable - strict validation applies
$participant1->mobile = '+49 123 456789'; // Required for applicant
$participant1->address = new \App\BusProNet\Model\Address();
$participant1->address = new Address();
$participant1->address->street = 'Test Street 1';
$participant1->address->postCode = '12345';
$participant1->address->city = 'Test City';
@@ -489,7 +494,7 @@ class ParticipantEditDtoTest extends TestCase
$participant->dateOfBirth = $travel->dateFrom->modify('-2 years');
$participant->index = 0;
$participant->mobile = '+49 123 456789';
$participant->address = new \App\BusProNet\Model\Address();
$participant->address = new Address();
$participant->address->street = 'Test Street 1';
$participant->address->postCode = '12345';
$participant->address->city = 'Test City';
@@ -526,7 +531,7 @@ class ParticipantEditDtoTest extends TestCase
$participant->dateOfBirth = $travel->dateFrom->modify('-3 years');
$participant->index = 0;
$participant->mobile = '+49 123 456789';
$participant->address = new \App\BusProNet\Model\Address();
$participant->address = new Address();
$participant->address->street = 'Test Street 1';
$participant->address->postCode = '12345';
$participant->address->city = 'Test City';
@@ -559,7 +564,7 @@ class ParticipantEditDtoTest extends TestCase
$bookingDto = new BookingDto($travel, 1);
// Create mock booking to simulate edit mode
$mockBooking = new \App\BusProNet\Model\Booking();
$mockBooking = new Booking();
$bookingDto->booking = $mockBooking;
// Create adult participant without ski pass in edit mode
@@ -568,7 +573,7 @@ class ParticipantEditDtoTest extends TestCase
$participant->index = 0;
$participant->mutable = false;
$participant->mobile = '+49 123 456789';
$participant->address = new \App\BusProNet\Model\Address();
$participant->address = new Address();
$participant->address->street = 'Test Street 1';
$participant->address->postCode = '12345';
$participant->address->city = 'Test City';
@@ -606,7 +611,7 @@ class ParticipantEditDtoTest extends TestCase
$participant->dateOfBirth = new \DateTimeImmutable('2023-06-02');
$participant->index = 0;
$participant->mobile = '+49 123 456789';
$participant->address = new \App\BusProNet\Model\Address();
$participant->address = new Address();
$participant->address->street = 'Test Street 1';
$participant->address->postCode = '12345';
$participant->address->city = 'Test City';
@@ -647,7 +652,7 @@ class ParticipantEditDtoTest extends TestCase
$participant->mobile = '+49 123 456789';
if (null === $participant->address) {
$participant->address = new \App\Form\Model\AddressDto();
$participant->address = new AddressDto();
}
$participant->address->street = 'Test Street 1';
$participant->address->postCode = '12345';
@@ -712,9 +717,9 @@ class ParticipantEditDtoTest extends TestCase
return $participant;
}
private function createMockService(): \App\BusProNet\Model\Service
private function createMockService(): Service
{
$service = new \App\BusProNet\Model\Service();
$service = new Service();
$service->id = 1;
$service->label = 'Test Service';
$service->subType = 'TEST';
@@ -723,9 +728,9 @@ class ParticipantEditDtoTest extends TestCase
return $service;
}
private function createMockInsurance(): \App\BusProNet\Model\Insurance
private function createMockInsurance(): Insurance
{
$insurance = new \App\BusProNet\Model\Insurance();
$insurance = new Insurance();
$insurance->id = '1';
$insurance->label = 'Test Insurance';
$insurance->price = 10.0;
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Tests\Model;
use PHPUnit\Framework\TestCase;
use App\Model\NewsletterSubscriptionRequest;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidatorFactory;
@@ -13,7 +14,7 @@ use Symfony\Component\Validator\Constraints\EmailValidator;
use Symfony\Component\Validator\Validation;
use Symfony\Component\Validator\Validator\ValidatorInterface;
class NewsletterSubscriptionRequestTest extends \PHPUnit\Framework\TestCase
class NewsletterSubscriptionRequestTest extends TestCase
{
public function testValidRequestPassesValidation(): void
{
@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace App\Tests\Service;
use App\Form\Model\BookingDto;
use App\Form\Model\ParticipantDto;
use App\BusProNet\Constants;
use App\BusProNet\Model\Room;
use App\BusProNet\Model\Service;
@@ -192,9 +194,9 @@ class BookingConfiguratorStatusTest extends TestCase
$travel->dateFrom = new \DateTimeImmutable('2030-01-01');
$travel->dateTo = new \DateTimeImmutable('2030-01-06');
$bookingDto = new \App\Form\Model\BookingDto($travel, 456);
$bookingDto = new BookingDto($travel, 456);
$bookingDto->bookingStatus = 'F';
$participant = new \App\Form\Model\ParticipantDto();
$participant = new ParticipantDto();
$participant->additionalServices = [new Service()];
$bookingDto->participants = [$participant];
@@ -223,7 +225,7 @@ class BookingConfiguratorStatusTest extends TestCase
$travel->dateFrom = new \DateTimeImmutable('2030-01-01');
$travel->dateTo = new \DateTimeImmutable('2030-01-06');
$bookingDto = new \App\Form\Model\BookingDto($travel, 456);
$bookingDto = new BookingDto($travel, 456);
$bookingDto->bookingStatus = 'A';
$bookingService->applyCreateBookingStatusRules($bookingDto);
+9 -8
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Tests\Service;
use App\BusProNet\ApiClient;
use App\BusProNet\Exception\ApiClientException;
use App\BusProNet\Exception\TimeoutException;
use App\BusProNet\Model\Booking;
@@ -87,7 +88,7 @@ class BookingEditSubmitterTest extends TestCase
->with($bookingDto, $freshBookingData)
->willReturn(false);
$apiClient = $this->createMock(\App\BusProNet\ApiClient::class);
$apiClient = $this->createMock(ApiClient::class);
$apiClient->expects($this->once())
->method('updateBooking')
->with($bookingDto, true)
@@ -137,7 +138,7 @@ class BookingEditSubmitterTest extends TestCase
->with($bookingDto, $freshBookingData)
->willReturn(false);
$apiClient = $this->createMock(\App\BusProNet\ApiClient::class);
$apiClient = $this->createMock(ApiClient::class);
$bookingUpdate = new BookingUpdate();
$bookingUpdate->success = false;
$bookingUpdate->status = 'BPN-FAIL';
@@ -200,7 +201,7 @@ class BookingEditSubmitterTest extends TestCase
->with($bookingDto, $freshBookingData)
->willReturn(false);
$apiClient = $this->createMock(\App\BusProNet\ApiClient::class);
$apiClient = $this->createMock(ApiClient::class);
$bookingUpdate = new BookingUpdate();
$bookingUpdate->success = true;
$apiClient->expects($this->once())
@@ -266,7 +267,7 @@ class BookingEditSubmitterTest extends TestCase
->with($bookingDto, $freshBookingData)
->willReturn(true);
$apiClient = $this->createMock(\App\BusProNet\ApiClient::class);
$apiClient = $this->createMock(ApiClient::class);
$bookingUpdate = new BookingUpdate();
$bookingUpdate->success = true;
$apiClient->expects($this->once())
@@ -350,7 +351,7 @@ class BookingEditSubmitterTest extends TestCase
->with($bookingDto, $freshBookingData)
->willReturn(false);
$apiClient = $this->createMock(\App\BusProNet\ApiClient::class);
$apiClient = $this->createMock(ApiClient::class);
$apiClient->expects($this->once())
->method('updateBooking')
->with($bookingDto, true)
@@ -400,7 +401,7 @@ class BookingEditSubmitterTest extends TestCase
->with($bookingDto, $freshBookingData)
->willReturn(false);
$apiClient = $this->createMock(\App\BusProNet\ApiClient::class);
$apiClient = $this->createMock(ApiClient::class);
$apiClient->expects($this->once())
->method('updateBooking')
->with($bookingDto, true)
@@ -421,7 +422,7 @@ class BookingEditSubmitterTest extends TestCase
}
private function createService(
?\App\BusProNet\ApiClient $apiClient = null,
?ApiClient $apiClient = null,
?BookingEditDataLoader $dataLoader = null,
?BookingEditDraftManager $draftService = null,
?TravelDataProvider $travelDataService = null,
@@ -429,7 +430,7 @@ class BookingEditSubmitterTest extends TestCase
?BookingSessionManager $bookingSessionService = null,
): BookingEditSubmitter {
return new BookingEditSubmitter(
$apiClient ?? $this->createMock(\App\BusProNet\ApiClient::class),
$apiClient ?? $this->createMock(ApiClient::class),
$dataLoader ?? $this->createMock(BookingEditDataLoader::class),
$draftService ?? $this->createMock(BookingEditDraftManager::class),
$travelDataService ?? $this->createMock(TravelDataProvider::class),
@@ -4,6 +4,9 @@ declare(strict_types=1);
namespace App\Tests\Service;
use Symfony\Component\Validator\ConstraintViolationListInterface;
use Symfony\Component\Validator\ConstraintViolationInterface;
use Symfony\Component\Validator\ConstraintViolationList;
use App\BusProNet\Model\Room;
use App\BusProNet\Model\Travel;
use App\Form\Model\BookingDto;
@@ -384,7 +387,7 @@ class ParticipantCardAssemblerTest extends TestCase
->willReturn([450.50]);
// Mock validator to return no violations (valid)
$violations = $this->createMock(\Symfony\Component\Validator\ConstraintViolationListInterface::class);
$violations = $this->createMock(ConstraintViolationListInterface::class);
$violations->expects($this->once())
->method('count')
->willReturn(0);
@@ -422,13 +425,13 @@ class ParticipantCardAssemblerTest extends TestCase
->willReturn([0.0]);
// Mock validator to return violations (invalid)
$violation = $this->createMock(\Symfony\Component\Validator\ConstraintViolationInterface::class);
$violation = $this->createMock(ConstraintViolationInterface::class);
$violation->expects($this->once())
->method('getMessage')
->willReturn('Diese E-Mail Adresse wird bereits von einem anderen Teilnehmer verwendet');
// Use ConstraintViolationList directly instead of mocking
$violations = new \Symfony\Component\Validator\ConstraintViolationList([$violation]);
$violations = new ConstraintViolationList([$violation]);
$this->validator
->expects($this->once())
@@ -473,7 +476,7 @@ class ParticipantCardAssemblerTest extends TestCase
->willReturn([450.0, 500.0]);
// Mock validator to return no violations for both participants
$violations = $this->createMock(\Symfony\Component\Validator\ConstraintViolationListInterface::class);
$violations = $this->createMock(ConstraintViolationListInterface::class);
$violations->expects($this->exactly(2))
->method('count')
->willReturn(0);