dateFrom = new \DateTimeImmutable('2030-01-01'); $travel->dateTo = new \DateTimeImmutable('2030-01-06'); $bookingDto = new BookingDto($travel, 157047); $travelDataService = $this->createMock(TravelDataService::class); $travelDataService->expects($this->once()) ->method('enrichWithFreshAvailabilities') ->with($travel); $service = new BookingEditParticipantContextFactory( $this->createMock(BookingSummaryDataService::class), $travelDataService, ); $service->prepareBookingDto($bookingDto); } public function testCreateBuildsEditContext(): void { $travel = new Travel(); $travel->dateFrom = new \DateTimeImmutable('2030-01-01'); $travel->dateTo = new \DateTimeImmutable('2030-01-06'); $bookingDto = new BookingDto($travel, 157047); $bookingDto->booking = new Booking(); $bookingData = new Booking(); $bookingData->dateId = 1234; $mutableData = new BaseData([]); $summaryData = $this->createMock(BookingSummaryDto::class); $summaryDataService = $this->createMock(BookingSummaryDataService::class); $summaryDataService->expects($this->once()) ->method('getSummaryData') ->with($bookingDto) ->willReturn($summaryData); $travelDataService = $this->createMock(TravelDataService::class); $travelDataService->expects($this->once()) ->method('getMutabilityData') ->with(1234) ->willReturn($mutableData); $service = new BookingEditParticipantContextFactory($summaryDataService, $travelDataService); $context = $service->create($bookingDto, $bookingData); $this->assertInstanceOf(BookingEditParticipantContext::class, $context); $this->assertSame($bookingDto, $context->bookingDto); $this->assertSame($bookingData, $context->bookingData); $this->assertSame($mutableData, $context->mutableData); $this->assertSame($summaryData, $context->summaryData); } }