feat: move scope of enforced 'option' status to full booking
addresses #869chtfeq
This commit is contained in:
@@ -5,8 +5,10 @@ declare(strict_types=1);
|
||||
namespace App\Tests\Service;
|
||||
|
||||
use App\BusProNet\Constants;
|
||||
use App\BusProNet\Model\Service;
|
||||
use App\BusProNet\Model\Room;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\BusProNet\Service\BookingStatusRuleRegistry;
|
||||
use App\BusProNet\XmlLoader\AgencyLoader;
|
||||
use App\Exception\NoRoomsAvailableException;
|
||||
use App\Service\BookingPriceCalculatorService;
|
||||
@@ -28,12 +30,15 @@ class BookingServiceStatusTest extends TestCase
|
||||
$this->travelDataService = $this->createMock(TravelDataService::class);
|
||||
$priceCalculator = $this->createMock(BookingPriceCalculatorService::class);
|
||||
$participantEligibility = $this->createMock(ParticipantEligibilityService::class);
|
||||
$bookingStatusRuleRegistry = $this->createMock(BookingStatusRuleRegistry::class);
|
||||
$bookingStatusRuleRegistry->method('evaluateStatus')->willReturn('F');
|
||||
$agencyLoader = $this->createMock(AgencyLoader::class);
|
||||
|
||||
$this->bookingService = new BookingService(
|
||||
$this->travelDataService,
|
||||
$priceCalculator,
|
||||
$participantEligibility,
|
||||
$bookingStatusRuleRegistry,
|
||||
$agencyLoader,
|
||||
'F' // default booking status
|
||||
);
|
||||
@@ -167,6 +172,65 @@ class BookingServiceStatusTest extends TestCase
|
||||
$this->assertSame('A', $bookingDto->bookingStatus);
|
||||
}
|
||||
|
||||
public function testApplyCreateBookingStatusRulesSetsOptionFromRegistry(): void
|
||||
{
|
||||
$bookingStatusRuleRegistry = $this->createMock(BookingStatusRuleRegistry::class);
|
||||
$bookingStatusRuleRegistry->method('evaluateStatus')->willReturn('O');
|
||||
|
||||
$bookingService = new BookingService(
|
||||
$this->travelDataService,
|
||||
$this->createMock(BookingPriceCalculatorService::class),
|
||||
$this->createMock(ParticipantEligibilityService::class),
|
||||
$bookingStatusRuleRegistry,
|
||||
$this->createMock(AgencyLoader::class),
|
||||
'F'
|
||||
);
|
||||
|
||||
$travel = new Travel();
|
||||
$travel->id = 123;
|
||||
$travel->hotelId = 456;
|
||||
$travel->dateFrom = new \DateTimeImmutable('2030-01-01');
|
||||
$travel->dateTo = new \DateTimeImmutable('2030-01-06');
|
||||
|
||||
$bookingDto = new \App\Form\Model\BookingDto($travel, 456);
|
||||
$bookingDto->bookingStatus = 'F';
|
||||
$participant = new \App\Form\Model\ParticipantDto();
|
||||
$participant->additionalServices = [new Service()];
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
$bookingService->applyCreateBookingStatusRules($bookingDto);
|
||||
|
||||
$this->assertSame('O', $bookingDto->bookingStatus);
|
||||
}
|
||||
|
||||
public function testApplyCreateBookingStatusRulesKeepsInquiryStatus(): void
|
||||
{
|
||||
$bookingStatusRuleRegistry = $this->createMock(BookingStatusRuleRegistry::class);
|
||||
$bookingStatusRuleRegistry->expects($this->never())->method('evaluateStatus');
|
||||
|
||||
$bookingService = new BookingService(
|
||||
$this->travelDataService,
|
||||
$this->createMock(BookingPriceCalculatorService::class),
|
||||
$this->createMock(ParticipantEligibilityService::class),
|
||||
$bookingStatusRuleRegistry,
|
||||
$this->createMock(AgencyLoader::class),
|
||||
'F'
|
||||
);
|
||||
|
||||
$travel = new Travel();
|
||||
$travel->id = 123;
|
||||
$travel->hotelId = 456;
|
||||
$travel->dateFrom = new \DateTimeImmutable('2030-01-01');
|
||||
$travel->dateTo = new \DateTimeImmutable('2030-01-06');
|
||||
|
||||
$bookingDto = new \App\Form\Model\BookingDto($travel, 456);
|
||||
$bookingDto->bookingStatus = 'A';
|
||||
|
||||
$bookingService->applyCreateBookingStatusRules($bookingDto);
|
||||
|
||||
$this->assertSame('A', $bookingDto->bookingStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<array{status: string, available: int}> $roomsConfig
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user