feat: replace *Service suffix with role-based class names
This commit is contained in:
@@ -20,8 +20,8 @@ use App\BusProNet\Model\Service;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Service\BookingPriceCalculatorService;
|
||||
use App\Service\InsuranceService;
|
||||
use App\Service\BookingPriceCalculator;
|
||||
use App\Service\InsuranceManager;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\NullLogger;
|
||||
|
||||
@@ -37,9 +37,9 @@ class BookingDataProcessorTest extends TestCase
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
// Create a mock InsuranceService
|
||||
$insuranceService = $this->createMock(InsuranceService::class);
|
||||
$priceCalculatorService = $this->createMock(BookingPriceCalculatorService::class);
|
||||
// Create a mock InsuranceManager
|
||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
||||
|
||||
// Mock getSelectableInsurances to return empty array (not used in these tests)
|
||||
$insuranceService->method('getSelectableInsurances')
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace App\Tests\Command;
|
||||
|
||||
use App\BusProNet\XmlLoader\TravelLoader;
|
||||
use App\Command\BpnXmlSyncCommand;
|
||||
use App\Service\TravelDataService;
|
||||
use App\Service\TravelSnapshotService;
|
||||
use App\Service\TravelDataProvider;
|
||||
use App\Service\TravelSnapshotManager;
|
||||
use League\Flysystem\DirectoryListing;
|
||||
use League\Flysystem\FilesystemOperator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -23,8 +23,8 @@ class BpnXmlSyncCommandTest extends TestCase
|
||||
private CacheInterface $cache;
|
||||
private LoggerInterface $logger;
|
||||
private TravelLoader $travelLoader;
|
||||
private TravelDataService $travelDataService;
|
||||
private TravelSnapshotService $travelSnapshotService;
|
||||
private TravelDataProvider $travelDataService;
|
||||
private TravelSnapshotManager $travelSnapshotService;
|
||||
private BpnXmlSyncCommand $command;
|
||||
|
||||
protected function tearDown(): void
|
||||
@@ -42,8 +42,8 @@ class BpnXmlSyncCommandTest extends TestCase
|
||||
$this->cache = $this->createMock(CacheInterface::class);
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
$this->travelLoader = $this->createMock(TravelLoader::class);
|
||||
$this->travelDataService = $this->createMock(TravelDataService::class);
|
||||
$this->travelSnapshotService = $this->createMock(TravelSnapshotService::class);
|
||||
$this->travelDataService = $this->createMock(TravelDataProvider::class);
|
||||
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
||||
|
||||
$this->command = new BpnXmlSyncCommand(
|
||||
$this->xmlSource,
|
||||
|
||||
@@ -10,9 +10,9 @@ use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Model\ParticipantEditDto;
|
||||
use App\Form\Service\ServiceAgeEvaluator;
|
||||
use App\Service\BookingPriceCalculatorService;
|
||||
use App\Service\ParticipantEligibilityService;
|
||||
use App\Service\VoucherValidationService;
|
||||
use App\Service\BookingPriceCalculator;
|
||||
use App\Service\ParticipantEligibilityChecker;
|
||||
use App\Service\VoucherValidator;
|
||||
use App\Validator\Constraints\MandatoryAdditionalServicesSelectedValidator;
|
||||
use App\Validator\Constraints\PromoVoucherValidator;
|
||||
use App\Validator\Constraints\PurchaseVoucherValidator;
|
||||
@@ -39,22 +39,22 @@ class ParticipantEditDtoTest extends TestCase
|
||||
protected function setUp(): void
|
||||
{
|
||||
// Create mock services for validator dependencies
|
||||
$mockVoucherService = $this->createMock(VoucherValidationService::class);
|
||||
$mockPriceCalculatorService = $this->createMock(BookingPriceCalculatorService::class);
|
||||
$mockParticipantEligibilityService = $this->createMock(ParticipantEligibilityService::class);
|
||||
$mockVoucherService = $this->createMock(VoucherValidator::class);
|
||||
$mockPriceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
||||
$mockParticipantEligibilityChecker = $this->createMock(ParticipantEligibilityChecker::class);
|
||||
$mockServiceAgeEvaluator = $this->createMock(ServiceAgeEvaluator::class);
|
||||
|
||||
// Create custom validator factory that can inject dependencies
|
||||
$validatorFactory = new class(
|
||||
$mockVoucherService,
|
||||
$mockPriceCalculatorService,
|
||||
$mockParticipantEligibilityService,
|
||||
$mockParticipantEligibilityChecker,
|
||||
$mockServiceAgeEvaluator
|
||||
) implements ConstraintValidatorFactoryInterface {
|
||||
public function __construct(
|
||||
private readonly VoucherValidationService $voucherService,
|
||||
private readonly BookingPriceCalculatorService $priceCalculatorService,
|
||||
private readonly ParticipantEligibilityService $participantEligibilityService,
|
||||
private readonly VoucherValidator $voucherService,
|
||||
private readonly BookingPriceCalculator $priceCalculatorService,
|
||||
private readonly ParticipantEligibilityChecker $participantEligibilityService,
|
||||
private readonly ServiceAgeEvaluator $serviceAgeEvaluator,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ use App\BusProNet\Utility\DirectionMapper;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Service\ParticipantFieldOptionsProvider;
|
||||
use App\Service\BookingPriceCalculatorService;
|
||||
use App\Service\InsuranceService;
|
||||
use App\Service\BookingPriceCalculator;
|
||||
use App\Service\InsuranceManager;
|
||||
use App\Service\ServiceLabelFormatter;
|
||||
use App\Service\ServiceAvailabilityCalculator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -26,8 +26,8 @@ class ParticipantFieldOptionsProviderBabyTest extends TestCase
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
||||
$insuranceService = $this->createMock(InsuranceService::class);
|
||||
$priceCalculatorService = $this->createMock(BookingPriceCalculatorService::class);
|
||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
||||
$serviceLabelFormatter = new ServiceLabelFormatter();
|
||||
$translator = $this->createMock(TranslatorInterface::class);
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Service\ParticipantFieldOptionsProvider;
|
||||
use App\Service\BookingPriceCalculatorService;
|
||||
use App\Service\InsuranceService;
|
||||
use App\Service\BookingPriceCalculator;
|
||||
use App\Service\InsuranceManager;
|
||||
use App\Service\ServiceLabelFormatter;
|
||||
use App\Service\ServiceAvailabilityCalculator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -29,8 +29,8 @@ class ParticipantFieldOptionsProviderMandatoryServiceTest extends TestCase
|
||||
protected function setUp(): void
|
||||
{
|
||||
$serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
||||
$insuranceService = $this->createMock(InsuranceService::class);
|
||||
$priceCalculatorService = $this->createMock(BookingPriceCalculatorService::class);
|
||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
||||
$serviceLabelFormatter = new ServiceLabelFormatter();
|
||||
$translator = $this->createMock(TranslatorInterface::class);
|
||||
|
||||
|
||||
@@ -9,20 +9,20 @@ use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Service\ParticipantInsuranceFieldHandler;
|
||||
use App\Service\BookingPriceCalculatorService;
|
||||
use App\Service\InsuranceService;
|
||||
use App\Service\BookingPriceCalculator;
|
||||
use App\Service\InsuranceManager;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ParticipantInsuranceFieldHandlerTest extends TestCase
|
||||
{
|
||||
private ParticipantInsuranceFieldHandler $handler;
|
||||
private InsuranceService $insuranceService;
|
||||
private BookingPriceCalculatorService $priceCalculatorService;
|
||||
private InsuranceManager $insuranceService;
|
||||
private BookingPriceCalculator $priceCalculatorService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->insuranceService = $this->createMock(InsuranceService::class);
|
||||
$this->priceCalculatorService = $this->createMock(BookingPriceCalculatorService::class);
|
||||
$this->insuranceService = $this->createMock(InsuranceManager::class);
|
||||
$this->priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
||||
|
||||
// Mock getSelectableInsurances to return input array
|
||||
$this->insuranceService->method('getSelectableInsurances')
|
||||
|
||||
@@ -5,19 +5,19 @@ declare(strict_types=1);
|
||||
namespace App\Tests\Logger;
|
||||
|
||||
use App\Logger\ErrorCodeProcessor;
|
||||
use App\Service\ErrorCodeService;
|
||||
use App\Service\ErrorCodeGenerator;
|
||||
use Monolog\Level;
|
||||
use Monolog\LogRecord;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ErrorCodeProcessorTest extends TestCase
|
||||
{
|
||||
private ErrorCodeService $errorCodeService;
|
||||
private ErrorCodeGenerator $errorCodeService;
|
||||
private ErrorCodeProcessor $processor;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->errorCodeService = $this->createMock(ErrorCodeService::class);
|
||||
$this->errorCodeService = $this->createMock(ErrorCodeGenerator::class);
|
||||
$this->processor = new ErrorCodeProcessor($this->errorCodeService);
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -11,27 +11,27 @@ use App\BusProNet\Service\BookingStatusRuleRegistry;
|
||||
use App\BusProNet\XmlLoader\AgencyLoader;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Service\BookingService;
|
||||
use App\Service\BookingSessionService;
|
||||
use App\Service\ParticipantEligibilityService;
|
||||
use App\Service\TravelDataService;
|
||||
use App\Service\BookingConfigurator;
|
||||
use App\Service\BookingSessionStore;
|
||||
use App\Service\ParticipantEligibilityChecker;
|
||||
use App\Service\TravelDataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BookingServiceBabyTest extends TestCase
|
||||
class BookingConfiguratorBabyTest extends TestCase
|
||||
{
|
||||
private BookingService $bookingService;
|
||||
private ParticipantEligibilityService $participantEligibilityService;
|
||||
private BookingConfigurator $bookingService;
|
||||
private ParticipantEligibilityChecker $participantEligibilityService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$travelDataService = $this->createMock(TravelDataService::class);
|
||||
$this->participantEligibilityService = $this->createMock(ParticipantEligibilityService::class);
|
||||
$travelDataService = $this->createMock(TravelDataProvider::class);
|
||||
$this->participantEligibilityService = $this->createMock(ParticipantEligibilityChecker::class);
|
||||
$bookingStatusRuleRegistry = $this->createMock(BookingStatusRuleRegistry::class);
|
||||
$bookingStatusRuleRegistry->method('evaluateStatus')->willReturn('F');
|
||||
$agencyLoader = $this->createMock(AgencyLoader::class);
|
||||
|
||||
$this->bookingService = new BookingService(
|
||||
$this->createMock(BookingSessionService::class),
|
||||
$this->bookingService = new BookingConfigurator(
|
||||
$this->createMock(BookingSessionStore::class),
|
||||
$travelDataService,
|
||||
$this->participantEligibilityService,
|
||||
$bookingStatusRuleRegistry,
|
||||
+17
-17
@@ -11,30 +11,30 @@ use App\BusProNet\Model\Travel;
|
||||
use App\BusProNet\Service\BookingStatusRuleRegistry;
|
||||
use App\BusProNet\XmlLoader\AgencyLoader;
|
||||
use App\Exception\NoRoomsAvailableException;
|
||||
use App\Service\BookingService;
|
||||
use App\Service\BookingSessionService;
|
||||
use App\Service\ParticipantEligibilityService;
|
||||
use App\Service\TravelDataService;
|
||||
use App\Service\BookingConfigurator;
|
||||
use App\Service\BookingSessionStore;
|
||||
use App\Service\ParticipantEligibilityChecker;
|
||||
use App\Service\TravelDataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||
|
||||
class BookingServiceStatusTest extends TestCase
|
||||
class BookingConfiguratorStatusTest extends TestCase
|
||||
{
|
||||
private BookingService $bookingService;
|
||||
private TravelDataService $travelDataService;
|
||||
private BookingConfigurator $bookingService;
|
||||
private TravelDataProvider $travelDataService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$bookingSessionService = $this->createMock(BookingSessionService::class);
|
||||
$this->travelDataService = $this->createMock(TravelDataService::class);
|
||||
$participantEligibility = $this->createMock(ParticipantEligibilityService::class);
|
||||
$bookingSessionService = $this->createMock(BookingSessionStore::class);
|
||||
$this->travelDataService = $this->createMock(TravelDataProvider::class);
|
||||
$participantEligibility = $this->createMock(ParticipantEligibilityChecker::class);
|
||||
$bookingStatusRuleRegistry = $this->createMock(BookingStatusRuleRegistry::class);
|
||||
$bookingStatusRuleRegistry->method('evaluateStatus')->willReturn('F');
|
||||
$agencyLoader = $this->createMock(AgencyLoader::class);
|
||||
|
||||
$this->bookingService = new BookingService(
|
||||
$this->bookingService = new BookingConfigurator(
|
||||
$bookingSessionService,
|
||||
$this->travelDataService,
|
||||
$participantEligibility,
|
||||
@@ -177,10 +177,10 @@ class BookingServiceStatusTest extends TestCase
|
||||
$bookingStatusRuleRegistry = $this->createMock(BookingStatusRuleRegistry::class);
|
||||
$bookingStatusRuleRegistry->method('evaluateStatus')->willReturn('O');
|
||||
|
||||
$bookingService = new BookingService(
|
||||
$this->createMock(BookingSessionService::class),
|
||||
$bookingService = new BookingConfigurator(
|
||||
$this->createMock(BookingSessionStore::class),
|
||||
$this->travelDataService,
|
||||
$this->createMock(ParticipantEligibilityService::class),
|
||||
$this->createMock(ParticipantEligibilityChecker::class),
|
||||
$bookingStatusRuleRegistry,
|
||||
$this->createMock(AgencyLoader::class),
|
||||
'F'
|
||||
@@ -208,10 +208,10 @@ class BookingServiceStatusTest extends TestCase
|
||||
$bookingStatusRuleRegistry = $this->createMock(BookingStatusRuleRegistry::class);
|
||||
$bookingStatusRuleRegistry->expects($this->never())->method('evaluateStatus');
|
||||
|
||||
$bookingService = new BookingService(
|
||||
$this->createMock(BookingSessionService::class),
|
||||
$bookingService = new BookingConfigurator(
|
||||
$this->createMock(BookingSessionStore::class),
|
||||
$this->travelDataService,
|
||||
$this->createMock(ParticipantEligibilityService::class),
|
||||
$this->createMock(ParticipantEligibilityChecker::class),
|
||||
$bookingStatusRuleRegistry,
|
||||
$this->createMock(AgencyLoader::class),
|
||||
'F'
|
||||
@@ -13,9 +13,9 @@ use App\Form\Model\BookingMutabilityDto;
|
||||
use App\Form\Model\BookingEditContext;
|
||||
use App\Form\Model\BookingSummaryDto;
|
||||
use App\Service\BookingEditContextFactory;
|
||||
use App\Service\BookingSummaryDataService;
|
||||
use App\Service\ParticipantCardDataService;
|
||||
use App\Service\TravelDataService;
|
||||
use App\Service\BookingSummaryAssembler;
|
||||
use App\Service\ParticipantCardAssembler;
|
||||
use App\Service\TravelDataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BookingEditContextFactoryTest extends TestCase
|
||||
@@ -27,14 +27,14 @@ class BookingEditContextFactoryTest extends TestCase
|
||||
$travel->dateTo = new \DateTimeImmutable('2030-01-06');
|
||||
$bookingDto = new BookingDto($travel, 157047);
|
||||
|
||||
$travelDataService = $this->createMock(TravelDataService::class);
|
||||
$travelDataService = $this->createMock(TravelDataProvider::class);
|
||||
$travelDataService->expects($this->once())
|
||||
->method('enrichWithFreshAvailabilities')
|
||||
->with($travel);
|
||||
|
||||
$service = new BookingEditContextFactory(
|
||||
$this->createMock(ParticipantCardDataService::class),
|
||||
$this->createMock(BookingSummaryDataService::class),
|
||||
$this->createMock(ParticipantCardAssembler::class),
|
||||
$this->createMock(BookingSummaryAssembler::class),
|
||||
$travelDataService,
|
||||
);
|
||||
|
||||
@@ -58,20 +58,20 @@ class BookingEditContextFactoryTest extends TestCase
|
||||
]);
|
||||
$summaryData = $this->createMock(BookingSummaryDto::class);
|
||||
|
||||
$summaryDataService = $this->createMock(BookingSummaryDataService::class);
|
||||
$summaryDataService = $this->createMock(BookingSummaryAssembler::class);
|
||||
$summaryDataService->expects($this->once())
|
||||
->method('getSummaryData')
|
||||
->with($bookingDto)
|
||||
->willReturn($summaryData);
|
||||
|
||||
$travelDataService = $this->createMock(TravelDataService::class);
|
||||
$travelDataService = $this->createMock(TravelDataProvider::class);
|
||||
$travelDataService->expects($this->once())
|
||||
->method('getMutabilityData')
|
||||
->with(1234)
|
||||
->willReturn($mutableData);
|
||||
|
||||
$service = new BookingEditContextFactory(
|
||||
$this->createMock(ParticipantCardDataService::class),
|
||||
$this->createMock(ParticipantCardAssembler::class),
|
||||
$summaryDataService,
|
||||
$travelDataService,
|
||||
);
|
||||
@@ -96,18 +96,18 @@ class BookingEditContextFactoryTest extends TestCase
|
||||
$bookingDto = new BookingDto($travel, 157047);
|
||||
$summaryData = $this->createMock(BookingSummaryDto::class);
|
||||
|
||||
$summaryDataService = $this->createMock(BookingSummaryDataService::class);
|
||||
$summaryDataService = $this->createMock(BookingSummaryAssembler::class);
|
||||
$summaryDataService->expects($this->once())
|
||||
->method('getSummaryData')
|
||||
->with($bookingDto)
|
||||
->willReturn($summaryData);
|
||||
|
||||
$travelDataService = $this->createMock(TravelDataService::class);
|
||||
$travelDataService = $this->createMock(TravelDataProvider::class);
|
||||
$travelDataService->expects($this->never())
|
||||
->method('getMutabilityData');
|
||||
|
||||
$service = new BookingEditContextFactory(
|
||||
$this->createMock(ParticipantCardDataService::class),
|
||||
$this->createMock(ParticipantCardAssembler::class),
|
||||
$summaryDataService,
|
||||
$travelDataService,
|
||||
);
|
||||
@@ -135,19 +135,19 @@ class BookingEditContextFactoryTest extends TestCase
|
||||
$summaryData = $this->createMock(BookingSummaryDto::class);
|
||||
$cardsData = [];
|
||||
|
||||
$participantCardDataService = $this->createMock(ParticipantCardDataService::class);
|
||||
$participantCardDataService = $this->createMock(ParticipantCardAssembler::class);
|
||||
$participantCardDataService->expects($this->once())
|
||||
->method('getAllCardsDataWithValidation')
|
||||
->with($bookingDto)
|
||||
->willReturn($cardsData);
|
||||
|
||||
$summaryDataService = $this->createMock(BookingSummaryDataService::class);
|
||||
$summaryDataService = $this->createMock(BookingSummaryAssembler::class);
|
||||
$summaryDataService->expects($this->once())
|
||||
->method('getSummaryData')
|
||||
->with($bookingDto)
|
||||
->willReturn($summaryData);
|
||||
|
||||
$travelDataService = $this->createMock(TravelDataService::class);
|
||||
$travelDataService = $this->createMock(TravelDataProvider::class);
|
||||
$travelDataService->expects($this->once())
|
||||
->method('getMutabilityData')
|
||||
->with(1234)
|
||||
|
||||
+5
-5
@@ -11,11 +11,11 @@ use App\BusProNet\Model\Service;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Service\BookingEditSubmitGuardService;
|
||||
use App\Service\BookingEditSubmitGuard;
|
||||
use Carbon\CarbonImmutable;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BookingEditSubmitGuardServiceTest extends TestCase
|
||||
class BookingEditSubmitGuardTest extends TestCase
|
||||
{
|
||||
protected function tearDown(): void
|
||||
{
|
||||
@@ -52,7 +52,7 @@ class BookingEditSubmitGuardServiceTest extends TestCase
|
||||
->method('createBookingDtoFromBooking')
|
||||
->willReturn($baselineDto);
|
||||
|
||||
$service = new BookingEditSubmitGuardService($processor);
|
||||
$service = new BookingEditSubmitGuard($processor);
|
||||
|
||||
$changed = $service->reconcileImmutableCategories($workingDto, new Booking());
|
||||
|
||||
@@ -88,7 +88,7 @@ class BookingEditSubmitGuardServiceTest extends TestCase
|
||||
->method('createBookingDtoFromBooking')
|
||||
->willReturn($baselineDto);
|
||||
|
||||
$service = new BookingEditSubmitGuardService($processor);
|
||||
$service = new BookingEditSubmitGuard($processor);
|
||||
|
||||
$changed = $service->reconcileImmutableCategories($workingDto, new Booking());
|
||||
|
||||
@@ -125,7 +125,7 @@ class BookingEditSubmitGuardServiceTest extends TestCase
|
||||
->method('createBookingDtoFromBooking')
|
||||
->willReturn($baselineDto);
|
||||
|
||||
$service = new BookingEditSubmitGuardService($processor);
|
||||
$service = new BookingEditSubmitGuard($processor);
|
||||
|
||||
$changed = $service->reconcileImmutableCategories($workingDto, new Booking());
|
||||
|
||||
+42
-42
@@ -12,12 +12,12 @@ use App\BusProNet\Model\Notification;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Entity\User;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Service\BookingEditDataLoaderService;
|
||||
use App\Service\BookingEditDraftService;
|
||||
use App\Service\BookingEditSubmitGuardService;
|
||||
use App\Service\BookingEditSubmitService;
|
||||
use App\Service\BookingSessionService;
|
||||
use App\Service\TravelDataService;
|
||||
use App\Service\BookingEditDataLoader;
|
||||
use App\Service\BookingEditDraftManager;
|
||||
use App\Service\BookingEditSubmitGuard;
|
||||
use App\Service\BookingEditSubmitter;
|
||||
use App\Service\BookingSessionStore;
|
||||
use App\Service\TravelDataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -25,7 +25,7 @@ use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
class BookingEditSubmitServiceTest extends TestCase
|
||||
class BookingEditSubmitterTest extends TestCase
|
||||
{
|
||||
public function testHandleSubmissionReturnsRedirectWhenFreshBookingDataCannotBeLoaded(): void
|
||||
{
|
||||
@@ -33,7 +33,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
$user = $this->createUser();
|
||||
$bookingDto = $this->createBookingDto();
|
||||
|
||||
$dataLoader = $this->createMock(BookingEditDataLoaderService::class);
|
||||
$dataLoader = $this->createMock(BookingEditDataLoader::class);
|
||||
$dataLoader->expects($this->once())
|
||||
->method('invalidateBookingCache')
|
||||
->with(42, $user);
|
||||
@@ -68,7 +68,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
$bookingDto = $this->createBookingDto();
|
||||
$freshBookingData = $this->createFreshBooking();
|
||||
|
||||
$dataLoader = $this->createMock(BookingEditDataLoaderService::class);
|
||||
$dataLoader = $this->createMock(BookingEditDataLoader::class);
|
||||
$dataLoader->expects($this->exactly(1))
|
||||
->method('invalidateBookingCache')
|
||||
->with(42, $user);
|
||||
@@ -77,7 +77,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
->with(42, $user)
|
||||
->willReturn($freshBookingData);
|
||||
|
||||
$travelDataService = $this->createMock(TravelDataService::class);
|
||||
$travelDataService = $this->createMock(TravelDataProvider::class);
|
||||
$travelDataService->expects($this->once())
|
||||
->method('getMutabilityData')
|
||||
->with(1234, true, true)
|
||||
@@ -85,7 +85,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
$travelDataService->expects($this->never())
|
||||
->method('patchMutability');
|
||||
|
||||
$submitGuard = $this->createMock(BookingEditSubmitGuardService::class);
|
||||
$submitGuard = $this->createMock(BookingEditSubmitGuard::class);
|
||||
$submitGuard->expects($this->once())
|
||||
->method('reconcileImmutableCategories')
|
||||
->with($bookingDto, $freshBookingData)
|
||||
@@ -117,7 +117,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
$bookingDto = $this->createBookingDto();
|
||||
$freshBookingData = $this->createFreshBooking();
|
||||
|
||||
$dataLoader = $this->createMock(BookingEditDataLoaderService::class);
|
||||
$dataLoader = $this->createMock(BookingEditDataLoader::class);
|
||||
$dataLoader->expects($this->once())
|
||||
->method('invalidateBookingCache')
|
||||
->with(42, $user);
|
||||
@@ -126,7 +126,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
->with(42, $user)
|
||||
->willReturn($freshBookingData);
|
||||
|
||||
$travelDataService = $this->createMock(TravelDataService::class);
|
||||
$travelDataService = $this->createMock(TravelDataProvider::class);
|
||||
$travelDataService->expects($this->once())
|
||||
->method('getMutabilityData')
|
||||
->with(1234, true, true)
|
||||
@@ -134,7 +134,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
$travelDataService->expects($this->never())
|
||||
->method('patchMutability');
|
||||
|
||||
$submitGuard = $this->createMock(BookingEditSubmitGuardService::class);
|
||||
$submitGuard = $this->createMock(BookingEditSubmitGuard::class);
|
||||
$submitGuard->expects($this->once())
|
||||
->method('reconcileImmutableCategories')
|
||||
->with($bookingDto, $freshBookingData)
|
||||
@@ -179,7 +179,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
$bookingDto = $this->createBookingDto();
|
||||
$freshBookingData = $this->createFreshBooking();
|
||||
|
||||
$dataLoader = $this->createMock(BookingEditDataLoaderService::class);
|
||||
$dataLoader = $this->createMock(BookingEditDataLoader::class);
|
||||
$dataLoader->expects($this->exactly(2))
|
||||
->method('invalidateBookingCache')
|
||||
->with(42, $user);
|
||||
@@ -188,7 +188,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
->with(42, $user)
|
||||
->willReturn($freshBookingData);
|
||||
|
||||
$travelDataService = $this->createMock(TravelDataService::class);
|
||||
$travelDataService = $this->createMock(TravelDataProvider::class);
|
||||
$travelDataService->expects($this->once())
|
||||
->method('getMutabilityData')
|
||||
->with(1234, true, true)
|
||||
@@ -196,7 +196,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
$travelDataService->expects($this->never())
|
||||
->method('patchMutability');
|
||||
|
||||
$submitGuard = $this->createMock(BookingEditSubmitGuardService::class);
|
||||
$submitGuard = $this->createMock(BookingEditSubmitGuard::class);
|
||||
$submitGuard->expects($this->once())
|
||||
->method('reconcileImmutableCategories')
|
||||
->with($bookingDto, $freshBookingData)
|
||||
@@ -210,14 +210,14 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
->with($bookingDto, true)
|
||||
->willReturn($bookingUpdate);
|
||||
|
||||
$bookingSessionService = $this->createMock(BookingSessionService::class);
|
||||
$bookingSessionService = $this->createMock(BookingSessionStore::class);
|
||||
$bookingSessionService->expects($this->once())
|
||||
->method('clearBookingDto')
|
||||
->with($request, BookingDto::MODE_EDIT);
|
||||
$bookingSessionService->expects($this->never())
|
||||
->method('saveBookingDto');
|
||||
|
||||
$draftService = $this->createMock(BookingEditDraftService::class);
|
||||
$draftService = $this->createMock(BookingEditDraftManager::class);
|
||||
$draftService->expects($this->once())
|
||||
->method('deleteDraft')
|
||||
->with($user, 42);
|
||||
@@ -245,7 +245,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
$bookingDto = $this->createBookingDto();
|
||||
$freshBookingData = $this->createFreshBooking();
|
||||
|
||||
$dataLoader = $this->createMock(BookingEditDataLoaderService::class);
|
||||
$dataLoader = $this->createMock(BookingEditDataLoader::class);
|
||||
$dataLoader->expects($this->exactly(2))
|
||||
->method('invalidateBookingCache')
|
||||
->with(42, $user);
|
||||
@@ -254,7 +254,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
->with(42, $user)
|
||||
->willReturn($freshBookingData);
|
||||
|
||||
$travelDataService = $this->createMock(TravelDataService::class);
|
||||
$travelDataService = $this->createMock(TravelDataProvider::class);
|
||||
$travelDataService->expects($this->once())
|
||||
->method('getMutabilityData')
|
||||
->with(1234, true, true)
|
||||
@@ -262,7 +262,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
$travelDataService->expects($this->never())
|
||||
->method('patchMutability');
|
||||
|
||||
$submitGuard = $this->createMock(BookingEditSubmitGuardService::class);
|
||||
$submitGuard = $this->createMock(BookingEditSubmitGuard::class);
|
||||
$submitGuard->expects($this->once())
|
||||
->method('reconcileImmutableCategories')
|
||||
->with($bookingDto, $freshBookingData)
|
||||
@@ -276,7 +276,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
->with($bookingDto, true)
|
||||
->willReturn($bookingUpdate);
|
||||
|
||||
$bookingSessionService = $this->createMock(BookingSessionService::class);
|
||||
$bookingSessionService = $this->createMock(BookingSessionStore::class);
|
||||
$bookingSessionService->expects($this->once())
|
||||
->method('saveBookingDto')
|
||||
->with($request, $bookingDto, BookingDto::MODE_EDIT);
|
||||
@@ -284,7 +284,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
->method('clearBookingDto')
|
||||
->with($request, BookingDto::MODE_EDIT);
|
||||
|
||||
$draftService = $this->createMock(BookingEditDraftService::class);
|
||||
$draftService = $this->createMock(BookingEditDraftManager::class);
|
||||
$draftService->expects($this->once())
|
||||
->method('deleteDraft')
|
||||
->with($user, 42);
|
||||
@@ -330,7 +330,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
$bookingDto = $this->createBookingDto();
|
||||
$freshBookingData = $this->createFreshBooking();
|
||||
|
||||
$dataLoader = $this->createMock(BookingEditDataLoaderService::class);
|
||||
$dataLoader = $this->createMock(BookingEditDataLoader::class);
|
||||
$dataLoader->expects($this->once())
|
||||
->method('invalidateBookingCache')
|
||||
->with(42, $user);
|
||||
@@ -339,7 +339,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
->with(42, $user)
|
||||
->willReturn($freshBookingData);
|
||||
|
||||
$travelDataService = $this->createMock(TravelDataService::class);
|
||||
$travelDataService = $this->createMock(TravelDataProvider::class);
|
||||
$travelDataService->expects($this->once())
|
||||
->method('getMutabilityData')
|
||||
->with(1234, true, true)
|
||||
@@ -347,7 +347,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
$travelDataService->expects($this->never())
|
||||
->method('patchMutability');
|
||||
|
||||
$submitGuard = $this->createMock(BookingEditSubmitGuardService::class);
|
||||
$submitGuard = $this->createMock(BookingEditSubmitGuard::class);
|
||||
$submitGuard->expects($this->once())
|
||||
->method('reconcileImmutableCategories')
|
||||
->with($bookingDto, $freshBookingData)
|
||||
@@ -379,7 +379,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
$bookingDto = $this->createBookingDto();
|
||||
$freshBookingData = $this->createFreshBooking();
|
||||
|
||||
$dataLoader = $this->createMock(BookingEditDataLoaderService::class);
|
||||
$dataLoader = $this->createMock(BookingEditDataLoader::class);
|
||||
$dataLoader->expects($this->once())
|
||||
->method('invalidateBookingCache')
|
||||
->with(42, $user);
|
||||
@@ -388,7 +388,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
->with(42, $user)
|
||||
->willReturn($freshBookingData);
|
||||
|
||||
$travelDataService = $this->createMock(TravelDataService::class);
|
||||
$travelDataService = $this->createMock(TravelDataProvider::class);
|
||||
$travelDataService->expects($this->once())
|
||||
->method('getMutabilityData')
|
||||
->with(1234, true, true)
|
||||
@@ -396,7 +396,7 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
$travelDataService->expects($this->never())
|
||||
->method('patchMutability');
|
||||
|
||||
$submitGuard = $this->createMock(BookingEditSubmitGuardService::class);
|
||||
$submitGuard = $this->createMock(BookingEditSubmitGuard::class);
|
||||
$submitGuard->expects($this->once())
|
||||
->method('reconcileImmutableCategories')
|
||||
->with($bookingDto, $freshBookingData)
|
||||
@@ -423,19 +423,19 @@ class BookingEditSubmitServiceTest extends TestCase
|
||||
|
||||
private function createService(
|
||||
?\App\BusProNet\ApiClient $apiClient = null,
|
||||
?BookingEditDataLoaderService $dataLoader = null,
|
||||
?BookingEditDraftService $draftService = null,
|
||||
?TravelDataService $travelDataService = null,
|
||||
?BookingEditSubmitGuardService $submitGuard = null,
|
||||
?BookingSessionService $bookingSessionService = null,
|
||||
): BookingEditSubmitService {
|
||||
return new BookingEditSubmitService(
|
||||
?BookingEditDataLoader $dataLoader = null,
|
||||
?BookingEditDraftManager $draftService = null,
|
||||
?TravelDataProvider $travelDataService = null,
|
||||
?BookingEditSubmitGuard $submitGuard = null,
|
||||
?BookingSessionStore $bookingSessionService = null,
|
||||
): BookingEditSubmitter {
|
||||
return new BookingEditSubmitter(
|
||||
$apiClient ?? $this->createMock(\App\BusProNet\ApiClient::class),
|
||||
$dataLoader ?? $this->createMock(BookingEditDataLoaderService::class),
|
||||
$draftService ?? $this->createMock(BookingEditDraftService::class),
|
||||
$travelDataService ?? $this->createMock(TravelDataService::class),
|
||||
$submitGuard ?? $this->createMock(BookingEditSubmitGuardService::class),
|
||||
$bookingSessionService ?? $this->createMock(BookingSessionService::class),
|
||||
$dataLoader ?? $this->createMock(BookingEditDataLoader::class),
|
||||
$draftService ?? $this->createMock(BookingEditDraftManager::class),
|
||||
$travelDataService ?? $this->createMock(TravelDataProvider::class),
|
||||
$submitGuard ?? $this->createMock(BookingEditSubmitGuard::class),
|
||||
$bookingSessionService ?? $this->createMock(BookingSessionStore::class),
|
||||
$this->createUrlGenerator(),
|
||||
$this->createMock(LoggerInterface::class),
|
||||
);
|
||||
+11
-11
@@ -11,23 +11,23 @@ use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Model\RoomSelectionDto;
|
||||
use App\Service\BookingPriceCalculatorService;
|
||||
use App\Service\InsuranceService;
|
||||
use App\Service\ParticipantEligibilityService;
|
||||
use App\Service\BookingPriceCalculator;
|
||||
use App\Service\InsuranceManager;
|
||||
use App\Service\ParticipantEligibilityChecker;
|
||||
use App\Service\ParticipantPricingCalculator;
|
||||
use App\Service\RoomPricingCalculator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BookingPriceCalculatorServiceTest extends TestCase
|
||||
class BookingPriceCalculatorTest extends TestCase
|
||||
{
|
||||
private BookingPriceCalculatorService $service;
|
||||
private ParticipantEligibilityService $participantEligibilityService;
|
||||
private BookingPriceCalculator $service;
|
||||
private ParticipantEligibilityChecker $participantEligibilityService;
|
||||
private RoomPricingCalculator $roomPricingCalculator;
|
||||
private ParticipantPricingCalculator $participantPricingCalculator;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->participantEligibilityService = $this->createMock(ParticipantEligibilityService::class);
|
||||
$this->participantEligibilityService = $this->createMock(ParticipantEligibilityChecker::class);
|
||||
$this->participantEligibilityService->method('isParticipantEligible')->willReturn(true);
|
||||
|
||||
$this->roomPricingCalculator = new RoomPricingCalculator();
|
||||
@@ -595,7 +595,7 @@ class BookingPriceCalculatorServiceTest extends TestCase
|
||||
$bookingDto->participants = [$participant1, $participant2];
|
||||
|
||||
// Mock participant eligibility to mark second participant as ineligible
|
||||
$participantEligibilityService = $this->createMock(ParticipantEligibilityService::class);
|
||||
$participantEligibilityService = $this->createMock(ParticipantEligibilityChecker::class);
|
||||
$participantEligibilityService->method('isParticipantEligible')
|
||||
->willReturnCallback(fn ($booking, $index) => 0 === $index); // Only first participant eligible
|
||||
|
||||
@@ -695,12 +695,12 @@ class BookingPriceCalculatorServiceTest extends TestCase
|
||||
return $participant;
|
||||
}
|
||||
|
||||
private function createService(ParticipantEligibilityService $participantEligibilityService): BookingPriceCalculatorService
|
||||
private function createService(ParticipantEligibilityChecker $participantEligibilityService): BookingPriceCalculator
|
||||
{
|
||||
return new BookingPriceCalculatorService(
|
||||
return new BookingPriceCalculator(
|
||||
$this->roomPricingCalculator,
|
||||
$participantEligibilityService,
|
||||
new InsuranceService(),
|
||||
new InsuranceManager(),
|
||||
$this->participantPricingCalculator,
|
||||
);
|
||||
}
|
||||
+6
-6
@@ -11,16 +11,16 @@ use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Model\RoomSelectionDto;
|
||||
use App\Service\BookingPriceCalculatorService;
|
||||
use App\Service\BookingPriceMismatchDiagnosticsService;
|
||||
use App\Service\BookingPricingAssembler;
|
||||
use App\Service\BookingPriceMismatchAnalyzer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BookingPriceMismatchDiagnosticsServiceTest extends TestCase
|
||||
class BookingPriceMismatchAnalyzerTest extends TestCase
|
||||
{
|
||||
public function testBuildDiagnosticsProvidesDeltaBreakdown(): void
|
||||
{
|
||||
$priceCalculator = $this->createMock(BookingPriceCalculatorService::class);
|
||||
$priceCalculator->method('getPricingBreakdown')->willReturn([
|
||||
$pricingAssembler = $this->createMock(BookingPricingAssembler::class);
|
||||
$pricingAssembler->method('getPricingBreakdown')->willReturn([
|
||||
'rooms' => [
|
||||
['roomId' => 74, 'totalPrice' => 444.0],
|
||||
],
|
||||
@@ -36,7 +36,7 @@ class BookingPriceMismatchDiagnosticsServiceTest extends TestCase
|
||||
'grandTotal' => 513.5,
|
||||
]);
|
||||
|
||||
$service = new BookingPriceMismatchDiagnosticsService($priceCalculator);
|
||||
$service = new BookingPriceMismatchAnalyzer($pricingAssembler);
|
||||
|
||||
$bookingDto = new BookingDto(new Travel(), 197136);
|
||||
$roomSelection = new RoomSelectionDto();
|
||||
+8
-8
@@ -8,22 +8,22 @@ use App\BusProNet\Model\Booking;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\RoomSelectionDto;
|
||||
use App\Service\BookingSessionService;
|
||||
use App\Service\TravelDataService;
|
||||
use App\Service\BookingSessionStore;
|
||||
use App\Service\TravelDataProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
||||
|
||||
class BookingSessionServiceTest extends TestCase
|
||||
class BookingSessionStoreTest extends TestCase
|
||||
{
|
||||
private TravelDataService $travelDataService;
|
||||
private BookingSessionService $service;
|
||||
private TravelDataProvider $travelDataService;
|
||||
private BookingSessionStore $service;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->travelDataService = $this->createMock(TravelDataService::class);
|
||||
$this->service = new BookingSessionService($this->travelDataService);
|
||||
$this->travelDataService = $this->createMock(TravelDataProvider::class);
|
||||
$this->service = new BookingSessionStore($this->travelDataService);
|
||||
}
|
||||
|
||||
public function testGetOrCreateBookingCreateDtoThrowsWhenSessionMissing(): void
|
||||
@@ -91,7 +91,7 @@ class BookingSessionServiceTest extends TestCase
|
||||
|
||||
$this->service->storeReturnUrl($request, 'javascript:alert(1)');
|
||||
|
||||
$this->assertSame(BookingSessionService::DEFAULT_RETURN_URL, $this->service->getReturnUrl($request));
|
||||
$this->assertSame(BookingSessionStore::DEFAULT_RETURN_URL, $this->service->getReturnUrl($request));
|
||||
}
|
||||
|
||||
public function testClearBookingSessionPreservesReturnUrl(): void
|
||||
@@ -4,20 +4,20 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Service;
|
||||
|
||||
use App\Service\ErrorCodeService;
|
||||
use App\Service\ErrorCodeGenerator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
class ErrorCodeServiceTest extends TestCase
|
||||
class ErrorCodeGeneratorTest extends TestCase
|
||||
{
|
||||
private RequestStack $requestStack;
|
||||
private ErrorCodeService $service;
|
||||
private ErrorCodeGenerator $service;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->requestStack = new RequestStack();
|
||||
$this->service = new ErrorCodeService($this->requestStack);
|
||||
$this->service = new ErrorCodeGenerator($this->requestStack);
|
||||
}
|
||||
|
||||
public function testReturnsNullWithoutRequest(): void
|
||||
@@ -67,7 +67,7 @@ class ErrorCodeServiceTest extends TestCase
|
||||
$request1->attributes->set('request_id', 'abc123');
|
||||
$this->requestStack->push($request1);
|
||||
|
||||
$service1 = new ErrorCodeService($this->requestStack);
|
||||
$service1 = new ErrorCodeGenerator($this->requestStack);
|
||||
$result1 = $service1->getErrorCode();
|
||||
|
||||
$this->requestStack->pop();
|
||||
@@ -76,7 +76,7 @@ class ErrorCodeServiceTest extends TestCase
|
||||
$request2->attributes->set('request_id', 'xyz789');
|
||||
$this->requestStack->push($request2);
|
||||
|
||||
$service2 = new ErrorCodeService($this->requestStack);
|
||||
$service2 = new ErrorCodeGenerator($this->requestStack);
|
||||
$result2 = $service2->getErrorCode();
|
||||
|
||||
$this->assertNotSame($result1, $result2);
|
||||
@@ -88,7 +88,7 @@ class ErrorCodeServiceTest extends TestCase
|
||||
$request1->attributes->set('request_id', 'abc123_1');
|
||||
$this->requestStack->push($request1);
|
||||
|
||||
$service1 = new ErrorCodeService($this->requestStack);
|
||||
$service1 = new ErrorCodeGenerator($this->requestStack);
|
||||
$result1 = $service1->getErrorCode();
|
||||
|
||||
$this->requestStack->pop();
|
||||
@@ -97,7 +97,7 @@ class ErrorCodeServiceTest extends TestCase
|
||||
$request2->attributes->set('request_id', 'abc123_2');
|
||||
$this->requestStack->push($request2);
|
||||
|
||||
$service2 = new ErrorCodeService($this->requestStack);
|
||||
$service2 = new ErrorCodeGenerator($this->requestStack);
|
||||
$result2 = $service2->getErrorCode();
|
||||
|
||||
$this->assertSame($result1, $result2);
|
||||
@@ -109,7 +109,7 @@ class ErrorCodeServiceTest extends TestCase
|
||||
$request1->attributes->set('request_id', 'abc123');
|
||||
$this->requestStack->push($request1);
|
||||
|
||||
$service1 = new ErrorCodeService($this->requestStack);
|
||||
$service1 = new ErrorCodeGenerator($this->requestStack);
|
||||
$result1 = $service1->getErrorCode();
|
||||
|
||||
$this->requestStack->pop();
|
||||
@@ -118,7 +118,7 @@ class ErrorCodeServiceTest extends TestCase
|
||||
$request2->attributes->set('request_id', 'abc123_5');
|
||||
$this->requestStack->push($request2);
|
||||
|
||||
$service2 = new ErrorCodeService($this->requestStack);
|
||||
$service2 = new ErrorCodeGenerator($this->requestStack);
|
||||
$result2 = $service2->getErrorCode();
|
||||
|
||||
$this->assertSame($result1, $result2);
|
||||
@@ -8,18 +8,18 @@ use App\BusProNet\Model\Insurance;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Service\InsuranceService;
|
||||
use App\Service\InsuranceManager;
|
||||
use Carbon\Carbon;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class InsuranceServiceTest extends TestCase
|
||||
class InsuranceManagerTest extends TestCase
|
||||
{
|
||||
private InsuranceService $service;
|
||||
private InsuranceManager $service;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
// InsuranceService is stateless and has no dependencies
|
||||
$this->service = new InsuranceService();
|
||||
// InsuranceManager is stateless and has no dependencies
|
||||
$this->service = new InsuranceManager();
|
||||
|
||||
// Set a fixed test date for consistent test results
|
||||
Carbon::setTestNow('2024-06-01 12:00:00');
|
||||
+7
-7
@@ -8,22 +8,22 @@ use App\BusProNet\Model\Room;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Service\BookingPriceCalculatorService;
|
||||
use App\Service\ParticipantCardDataService;
|
||||
use App\Service\BookingPriceCalculator;
|
||||
use App\Service\ParticipantCardAssembler;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
class ParticipantCardDataServiceTest extends TestCase
|
||||
class ParticipantCardAssemblerTest extends TestCase
|
||||
{
|
||||
private ParticipantCardDataService $service;
|
||||
private BookingPriceCalculatorService $priceCalculator;
|
||||
private ParticipantCardAssembler $service;
|
||||
private BookingPriceCalculator $priceCalculator;
|
||||
private ValidatorInterface $validator;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->priceCalculator = $this->createMock(BookingPriceCalculatorService::class);
|
||||
$this->priceCalculator = $this->createMock(BookingPriceCalculator::class);
|
||||
$this->validator = $this->createMock(ValidatorInterface::class);
|
||||
$this->service = new ParticipantCardDataService(
|
||||
$this->service = new ParticipantCardAssembler(
|
||||
$this->priceCalculator,
|
||||
$this->validator
|
||||
);
|
||||
+13
-13
@@ -13,17 +13,17 @@ use App\Entity\User;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Security\Crypt;
|
||||
use App\Service\ParticipantPrepopulationService;
|
||||
use App\Service\ParticipantDataPrefiller;
|
||||
use Carbon\CarbonImmutable;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class ParticipantPrepopulationServiceTest extends TestCase
|
||||
class ParticipantDataPrefillerTest extends TestCase
|
||||
{
|
||||
private ApiClient $apiClient;
|
||||
private Crypt $crypt;
|
||||
private LoggerInterface $logger;
|
||||
private ParticipantPrepopulationService $service;
|
||||
private ParticipantDataPrefiller $service;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
@@ -31,7 +31,7 @@ class ParticipantPrepopulationServiceTest extends TestCase
|
||||
$this->crypt = $this->createMock(Crypt::class);
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
|
||||
$this->service = new ParticipantPrepopulationService(
|
||||
$this->service = new ParticipantDataPrefiller(
|
||||
$this->apiClient,
|
||||
$this->crypt,
|
||||
$this->logger
|
||||
@@ -56,7 +56,7 @@ class ParticipantPrepopulationServiceTest extends TestCase
|
||||
->with('[email protected]', 'decrypted_password')
|
||||
->willReturn($personalData);
|
||||
|
||||
$result = $this->service->prepopulateApplicantFromUser($user, $applicant);
|
||||
$result = $this->service->prefillApplicantFromUser($user, $applicant);
|
||||
|
||||
// BPN API IDs for linking to existing records
|
||||
$this->assertSame(12345, $result->addressId);
|
||||
@@ -102,7 +102,7 @@ class ParticipantPrepopulationServiceTest extends TestCase
|
||||
->method('getPersonalData')
|
||||
->willReturn($personalData);
|
||||
|
||||
$result = $this->service->prepopulateApplicantFromUser($user, $applicant);
|
||||
$result = $this->service->prefillApplicantFromUser($user, $applicant);
|
||||
|
||||
// Required fields should be populated
|
||||
$this->assertSame('Jane', $result->firstName);
|
||||
@@ -148,7 +148,7 @@ class ParticipantPrepopulationServiceTest extends TestCase
|
||||
$this->logger->expects($this->never())
|
||||
->method('info');
|
||||
|
||||
$result = $this->service->prepopulateApplicantFromUser($user, $applicant);
|
||||
$result = $this->service->prefillApplicantFromUser($user, $applicant);
|
||||
|
||||
// Should return unchanged applicant
|
||||
$this->assertNull($result->firstName);
|
||||
@@ -176,7 +176,7 @@ class ParticipantPrepopulationServiceTest extends TestCase
|
||||
'email' => '[email protected]',
|
||||
]);
|
||||
|
||||
$result = $this->service->prepopulateApplicantFromUser($user, $applicant);
|
||||
$result = $this->service->prefillApplicantFromUser($user, $applicant);
|
||||
|
||||
// Should return unchanged applicant
|
||||
$this->assertNull($result->firstName);
|
||||
@@ -205,7 +205,7 @@ class ParticipantPrepopulationServiceTest extends TestCase
|
||||
'email' => '[email protected]',
|
||||
]);
|
||||
|
||||
$result = $this->service->prepopulateApplicantFromUser($user, $applicant);
|
||||
$result = $this->service->prefillApplicantFromUser($user, $applicant);
|
||||
|
||||
// Should return unchanged applicant
|
||||
$this->assertNull($result->firstName);
|
||||
@@ -231,7 +231,7 @@ class ParticipantPrepopulationServiceTest extends TestCase
|
||||
->method('getPersonalData')
|
||||
->willReturn($personalData);
|
||||
|
||||
$result = $this->service->prepopulateApplicantFromUser($user, $applicant);
|
||||
$result = $this->service->prefillApplicantFromUser($user, $applicant);
|
||||
|
||||
// Personal data should be updated
|
||||
$this->assertSame('John', $result->firstName);
|
||||
@@ -250,14 +250,14 @@ class ParticipantPrepopulationServiceTest extends TestCase
|
||||
$filled = new ParticipantDto();
|
||||
$filled->firstName = 'Already set';
|
||||
|
||||
$this->assertTrue($this->service->shouldPrepopulateApplicant($fresh));
|
||||
$this->assertFalse($this->service->shouldPrepopulateApplicant($filled));
|
||||
$this->assertTrue($this->service->shouldPrefillApplicant($fresh));
|
||||
$this->assertFalse($this->service->shouldPrefillApplicant($filled));
|
||||
}
|
||||
|
||||
public function testDummyTokenMatchesOnlyInCreateMode(): void
|
||||
{
|
||||
$participant = new ParticipantDto();
|
||||
$participant->lastName = ParticipantPrepopulationService::TOKEN;
|
||||
$participant->lastName = ParticipantDataPrefiller::TOKEN;
|
||||
|
||||
$this->assertTrue($this->service->isDummyDataFillRequested($participant, BookingDto::MODE_CREATE));
|
||||
$this->assertFalse($this->service->isDummyDataFillRequested($participant, BookingDto::MODE_EDIT));
|
||||
+4
-4
@@ -9,16 +9,16 @@ use App\BusProNet\Model\Service;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Service\ParticipantEligibilityService;
|
||||
use App\Service\ParticipantEligibilityChecker;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ParticipantEligibilityServiceTest extends TestCase
|
||||
class ParticipantEligibilityCheckerTest extends TestCase
|
||||
{
|
||||
private ParticipantEligibilityService $service;
|
||||
private ParticipantEligibilityChecker $service;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->service = new ParticipantEligibilityService();
|
||||
$this->service = new ParticipantEligibilityChecker();
|
||||
}
|
||||
|
||||
public function testBabyParticipantIsAlwaysEligible(): void
|
||||
+4
-4
@@ -9,11 +9,11 @@ use App\BusProNet\Model\Travel;
|
||||
use App\Exception\ParticipantNotFoundException;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Service\ParticipantFormSupportService;
|
||||
use App\Service\ParticipantFormSupport;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
|
||||
class ParticipantFormSupportServiceTest extends TestCase
|
||||
class ParticipantFormSupportTest extends TestCase
|
||||
{
|
||||
public function testEnsureParticipantExistsThrowsForMissingIndex(): void
|
||||
{
|
||||
@@ -84,11 +84,11 @@ class ParticipantFormSupportServiceTest extends TestCase
|
||||
$this->assertFalse($options['validation_groups']);
|
||||
}
|
||||
|
||||
private function createService(?ParameterBagInterface $parameterBag = null): ParticipantFormSupportService
|
||||
private function createService(?ParameterBagInterface $parameterBag = null): ParticipantFormSupport
|
||||
{
|
||||
$parameterBag ??= $this->createMock(ParameterBagInterface::class);
|
||||
|
||||
return new ParticipantFormSupportService($parameterBag);
|
||||
return new ParticipantFormSupport($parameterBag);
|
||||
}
|
||||
|
||||
private function createBookingDto(): BookingDto
|
||||
@@ -10,19 +10,19 @@ use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Model\RoomSelectionDto;
|
||||
use App\Service\RoomAssignmentService;
|
||||
use App\Service\RoomAssigner;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Tests for RoomAssignmentService.
|
||||
* Tests for RoomAssigner.
|
||||
*/
|
||||
class RoomAssignmentServiceTest extends TestCase
|
||||
class RoomAssignerTest extends TestCase
|
||||
{
|
||||
private RoomAssignmentService $service;
|
||||
private RoomAssigner $service;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->service = new RoomAssignmentService();
|
||||
$this->service = new RoomAssigner();
|
||||
}
|
||||
|
||||
/**
|
||||
+13
-13
@@ -8,24 +8,24 @@ use App\BusProNet\ApiClient;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\BusProNet\XmlLoader\TravelLoader;
|
||||
use App\Exception\TravelNotFoundException;
|
||||
use App\Service\TravelDataService;
|
||||
use App\Service\TravelEnrichmentService;
|
||||
use App\Service\TravelLookupService;
|
||||
use App\Service\TravelSnapshotService;
|
||||
use App\Service\TravelDataProvider;
|
||||
use App\Service\TravelEnricher;
|
||||
use App\Service\TravelIndex;
|
||||
use App\Service\TravelSnapshotManager;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Contracts\Cache\CacheInterface;
|
||||
|
||||
class TravelDataServiceTest extends TestCase
|
||||
class TravelDataProviderTest extends TestCase
|
||||
{
|
||||
private TravelDataService $service;
|
||||
private TravelDataProvider $service;
|
||||
private TravelLoader $travelLoader;
|
||||
private ApiClient $apiClient;
|
||||
private CacheInterface $cache;
|
||||
private LoggerInterface $logger;
|
||||
private TravelSnapshotService $travelSnapshotService;
|
||||
private TravelLookupService $travelLookupService;
|
||||
private TravelEnrichmentService $travelEnrichmentService;
|
||||
private TravelSnapshotManager $travelSnapshotService;
|
||||
private TravelIndex $travelLookupService;
|
||||
private TravelEnricher $travelEnrichmentService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
@@ -33,11 +33,11 @@ class TravelDataServiceTest extends TestCase
|
||||
$this->apiClient = $this->createMock(ApiClient::class);
|
||||
$this->cache = $this->createMock(CacheInterface::class);
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
$this->travelSnapshotService = $this->createMock(TravelSnapshotService::class);
|
||||
$this->travelLookupService = $this->createMock(TravelLookupService::class);
|
||||
$this->travelEnrichmentService = $this->createMock(TravelEnrichmentService::class);
|
||||
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
||||
$this->travelLookupService = $this->createMock(TravelIndex::class);
|
||||
$this->travelEnrichmentService = $this->createMock(TravelEnricher::class);
|
||||
|
||||
$this->service = new TravelDataService(
|
||||
$this->service = new TravelDataProvider(
|
||||
$this->travelLoader,
|
||||
$this->apiClient,
|
||||
$this->cache,
|
||||
+4
-4
@@ -9,13 +9,13 @@ use App\BusProNet\Model\Travel;
|
||||
use App\BusProNet\XmlLoader\HotelLoader;
|
||||
use App\BusProNet\XmlLoader\InsuranceLoader;
|
||||
use App\BusProNet\XmlLoader\PickupLoader;
|
||||
use App\Service\TravelEnrichmentService;
|
||||
use App\Service\TravelEnricher;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class TravelEnrichmentServiceTest extends TestCase
|
||||
class TravelEnricherTest extends TestCase
|
||||
{
|
||||
private TravelEnrichmentService $service;
|
||||
private TravelEnricher $service;
|
||||
private PickupLoader $pickupLoader;
|
||||
private HotelLoader $hotelLoader;
|
||||
private InsuranceLoader $insuranceLoader;
|
||||
@@ -28,7 +28,7 @@ class TravelEnrichmentServiceTest extends TestCase
|
||||
$this->insuranceLoader = $this->createMock(InsuranceLoader::class);
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
|
||||
$this->service = new TravelEnrichmentService(
|
||||
$this->service = new TravelEnricher(
|
||||
$this->pickupLoader,
|
||||
$this->hotelLoader,
|
||||
$this->insuranceLoader,
|
||||
@@ -6,27 +6,27 @@ namespace App\Tests\Service;
|
||||
|
||||
use App\BusProNet\XmlLoader\HotelLoader;
|
||||
use App\BusProNet\XmlLoader\TravelLoader;
|
||||
use App\Service\TravelLookupService;
|
||||
use App\Service\TravelSnapshotService;
|
||||
use App\Service\TravelIndex;
|
||||
use App\Service\TravelSnapshotManager;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class TravelLookupServiceTest extends TestCase
|
||||
class TravelIndexTest extends TestCase
|
||||
{
|
||||
private TravelLookupService $service;
|
||||
private TravelIndex $service;
|
||||
private TravelLoader $travelLoader;
|
||||
private HotelLoader $hotelLoader;
|
||||
private TravelSnapshotService $travelSnapshotService;
|
||||
private TravelSnapshotManager $travelSnapshotService;
|
||||
private LoggerInterface $logger;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->travelLoader = $this->createMock(TravelLoader::class);
|
||||
$this->hotelLoader = $this->createMock(HotelLoader::class);
|
||||
$this->travelSnapshotService = $this->createMock(TravelSnapshotService::class);
|
||||
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
|
||||
$this->service = new TravelLookupService(
|
||||
$this->service = new TravelIndex(
|
||||
$this->travelLoader,
|
||||
$this->hotelLoader,
|
||||
$this->travelSnapshotService,
|
||||
+4
-4
@@ -11,20 +11,20 @@ use App\BusProNet\Model\Hotel;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Entity\TravelSnapshot;
|
||||
use App\Repository\TravelSnapshotRepository;
|
||||
use App\Service\TravelSnapshotService;
|
||||
use App\Service\TravelSnapshotManager;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
class TravelSnapshotServiceTest extends TestCase
|
||||
class TravelSnapshotManagerTest extends TestCase
|
||||
{
|
||||
private TravelSnapshotRepository $snapshotRepository;
|
||||
private EntityManagerInterface $entityManager;
|
||||
private ApiClient $apiClient;
|
||||
private LoggerInterface $logger;
|
||||
private SerializerInterface $serializer;
|
||||
private TravelSnapshotService $service;
|
||||
private TravelSnapshotManager $service;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
@@ -34,7 +34,7 @@ class TravelSnapshotServiceTest extends TestCase
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
$this->serializer = $this->createMock(SerializerInterface::class);
|
||||
|
||||
$this->service = new TravelSnapshotService(
|
||||
$this->service = new TravelSnapshotManager(
|
||||
$this->snapshotRepository,
|
||||
$this->entityManager,
|
||||
$this->apiClient,
|
||||
@@ -11,19 +11,19 @@ use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Model\ParticipantEditDto;
|
||||
use App\Form\Service\ServiceAgeEvaluator;
|
||||
use App\Service\ParticipantEligibilityService;
|
||||
use App\Service\ParticipantEligibilityChecker;
|
||||
use App\Validator\Constraints\MandatoryAdditionalServicesSelected;
|
||||
use App\Validator\Constraints\MandatoryAdditionalServicesSelectedValidator;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
class MandatoryAdditionalServicesSelectedValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
private ParticipantEligibilityService $participantEligibilityService;
|
||||
private ParticipantEligibilityChecker $participantEligibilityService;
|
||||
private bool $participantEligible = true;
|
||||
|
||||
protected function createValidator(): MandatoryAdditionalServicesSelectedValidator
|
||||
{
|
||||
$this->participantEligibilityService = $this->createMock(ParticipantEligibilityService::class);
|
||||
$this->participantEligibilityService = $this->createMock(ParticipantEligibilityChecker::class);
|
||||
$this->participantEligibilityService
|
||||
->method('isParticipantEligible')
|
||||
->willReturnCallback(fn (): bool => $this->participantEligible);
|
||||
|
||||
Reference in New Issue
Block a user