chore: code cleanup with rector and php-cs-fixer
This commit is contained in:
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\BusProNet\DataProcessor;
|
||||
|
||||
use App\BusProNet\Model\Booking;
|
||||
use App\BusProNet\Model\Service;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -120,7 +121,7 @@ class ParticipantServiceProcessor
|
||||
*
|
||||
* @param ParticipantDto $participant The participant data
|
||||
*
|
||||
* @return array<\App\BusProNet\Model\Service> Array of services selected by this participant
|
||||
* @return array<Service> Array of services selected by this participant
|
||||
*/
|
||||
private function collectParticipantAdditionalServices(ParticipantDto $participant): array
|
||||
{
|
||||
|
||||
@@ -6,7 +6,6 @@ use App\BusProNet\Constants;
|
||||
use App\BusProNet\Model\Address;
|
||||
use App\BusProNet\Model\BankAccount;
|
||||
use App\BusProNet\Model\Booking;
|
||||
use App\BusProNet\Model\Communication;
|
||||
use App\BusProNet\Model\PersonalData;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ namespace App\Command;
|
||||
use App\BusProNet\Model\XmlExportInfo;
|
||||
use App\Model\BpnXmlSnapshotRefreshResult;
|
||||
use App\Model\BpnXmlSyncTarget;
|
||||
use App\Service\BpnXmlSyncManager;
|
||||
use App\Service\BpnXmlSnapshotRefreshManager;
|
||||
use App\Service\BpnXmlSyncManager;
|
||||
use League\Flysystem\FilesystemException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
@@ -183,8 +183,7 @@ class BpnXmlSyncCommand extends Command
|
||||
bool $dryRun,
|
||||
SymfonyStyle $io,
|
||||
OutputInterface $output,
|
||||
): array
|
||||
{
|
||||
): array {
|
||||
$datasetName = $target->name;
|
||||
|
||||
$remoteInfo = $this->syncManager->readRemoteInfo($target->source, $datasetName);
|
||||
|
||||
@@ -32,9 +32,9 @@ final class MailjetNewsletterWebhookCommand extends Command
|
||||
|
||||
public function __construct(
|
||||
private readonly MailjetApiClient $mailjetApiClient,
|
||||
#[Autowire('%env(APP_BASE_URL)%')]
|
||||
#[Autowire(env: 'APP_BASE_URL')]
|
||||
private readonly string $defaultBaseUrl,
|
||||
#[Autowire('%env(MAILJET_WEBHOOK_BASIC_PASSWORD)%')]
|
||||
#[Autowire(env: 'MAILJET_WEBHOOK_BASIC_PASSWORD')]
|
||||
private readonly string $basicAuthPassword,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
|
||||
@@ -10,12 +10,12 @@ use App\BusProNet\Model\Notification;
|
||||
use App\BusProNet\Model\PersonalData;
|
||||
use App\Entity\User;
|
||||
use App\Exception\NewsletterProviderException;
|
||||
use App\Htmx\HxTrait;
|
||||
use App\Form\PersonalDataType;
|
||||
use App\Htmx\HxTrait;
|
||||
use App\Model\NewsletterSubscriptionRequestResult;
|
||||
use App\Service\NewsletterManager;
|
||||
use App\Security\Crypt;
|
||||
use App\Service\BookingEditDataLoader;
|
||||
use App\Service\NewsletterManager;
|
||||
use App\Service\ProfileCompletenessChecker;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -55,8 +55,7 @@ class PersonalDataController extends AbstractController
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly NewsletterManager $newsletterManager,
|
||||
private readonly LoggerInterface $logger,
|
||||
)
|
||||
{
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,7 +124,7 @@ class PersonalDataController extends AbstractController
|
||||
|
||||
return $this->render('account/personal_data.html.twig', [
|
||||
'personalData' => $personalData,
|
||||
'personalDataForm' => $personalDataForm->createView(),
|
||||
'personalDataForm' => $personalDataForm,
|
||||
'newsletterSubscribed' => $newsletterSubscribed,
|
||||
'newsletterPendingConfirmation' => $newsletterPendingConfirmation,
|
||||
]);
|
||||
@@ -149,7 +148,6 @@ class PersonalDataController extends AbstractController
|
||||
$result = $this->newsletterManager->requestDefaultListSubscription($email, $personalData->firstName, $personalData->name);
|
||||
$this->addFlash(...$this->newsletterRequestFlash($result));
|
||||
}
|
||||
|
||||
} catch (NewsletterProviderException|\InvalidArgumentException $e) {
|
||||
$this->addFlash('error', 'Die Newsletter-Aktion konnte gerade nicht verarbeitet werden. Bitte versuche es erneut.');
|
||||
$this->logger->warning('Newsletter action failed', [
|
||||
|
||||
@@ -32,7 +32,7 @@ class NewsletterSubscriptionController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/newsletters', name: 'api_newsletters_all', methods: ['GET'])]
|
||||
public function index():JsonResponse
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
return $this->json($this->newsletterManager->createListIdMapping(array_keys($this->mailjetLists)));
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ class Step1Controller extends AbstractBookingCreateController
|
||||
|
||||
return $this->render('booking/create/step_1.html.twig', [
|
||||
'bookingCreateContext' => $context,
|
||||
'form' => $form->createView(),
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ declare(strict_types=1);
|
||||
namespace App\Controller\Booking\Create;
|
||||
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Entity\User;
|
||||
use App\Exception\BookingSessionNotFoundException;
|
||||
use App\Exception\HotelNotInTravelException;
|
||||
use App\Exception\TravelNotFoundException;
|
||||
use App\Entity\User;
|
||||
use App\Form\BookingCreateStep2Type;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
|
||||
@@ -136,7 +136,7 @@ class Step2ParticipantController extends AbstractController
|
||||
);
|
||||
|
||||
return $this->render('booking/create/step_2_participant.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'form' => $form,
|
||||
'participantIndex' => $index,
|
||||
'bookingCreateContext' => $bookingCreateContext,
|
||||
'bookingDto' => $bookingCreateContext->bookingDto,
|
||||
|
||||
@@ -228,7 +228,7 @@ class Step3Controller extends AbstractBookingCreateController
|
||||
|
||||
return $this->render('booking/create/step_3.html.twig', [
|
||||
'bookingCreateContext' => $context,
|
||||
'form' => $form->createView(),
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ class Step4Controller extends AbstractBookingCreateController
|
||||
|
||||
return $this->render('booking/create/step_4.html.twig', [
|
||||
'bookingCreateContext' => $bookingCreateContext,
|
||||
'form' => $form->createView(),
|
||||
'form' => $form,
|
||||
'newsletterOptInVisible' => $newsletterOptInVisible,
|
||||
'newsletterTargetEmail' => $newsletterTargetEmail,
|
||||
]);
|
||||
|
||||
@@ -9,8 +9,8 @@ use App\Entity\User;
|
||||
use App\Exception\TravelNotFoundException;
|
||||
use App\Form\BookingEditType;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Model\BookingEditSubmissionResult;
|
||||
use App\Htmx\HxTrait;
|
||||
use App\Model\BookingEditSubmissionResult;
|
||||
use App\Service\BookingChangeTracker;
|
||||
use App\Service\BookingEditContextFactory;
|
||||
use App\Service\BookingEditDataLoader;
|
||||
|
||||
@@ -99,7 +99,7 @@ class ParticipantController extends AbstractController
|
||||
$context = $this->editContextFactory->createParticipantContext($bookingDto, $bookingData);
|
||||
|
||||
return $this->render('booking/edit/participant.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'form' => $form,
|
||||
'participantIndex' => $index,
|
||||
'bookingEditContext' => $context,
|
||||
'bookingDto' => $context->bookingDto,
|
||||
|
||||
@@ -55,7 +55,7 @@ class RegistrationController extends AbstractController
|
||||
}
|
||||
|
||||
return $this->render('registration/index.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class ResetPasswordController extends AbstractController
|
||||
}
|
||||
|
||||
return $this->render('reset_password/index.html.twig', [
|
||||
'form' => $form->createView(),
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ final class MailjetNewsletterWebhookController extends AbstractController
|
||||
* into a list before dispatching.
|
||||
*
|
||||
* @param array<int|string, mixed> $payload
|
||||
*
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
private function normalizeEvents(array $payload): array
|
||||
|
||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Form\Service\Condition;
|
||||
|
||||
use App\BusProNet\Model\Service;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Service\Contract\FieldConditionInterface;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Form\Service;
|
||||
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Service\Abstract\AbstractParticipantFieldHandler;
|
||||
|
||||
/**
|
||||
@@ -217,7 +218,7 @@ class ParticipantAssignedRoomFieldHandler extends AbstractParticipantFieldHandle
|
||||
* @param BookingDto $bookingDto The booking DTO with all participants
|
||||
* @param int $excludeParticipantIndex Participant index to exclude from results
|
||||
*
|
||||
* @return array<int, \App\Form\Model\ParticipantDto> Array of participants indexed by their position
|
||||
* @return array<int, ParticipantDto> Array of participants indexed by their position
|
||||
*/
|
||||
private function getParticipantsAssignedToRoom(int $roomId, BookingDto $bookingDto, int $excludeParticipantIndex): array
|
||||
{
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace App\Repository;
|
||||
use App\Entity\BookingEditDraft;
|
||||
use App\Entity\User;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Query\Parameter;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
@@ -47,8 +49,10 @@ class BookingEditDraftRepository extends ServiceEntityRepository
|
||||
->delete()
|
||||
->where('d.user = :user')
|
||||
->andWhere('d.bookingId = :bookingId')
|
||||
->setParameter('user', $user)
|
||||
->setParameter('bookingId', $bookingId)
|
||||
->setParameters(new ArrayCollection([
|
||||
new Parameter('user', $user),
|
||||
new Parameter('bookingId', $bookingId),
|
||||
]))
|
||||
->getQuery()
|
||||
->execute();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ namespace App\Repository;
|
||||
|
||||
use App\Entity\NewsletterOptInRequest;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Query\Parameter;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
@@ -29,8 +31,10 @@ class NewsletterOptInRequestRepository extends ServiceEntityRepository
|
||||
->where('c.email = :email')
|
||||
->andWhere('c.confirmedAt IS NULL')
|
||||
->andWhere('c.expiresAt > :now')
|
||||
->setParameter('email', mb_strtolower(trim($email)))
|
||||
->setParameter('now', new \DateTimeImmutable())
|
||||
->setParameters(new ArrayCollection([
|
||||
new Parameter('email', mb_strtolower(trim($email))),
|
||||
new Parameter('now', new \DateTimeImmutable()),
|
||||
]))
|
||||
->orderBy('c.createdAt', 'DESC')
|
||||
->setMaxResults(1)
|
||||
->getQuery()
|
||||
@@ -44,8 +48,10 @@ class NewsletterOptInRequestRepository extends ServiceEntityRepository
|
||||
->where('c.email = :email')
|
||||
->andWhere('c.confirmedAt IS NULL')
|
||||
->andWhere('c.expiresAt <= :now')
|
||||
->setParameter('email', mb_strtolower(trim($email)))
|
||||
->setParameter('now', new \DateTimeImmutable())
|
||||
->setParameters(new ArrayCollection([
|
||||
new Parameter('email', mb_strtolower(trim($email))),
|
||||
new Parameter('now', new \DateTimeImmutable()),
|
||||
]))
|
||||
->getQuery()
|
||||
->execute();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ namespace App\Repository;
|
||||
|
||||
use App\Entity\TravelSnapshot;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Query\Parameter;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
@@ -102,8 +104,10 @@ class TravelSnapshotRepository extends ServiceEntityRepository
|
||||
->where('s.dateTo IS NULL OR s.dateTo >= :dateToThreshold')
|
||||
// extendedRefreshedAt IS NULL: never-refreshed snapshots rank as oldest.
|
||||
->andWhere('s.extendedRefreshedAt IS NULL OR s.extendedRefreshedAt < :refreshBefore')
|
||||
->setParameter('dateToThreshold', $dateToThreshold)
|
||||
->setParameter('refreshBefore', $refreshBefore)
|
||||
->setParameters(new ArrayCollection([
|
||||
new Parameter('dateToThreshold', $dateToThreshold),
|
||||
new Parameter('refreshBefore', $refreshBefore),
|
||||
]))
|
||||
->orderBy('s.extendedRefreshedAt', 'ASC')
|
||||
->addOrderBy('s.id', 'ASC')
|
||||
->setMaxResults($limit)
|
||||
@@ -148,8 +152,10 @@ class TravelSnapshotRepository extends ServiceEntityRepository
|
||||
->where('s.dateFrom IS NOT NULL')
|
||||
->andWhere('s.dateFrom > :today')
|
||||
->andWhere('s.dateId NOT IN (:activeXmlDateIds)')
|
||||
->setParameter('today', $today)
|
||||
->setParameter('activeXmlDateIds', $activeXmlDateIds)
|
||||
->setParameters(new ArrayCollection([
|
||||
new Parameter('today', $today),
|
||||
new Parameter('activeXmlDateIds', $activeXmlDateIds),
|
||||
]))
|
||||
->getQuery()
|
||||
->execute();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class BookingConfigurator
|
||||
private readonly ParticipantEligibilityChecker $participantEligibilityService,
|
||||
private readonly BookingStatusRuleRegistry $bookingStatusRuleRegistry,
|
||||
private readonly AgencyLoader $agencyLoader,
|
||||
#[Autowire('%default_booking_status%')]
|
||||
#[Autowire(param: 'default_booking_status')]
|
||||
private readonly string $defaultBookingStatus,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\BusProNet\Model\Address;
|
||||
use App\BusProNet\Model\Service;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
@@ -120,7 +121,7 @@ class BookingEditDraftMerger
|
||||
}
|
||||
|
||||
if (null === $participant->address) {
|
||||
$participant->address = new \App\BusProNet\Model\Address();
|
||||
$participant->address = new Address();
|
||||
}
|
||||
|
||||
if (true === array_key_exists('street', $data)) {
|
||||
|
||||
@@ -9,8 +9,8 @@ use App\BusProNet\Exception\ApiClientException;
|
||||
use App\BusProNet\Exception\TimeoutException;
|
||||
use App\BusProNet\Model\Notification;
|
||||
use App\Entity\User;
|
||||
use App\Model\BookingEditSubmissionResult;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Model\BookingEditSubmissionResult;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
@@ -76,6 +76,7 @@ class BookingEditSubmitter
|
||||
'booking_id' => $bookingId,
|
||||
'message' => $response->message,
|
||||
]);
|
||||
|
||||
return new BookingEditSubmissionResult(
|
||||
true === $response->isError()
|
||||
? BookingEditSubmissionResult::STATUS_NOTIFICATION_ERROR
|
||||
@@ -118,6 +119,7 @@ class BookingEditSubmitter
|
||||
'email' => $email,
|
||||
'booking_id' => $bookingId,
|
||||
]);
|
||||
|
||||
return new BookingEditSubmissionResult(
|
||||
BookingEditSubmissionResult::STATUS_TIMEOUT,
|
||||
null,
|
||||
|
||||
@@ -4,8 +4,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Entity\BookingEditDraft;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Fill;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
@@ -106,11 +110,11 @@ class BookingExporter
|
||||
/**
|
||||
* Builds lookup arrays for converting IDs to labels.
|
||||
*
|
||||
* @param \App\BusProNet\Model\Travel $travel The travel data
|
||||
* @param Travel $travel The travel data
|
||||
*
|
||||
* @return array{services: array<int, string>, rooms: array<int, string>, pickups: array<int, string>}
|
||||
*/
|
||||
private function buildLookups(\App\BusProNet\Model\Travel $travel): array
|
||||
private function buildLookups(Travel $travel): array
|
||||
{
|
||||
$services = [];
|
||||
$rooms = [];
|
||||
@@ -174,11 +178,11 @@ class BookingExporter
|
||||
$headerStyle = [
|
||||
'font' => ['bold' => true],
|
||||
'fill' => [
|
||||
'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
|
||||
'fillType' => Fill::FILL_SOLID,
|
||||
'startColor' => ['rgb' => 'E0E0E0'],
|
||||
],
|
||||
];
|
||||
$lastColumn = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex(count(self::COLUMN_HEADERS));
|
||||
$lastColumn = Coordinate::stringFromColumnIndex(count(self::COLUMN_HEADERS));
|
||||
$sheet->getStyle('A1:'.$lastColumn.'1')->applyFromArray($headerStyle);
|
||||
|
||||
// Write participant data
|
||||
@@ -193,7 +197,7 @@ class BookingExporter
|
||||
|
||||
// Auto-size columns
|
||||
foreach (range(1, count(self::COLUMN_HEADERS)) as $col) {
|
||||
$colLetter = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::stringFromColumnIndex($col);
|
||||
$colLetter = Coordinate::stringFromColumnIndex($col);
|
||||
$sheet->getColumnDimension($colLetter)->setAutoSize(true);
|
||||
}
|
||||
|
||||
@@ -208,7 +212,7 @@ class BookingExporter
|
||||
* @param array<string, array<int, string>> $lookups
|
||||
*/
|
||||
private function writeParticipantRow(
|
||||
\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $sheet,
|
||||
Worksheet $sheet,
|
||||
int $row,
|
||||
array $participant,
|
||||
array $lookups,
|
||||
|
||||
@@ -4,9 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\BusProNet\XmlLoader\TravelLoader;
|
||||
use App\Model\BpnXmlSnapshotRefreshPlan;
|
||||
use App\Model\BpnXmlSnapshotRefreshResult;
|
||||
use App\BusProNet\XmlLoader\TravelLoader;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
final class BpnXmlSnapshotRefreshManager
|
||||
|
||||
@@ -11,8 +11,8 @@ use App\Exception\NewsletterListNotAllowedException;
|
||||
use App\Exception\NewsletterProviderException;
|
||||
use App\Model\NewsletterConfirmationResult;
|
||||
use App\Model\NewsletterSubscriptionRequestResult;
|
||||
use App\Repository\NewsletterOptInRequestRepository;
|
||||
use App\Repository\NewsletterConsentRepository;
|
||||
use App\Repository\NewsletterOptInRequestRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
||||
namespace App\Service;
|
||||
|
||||
use App\BusProNet\Model\Insurance;
|
||||
use App\BusProNet\Model\Service;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ class ErrorCodeExtension extends AbstractExtension
|
||||
public function getFunctions(): array
|
||||
{
|
||||
return [
|
||||
new TwigFunction('error_code', [$this, 'getErrorCode']),
|
||||
new TwigFunction('has_error_code', [$this, 'hasErrorCode']),
|
||||
new TwigFunction('error_code', $this->getErrorCode(...)),
|
||||
new TwigFunction('has_error_code', $this->hasErrorCode(...)),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user