feat: upgrade phpunit to 12.5
This commit is contained in:
+1
-5
@@ -8,13 +8,9 @@
|
|||||||
/vendor/
|
/vendor/
|
||||||
###< symfony/framework-bundle ###
|
###< symfony/framework-bundle ###
|
||||||
|
|
||||||
###> phpunit/phpunit ###
|
|
||||||
/phpunit.xml
|
|
||||||
.phpunit.result.cache
|
|
||||||
###< phpunit/phpunit ###
|
|
||||||
|
|
||||||
###> symfony/phpunit-bridge ###
|
###> symfony/phpunit-bridge ###
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
|
.phpunit.cache
|
||||||
/phpunit.xml
|
/phpunit.xml
|
||||||
###< symfony/phpunit-bridge ###
|
###< symfony/phpunit-bridge ###
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -129,13 +129,13 @@
|
|||||||
"phpstan/phpstan": "^2.1",
|
"phpstan/phpstan": "^2.1",
|
||||||
"phpstan/phpstan-doctrine": "^2.0",
|
"phpstan/phpstan-doctrine": "^2.0",
|
||||||
"phpstan/phpstan-symfony": "^2.0",
|
"phpstan/phpstan-symfony": "^2.0",
|
||||||
"phpunit/phpunit": "^9.5",
|
"phpunit/phpunit": "^12",
|
||||||
"rector/rector": "^2.4",
|
"rector/rector": "^2.4",
|
||||||
"symfony/browser-kit": "7.4.*",
|
"symfony/browser-kit": "7.4.*",
|
||||||
"symfony/css-selector": "7.4.*",
|
"symfony/css-selector": "7.4.*",
|
||||||
"symfony/debug-bundle": "7.4.*",
|
"symfony/debug-bundle": "7.4.*",
|
||||||
"symfony/maker-bundle": "^1.0",
|
"symfony/maker-bundle": "^1.0",
|
||||||
"symfony/phpunit-bridge": "^7.1",
|
"symfony/phpunit-bridge": "^7.4",
|
||||||
"symfony/stopwatch": "7.4.*",
|
"symfony/stopwatch": "7.4.*",
|
||||||
"symfony/web-profiler-bundle": "7.4.*"
|
"symfony/web-profiler-bundle": "7.4.*"
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+369
-386
File diff suppressed because it is too large
Load Diff
+7
-10
@@ -1,20 +1,20 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
|
<!-- https://docs.phpunit.de/en/12.5/configuration.html -->
|
||||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||||
backupGlobals="false"
|
backupGlobals="false"
|
||||||
colors="true"
|
colors="true"
|
||||||
bootstrap="tests/bootstrap.php"
|
bootstrap="tests/bootstrap.php"
|
||||||
convertDeprecationsToExceptions="false"
|
cacheDirectory=".phpunit.cache"
|
||||||
|
displayDetailsOnTestsThatTriggerDeprecations="true"
|
||||||
|
displayDetailsOnPhpunitDeprecations="true"
|
||||||
>
|
>
|
||||||
<php>
|
<php>
|
||||||
<ini name="display_errors" value="1" />
|
<ini name="display_errors" value="1" />
|
||||||
<ini name="error_reporting" value="-1" />
|
<ini name="error_reporting" value="-1" />
|
||||||
<server name="APP_ENV" value="test" force="true" />
|
<server name="APP_ENV" value="test" force="true" />
|
||||||
<server name="SHELL_VERBOSITY" value="-1" />
|
<server name="SHELL_VERBOSITY" value="-1" />
|
||||||
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
|
|
||||||
<server name="SYMFONY_PHPUNIT_VERSION" value="9.5" />
|
|
||||||
</php>
|
</php>
|
||||||
|
|
||||||
<testsuites>
|
<testsuites>
|
||||||
@@ -23,16 +23,13 @@
|
|||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
||||||
<coverage processUncoveredFiles="true">
|
<source>
|
||||||
<include>
|
<include>
|
||||||
<directory suffix=".php">src</directory>
|
<directory suffix=".php">src</directory>
|
||||||
</include>
|
</include>
|
||||||
</coverage>
|
</source>
|
||||||
|
|
||||||
<listeners>
|
|
||||||
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
|
|
||||||
</listeners>
|
|
||||||
|
|
||||||
<extensions>
|
<extensions>
|
||||||
|
<bootstrap class="Symfony\Bridge\PhpUnit\SymfonyExtension" />
|
||||||
</extensions>
|
</extensions>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|||||||
@@ -17,19 +17,22 @@ use Symfony\Component\Serializer\SerializerInterface;
|
|||||||
|
|
||||||
class ApiClientReceiveTest extends TestCase
|
class ApiClientReceiveTest extends TestCase
|
||||||
{
|
{
|
||||||
private ApiClient $apiClient;
|
private ?ApiClient $apiClient = null;
|
||||||
private LoggerInterface $logger;
|
private LoggerInterface $logger;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->logger = $this->createMock(LoggerInterface::class);
|
$this->logger = $this->createStub(LoggerInterface::class);
|
||||||
|
}
|
||||||
|
|
||||||
$this->apiClient = new ApiClient(
|
private function apiClient(): ApiClient
|
||||||
$this->createMock(SerializerInterface::class),
|
{
|
||||||
$this->createMock(ApiResponseParser::class),
|
return $this->apiClient ??= new ApiClient(
|
||||||
$this->createMock(FilesystemOperator::class),
|
$this->createStub(SerializerInterface::class),
|
||||||
|
$this->createStub(ApiResponseParser::class),
|
||||||
|
$this->createStub(FilesystemOperator::class),
|
||||||
$this->logger,
|
$this->logger,
|
||||||
$this->createMock(BookingDataProcessor::class),
|
$this->createStub(BookingDataProcessor::class),
|
||||||
new RequestStack(),
|
new RequestStack(),
|
||||||
new RequestIdGenerator(),
|
new RequestIdGenerator(),
|
||||||
[
|
[
|
||||||
@@ -43,6 +46,8 @@ class ApiClientReceiveTest extends TestCase
|
|||||||
|
|
||||||
public function testEmptyResponseThrowsImmediateConnectionCloseException(): void
|
public function testEmptyResponseThrowsImmediateConnectionCloseException(): void
|
||||||
{
|
{
|
||||||
|
$this->logger = $this->createMock(LoggerInterface::class);
|
||||||
|
|
||||||
$stream = fopen('php://memory', 'r+');
|
$stream = fopen('php://memory', 'r+');
|
||||||
// Write nothing — stream is immediately at EOF
|
// Write nothing — stream is immediately at EOF
|
||||||
rewind($stream);
|
rewind($stream);
|
||||||
@@ -82,18 +87,18 @@ class ApiClientReceiveTest extends TestCase
|
|||||||
{
|
{
|
||||||
$method = new \ReflectionMethod(ApiClient::class, 'receive');
|
$method = new \ReflectionMethod(ApiClient::class, 'receive');
|
||||||
|
|
||||||
return $method->invoke($this->apiClient, $socket);
|
return $method->invoke($this->apiClient(), $socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setOperationStartTime(): void
|
private function setOperationStartTime(): void
|
||||||
{
|
{
|
||||||
$property = new \ReflectionProperty(ApiClient::class, 'operationStartTime');
|
$property = new \ReflectionProperty(ApiClient::class, 'operationStartTime');
|
||||||
$property->setValue($this->apiClient, microtime(true));
|
$property->setValue($this->apiClient(), microtime(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setSelectedPort(int $port): void
|
private function setSelectedPort(int $port): void
|
||||||
{
|
{
|
||||||
$property = new \ReflectionProperty(ApiClient::class, 'selectedPort');
|
$property = new \ReflectionProperty(ApiClient::class, 'selectedPort');
|
||||||
$property->setValue($this->apiClient, $port);
|
$property->setValue($this->apiClient(), $port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class TravelDataLoaderTest extends TestCase
|
|||||||
->with('test_file.xml')
|
->with('test_file.xml')
|
||||||
->willReturn($xmlContent);
|
->willReturn($xmlContent);
|
||||||
|
|
||||||
$hotelLoader = $this->createMock(HotelLoader::class);
|
$hotelLoader = $this->createStub(HotelLoader::class);
|
||||||
$travelParser = $this->createMock(TravelParser::class);
|
$travelParser = $this->createMock(TravelParser::class);
|
||||||
|
|
||||||
$expectedTravel = new Travel();
|
$expectedTravel = new Travel();
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ class BookingDataProcessorTest extends TestCase
|
|||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
// Create a mock InsuranceManager
|
// Create a mock InsuranceManager
|
||||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
$insuranceService = $this->createStub(InsuranceManager::class);
|
||||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
$priceCalculatorService = $this->createStub(BookingPriceCalculator::class);
|
||||||
|
|
||||||
// Mock getSelectableInsurances to return empty array (not used in these tests)
|
// Mock getSelectableInsurances to return empty array (not used in these tests)
|
||||||
$insuranceService->method('getSelectableInsurances')
|
$insuranceService->method('getSelectableInsurances')
|
||||||
@@ -851,7 +851,7 @@ class BookingDataProcessorTest extends TestCase
|
|||||||
$bookingDto = new BookingDto($this->createMockTravel(), 1);
|
$bookingDto = new BookingDto($this->createMockTravel(), 1);
|
||||||
$bookingDto->participants = [$applicant, $dependent];
|
$bookingDto->participants = [$applicant, $dependent];
|
||||||
|
|
||||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
$insuranceService = $this->createStub(InsuranceManager::class);
|
||||||
// Both insurances must already look eligible, otherwise the submit-time
|
// Both insurances must already look eligible, otherwise the submit-time
|
||||||
// reconciliation step (added for stale-insurance re-validation) would clear
|
// reconciliation step (added for stale-insurance re-validation) would clear
|
||||||
// them before propagation even runs - this test is only about propagation.
|
// them before propagation even runs - this test is only about propagation.
|
||||||
@@ -864,11 +864,11 @@ class BookingDataProcessorTest extends TestCase
|
|||||||
1 => null,
|
1 => null,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
$priceCalculatorService = $this->createStub(BookingPriceCalculator::class);
|
||||||
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
||||||
$priceCalculatorService->method('resolveInsuranceTravelPrice')->willReturn(0.0);
|
$priceCalculatorService->method('resolveInsuranceTravelPrice')->willReturn(0.0);
|
||||||
|
|
||||||
$payloadBuilder = $this->createMock(BookingPayloadBuilder::class);
|
$payloadBuilder = $this->createStub(BookingPayloadBuilder::class);
|
||||||
$payloadBuilder->method('buildCreatePayload')->willReturn([]);
|
$payloadBuilder->method('buildCreatePayload')->willReturn([]);
|
||||||
|
|
||||||
$processor = new BookingDataProcessor(
|
$processor = new BookingDataProcessor(
|
||||||
@@ -911,14 +911,14 @@ class BookingDataProcessorTest extends TestCase
|
|||||||
$dependent = $formData->participants[1];
|
$dependent = $formData->participants[1];
|
||||||
$dependent->insurance = $dependentInsurance;
|
$dependent->insurance = $dependentInsurance;
|
||||||
|
|
||||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
$insuranceService = $this->createStub(InsuranceManager::class);
|
||||||
$insuranceService->method('getSelectableInsurances')->willReturn([]);
|
$insuranceService->method('getSelectableInsurances')->willReturn([]);
|
||||||
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn([
|
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn([
|
||||||
0 => $familyInsurance,
|
0 => $familyInsurance,
|
||||||
1 => null,
|
1 => null,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
$priceCalculatorService = $this->createStub(BookingPriceCalculator::class);
|
||||||
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
||||||
|
|
||||||
$processor = new BookingDataProcessor(
|
$processor = new BookingDataProcessor(
|
||||||
@@ -961,18 +961,18 @@ class BookingDataProcessorTest extends TestCase
|
|||||||
$bookingDto = new BookingDto($this->createMockTravel(), 1);
|
$bookingDto = new BookingDto($this->createMockTravel(), 1);
|
||||||
$bookingDto->participants = [$applicant];
|
$bookingDto->participants = [$applicant];
|
||||||
|
|
||||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
$insuranceService = $this->createStub(InsuranceManager::class);
|
||||||
$insuranceService->method('getSelectableInsurances')->willReturn([$staleInsurance, $correctTierInsurance]);
|
$insuranceService->method('getSelectableInsurances')->willReturn([$staleInsurance, $correctTierInsurance]);
|
||||||
// Only the higher tier is eligible at the current (updated) price.
|
// Only the higher tier is eligible at the current (updated) price.
|
||||||
$insuranceService->method('getEligibleInsurances')->willReturn([$correctTierInsurance]);
|
$insuranceService->method('getEligibleInsurances')->willReturn([$correctTierInsurance]);
|
||||||
$insuranceService->method('reassignInsuranceForPriceChange')->willReturn($correctTierInsurance);
|
$insuranceService->method('reassignInsuranceForPriceChange')->willReturn($correctTierInsurance);
|
||||||
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn([0 => $correctTierInsurance]);
|
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn([0 => $correctTierInsurance]);
|
||||||
|
|
||||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
$priceCalculatorService = $this->createStub(BookingPriceCalculator::class);
|
||||||
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
||||||
$priceCalculatorService->method('resolveInsuranceTravelPrice')->willReturn(2600.0);
|
$priceCalculatorService->method('resolveInsuranceTravelPrice')->willReturn(2600.0);
|
||||||
|
|
||||||
$payloadBuilder = $this->createMock(BookingPayloadBuilder::class);
|
$payloadBuilder = $this->createStub(BookingPayloadBuilder::class);
|
||||||
$payloadBuilder->method('buildCreatePayload')->willReturn([]);
|
$payloadBuilder->method('buildCreatePayload')->willReturn([]);
|
||||||
|
|
||||||
$processor = new BookingDataProcessor(
|
$processor = new BookingDataProcessor(
|
||||||
@@ -1009,17 +1009,17 @@ class BookingDataProcessorTest extends TestCase
|
|||||||
$bookingDto = new BookingDto($this->createMockTravel(), 1);
|
$bookingDto = new BookingDto($this->createMockTravel(), 1);
|
||||||
$bookingDto->participants = [$applicant];
|
$bookingDto->participants = [$applicant];
|
||||||
|
|
||||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
$insuranceService = $this->createStub(InsuranceManager::class);
|
||||||
$insuranceService->method('getSelectableInsurances')->willReturn([$staleInsurance]);
|
$insuranceService->method('getSelectableInsurances')->willReturn([$staleInsurance]);
|
||||||
$insuranceService->method('getEligibleInsurances')->willReturn([]);
|
$insuranceService->method('getEligibleInsurances')->willReturn([]);
|
||||||
$insuranceService->method('reassignInsuranceForPriceChange')->willReturn(null);
|
$insuranceService->method('reassignInsuranceForPriceChange')->willReturn(null);
|
||||||
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn([0 => null]);
|
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn([0 => null]);
|
||||||
|
|
||||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
$priceCalculatorService = $this->createStub(BookingPriceCalculator::class);
|
||||||
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
||||||
$priceCalculatorService->method('resolveInsuranceTravelPrice')->willReturn(9999.0);
|
$priceCalculatorService->method('resolveInsuranceTravelPrice')->willReturn(9999.0);
|
||||||
|
|
||||||
$payloadBuilder = $this->createMock(BookingPayloadBuilder::class);
|
$payloadBuilder = $this->createStub(BookingPayloadBuilder::class);
|
||||||
$payloadBuilder->method('buildCreatePayload')->willReturn([]);
|
$payloadBuilder->method('buildCreatePayload')->willReturn([]);
|
||||||
|
|
||||||
$processor = new BookingDataProcessor(
|
$processor = new BookingDataProcessor(
|
||||||
@@ -1056,16 +1056,16 @@ class BookingDataProcessorTest extends TestCase
|
|||||||
$bookingDto = new BookingDto($this->createMockTravel(), 1);
|
$bookingDto = new BookingDto($this->createMockTravel(), 1);
|
||||||
$bookingDto->participants = [$applicant];
|
$bookingDto->participants = [$applicant];
|
||||||
|
|
||||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
$insuranceService = $this->createStub(InsuranceManager::class);
|
||||||
$insuranceService->method('getSelectableInsurances')->willReturn([$insurance]);
|
$insuranceService->method('getSelectableInsurances')->willReturn([$insurance]);
|
||||||
$insuranceService->method('getEligibleInsurances')->willReturn([$insurance]);
|
$insuranceService->method('getEligibleInsurances')->willReturn([$insurance]);
|
||||||
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn([0 => $insurance]);
|
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn([0 => $insurance]);
|
||||||
|
|
||||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
$priceCalculatorService = $this->createStub(BookingPriceCalculator::class);
|
||||||
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
||||||
$priceCalculatorService->method('resolveInsuranceTravelPrice')->willReturn(500.0);
|
$priceCalculatorService->method('resolveInsuranceTravelPrice')->willReturn(500.0);
|
||||||
|
|
||||||
$payloadBuilder = $this->createMock(BookingPayloadBuilder::class);
|
$payloadBuilder = $this->createStub(BookingPayloadBuilder::class);
|
||||||
$payloadBuilder->method('buildCreatePayload')->willReturn([]);
|
$payloadBuilder->method('buildCreatePayload')->willReturn([]);
|
||||||
|
|
||||||
$processor = new BookingDataProcessor(
|
$processor = new BookingDataProcessor(
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class BookingStatusRuleRegistryTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testReturnsDefaultStatusWhenNoRulesMatch(): void
|
public function testReturnsDefaultStatusWhenNoRulesMatch(): void
|
||||||
{
|
{
|
||||||
$rule = $this->createMock(BookingStatusRuleInterface::class);
|
$rule = $this->createStub(BookingStatusRuleInterface::class);
|
||||||
$rule->method('evaluate')->willReturn(false);
|
$rule->method('evaluate')->willReturn(false);
|
||||||
$rule->method('getPriority')->willReturn(100);
|
$rule->method('getPriority')->willReturn(100);
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ class BookingStatusRuleRegistryTest extends TestCase
|
|||||||
|
|
||||||
public function testReturnsMatchingRuleStatus(): void
|
public function testReturnsMatchingRuleStatus(): void
|
||||||
{
|
{
|
||||||
$rule = $this->createMock(BookingStatusRuleInterface::class);
|
$rule = $this->createStub(BookingStatusRuleInterface::class);
|
||||||
$rule->method('evaluate')->willReturn(true);
|
$rule->method('evaluate')->willReturn(true);
|
||||||
$rule->method('getStatus')->willReturn('O');
|
$rule->method('getStatus')->willReturn('O');
|
||||||
$rule->method('getPriority')->willReturn(100);
|
$rule->method('getPriority')->willReturn(100);
|
||||||
@@ -40,12 +40,12 @@ class BookingStatusRuleRegistryTest extends TestCase
|
|||||||
|
|
||||||
public function testHigherPriorityRuleTakesPrecedence(): void
|
public function testHigherPriorityRuleTakesPrecedence(): void
|
||||||
{
|
{
|
||||||
$lowPriorityRule = $this->createMock(BookingStatusRuleInterface::class);
|
$lowPriorityRule = $this->createStub(BookingStatusRuleInterface::class);
|
||||||
$lowPriorityRule->method('evaluate')->willReturn(true);
|
$lowPriorityRule->method('evaluate')->willReturn(true);
|
||||||
$lowPriorityRule->method('getStatus')->willReturn('L');
|
$lowPriorityRule->method('getStatus')->willReturn('L');
|
||||||
$lowPriorityRule->method('getPriority')->willReturn(50);
|
$lowPriorityRule->method('getPriority')->willReturn(50);
|
||||||
|
|
||||||
$highPriorityRule = $this->createMock(BookingStatusRuleInterface::class);
|
$highPriorityRule = $this->createStub(BookingStatusRuleInterface::class);
|
||||||
$highPriorityRule->method('evaluate')->willReturn(true);
|
$highPriorityRule->method('evaluate')->willReturn(true);
|
||||||
$highPriorityRule->method('getStatus')->willReturn('H');
|
$highPriorityRule->method('getStatus')->willReturn('H');
|
||||||
$highPriorityRule->method('getPriority')->willReturn(100);
|
$highPriorityRule->method('getPriority')->willReturn(100);
|
||||||
@@ -66,12 +66,12 @@ class BookingStatusRuleRegistryTest extends TestCase
|
|||||||
|
|
||||||
public function testFirstMatchingRuleWinsForSamePriority(): void
|
public function testFirstMatchingRuleWinsForSamePriority(): void
|
||||||
{
|
{
|
||||||
$firstMatchingRule = $this->createMock(BookingStatusRuleInterface::class);
|
$firstMatchingRule = $this->createStub(BookingStatusRuleInterface::class);
|
||||||
$firstMatchingRule->method('evaluate')->willReturn(true);
|
$firstMatchingRule->method('evaluate')->willReturn(true);
|
||||||
$firstMatchingRule->method('getStatus')->willReturn('A');
|
$firstMatchingRule->method('getStatus')->willReturn('A');
|
||||||
$firstMatchingRule->method('getPriority')->willReturn(100);
|
$firstMatchingRule->method('getPriority')->willReturn(100);
|
||||||
|
|
||||||
$secondMatchingRule = $this->createMock(BookingStatusRuleInterface::class);
|
$secondMatchingRule = $this->createStub(BookingStatusRuleInterface::class);
|
||||||
$secondMatchingRule->method('evaluate')->willReturn(true);
|
$secondMatchingRule->method('evaluate')->willReturn(true);
|
||||||
$secondMatchingRule->method('getStatus')->willReturn('B');
|
$secondMatchingRule->method('getStatus')->willReturn('B');
|
||||||
$secondMatchingRule->method('getPriority')->willReturn(100);
|
$secondMatchingRule->method('getPriority')->willReturn(100);
|
||||||
@@ -84,12 +84,12 @@ class BookingStatusRuleRegistryTest extends TestCase
|
|||||||
|
|
||||||
public function testNonMatchingHighPriorityRuleDoesNotBlockLowerPriority(): void
|
public function testNonMatchingHighPriorityRuleDoesNotBlockLowerPriority(): void
|
||||||
{
|
{
|
||||||
$highPriorityRule = $this->createMock(BookingStatusRuleInterface::class);
|
$highPriorityRule = $this->createStub(BookingStatusRuleInterface::class);
|
||||||
$highPriorityRule->method('evaluate')->willReturn(false);
|
$highPriorityRule->method('evaluate')->willReturn(false);
|
||||||
$highPriorityRule->method('getStatus')->willReturn('H');
|
$highPriorityRule->method('getStatus')->willReturn('H');
|
||||||
$highPriorityRule->method('getPriority')->willReturn(100);
|
$highPriorityRule->method('getPriority')->willReturn(100);
|
||||||
|
|
||||||
$lowPriorityRule = $this->createMock(BookingStatusRuleInterface::class);
|
$lowPriorityRule = $this->createStub(BookingStatusRuleInterface::class);
|
||||||
$lowPriorityRule->method('evaluate')->willReturn(true);
|
$lowPriorityRule->method('evaluate')->willReturn(true);
|
||||||
$lowPriorityRule->method('getStatus')->willReturn('L');
|
$lowPriorityRule->method('getStatus')->willReturn('L');
|
||||||
$lowPriorityRule->method('getPriority')->willReturn(50);
|
$lowPriorityRule->method('getPriority')->willReturn(50);
|
||||||
@@ -102,7 +102,7 @@ class BookingStatusRuleRegistryTest extends TestCase
|
|||||||
|
|
||||||
public function testSelection1473RuleWinsOverLowerPriorityRule(): void
|
public function testSelection1473RuleWinsOverLowerPriorityRule(): void
|
||||||
{
|
{
|
||||||
$lowerPriorityRule = $this->createMock(BookingStatusRuleInterface::class);
|
$lowerPriorityRule = $this->createStub(BookingStatusRuleInterface::class);
|
||||||
$lowerPriorityRule->method('evaluate')->willReturn(true);
|
$lowerPriorityRule->method('evaluate')->willReturn(true);
|
||||||
$lowerPriorityRule->method('getStatus')->willReturn('X');
|
$lowerPriorityRule->method('getStatus')->willReturn('X');
|
||||||
$lowerPriorityRule->method('getPriority')->willReturn(100);
|
$lowerPriorityRule->method('getPriority')->willReturn(100);
|
||||||
|
|||||||
@@ -3,13 +3,12 @@
|
|||||||
namespace App\Tests\BusProNet\Utility;
|
namespace App\Tests\BusProNet\Utility;
|
||||||
|
|
||||||
use App\BusProNet\Utility\DayTimeUtility;
|
use App\BusProNet\Utility\DayTimeUtility;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class DayTimeUtilityTest extends TestCase
|
class DayTimeUtilityTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
#[DataProvider('dayTimeProvider')]
|
||||||
* @dataProvider dayTimeProvider
|
|
||||||
*/
|
|
||||||
public function testMapTime(?string $time, ?string $dayTime): void
|
public function testMapTime(?string $time, ?string $dayTime): void
|
||||||
{
|
{
|
||||||
$utility = new DayTimeUtility();
|
$utility = new DayTimeUtility();
|
||||||
@@ -18,7 +17,7 @@ class DayTimeUtilityTest extends TestCase
|
|||||||
$this->assertEquals($dayTime, $result);
|
$this->assertEquals($dayTime, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dayTimeProvider(): array
|
public static function dayTimeProvider(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[null, null],
|
[null, null],
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ namespace App\Tests\BusProNet\XmlLoader;
|
|||||||
use App\BusProNet\Model\Pickup;
|
use App\BusProNet\Model\Pickup;
|
||||||
use App\BusProNet\Model\Travel;
|
use App\BusProNet\Model\Travel;
|
||||||
use App\BusProNet\XmlLoader\PickupLoader;
|
use App\BusProNet\XmlLoader\PickupLoader;
|
||||||
|
use League\Flysystem\FilesystemOperator;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Contracts\Cache\CacheInterface;
|
||||||
|
|
||||||
class PickupLoaderTest extends TestCase
|
class PickupLoaderTest extends TestCase
|
||||||
{
|
{
|
||||||
@@ -15,17 +17,21 @@ class PickupLoaderTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->loader = $this->createPartialMock(PickupLoader::class, ['loadById']);
|
// patchPickupsDetails() is the unit under test; loadById() only has to hand back
|
||||||
$this->loader->method('loadById')->willReturnCallback(function (int $id): Pickup {
|
// a Pickup per id, so a subclass beats a partial mock over the XML/cache stack.
|
||||||
$pickup = new Pickup();
|
$this->loader = new class($this->createStub(CacheInterface::class), $this->createStub(FilesystemOperator::class)) extends PickupLoader {
|
||||||
$pickup->id = $id;
|
public function loadById(int $id, ?string $filename = 'zustiege.xml'): ?Pickup
|
||||||
$pickup->code = 'Z'.$id;
|
{
|
||||||
$pickup->city = 'City '.$id;
|
$pickup = new Pickup();
|
||||||
$pickup->postalCode = '0000'.$id;
|
$pickup->id = $id;
|
||||||
$pickup->street = 'Street '.$id;
|
$pickup->code = 'Z'.$id;
|
||||||
|
$pickup->city = 'City '.$id;
|
||||||
|
$pickup->postalCode = '0000'.$id;
|
||||||
|
$pickup->street = 'Street '.$id;
|
||||||
|
|
||||||
return $pickup;
|
return $pickup;
|
||||||
});
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDropOffsAreOrderedInReverseOfSortedPickups(): void
|
public function testDropOffsAreOrderedInReverseOfSortedPickups(): void
|
||||||
|
|||||||
@@ -71,18 +71,18 @@ class BpnSyncContingentsCommandTest extends TestCase
|
|||||||
$hotelCodes,
|
$hotelCodes,
|
||||||
);
|
);
|
||||||
|
|
||||||
$accommodationRepository = $this->createMock(AccommodationRepository::class);
|
$accommodationRepository = $this->createStub(AccommodationRepository::class);
|
||||||
$accommodationRepository->method('findAllWithCalendarCode')->willReturn($accommodations);
|
$accommodationRepository->method('findAllWithCalendarCode')->willReturn($accommodations);
|
||||||
|
|
||||||
$manager = $this->createMock(ContingentSnapshotManager::class);
|
$manager = $this->createStub(ContingentSnapshotManager::class);
|
||||||
if ([] !== $results) {
|
if ([] !== $results) {
|
||||||
$manager->method('sync')->willReturnOnConsecutiveCalls(...$results);
|
$manager->method('sync')->willReturnOnConsecutiveCalls(...$results);
|
||||||
}
|
}
|
||||||
|
|
||||||
$command = new BpnSyncContingentsCommand(
|
$command = new BpnSyncContingentsCommand(
|
||||||
$accommodationRepository,
|
$accommodationRepository,
|
||||||
$this->createMock(ContingentSyncStateRepository::class),
|
$this->createStub(ContingentSyncStateRepository::class),
|
||||||
$this->createMock(ContingentDayRepository::class),
|
$this->createStub(ContingentDayRepository::class),
|
||||||
$manager,
|
$manager,
|
||||||
new NullLogger(),
|
new NullLogger(),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -27,12 +27,14 @@ class BpnXmlSyncCommandTest extends TestCase
|
|||||||
private TravelLoader $travelLoader;
|
private TravelLoader $travelLoader;
|
||||||
private TravelDataProvider $travelDataService;
|
private TravelDataProvider $travelDataService;
|
||||||
private TravelSnapshotManager $travelSnapshotService;
|
private TravelSnapshotManager $travelSnapshotService;
|
||||||
private BpnXmlSnapshotRefreshManager $snapshotRefreshManager;
|
private ?BpnXmlSyncCommand $command = null;
|
||||||
private BpnXmlSyncManager $syncManager;
|
|
||||||
private BpnXmlSyncCommand $command;
|
|
||||||
|
|
||||||
protected function tearDown(): void
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
|
if (null === $this->command) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$release = new \ReflectionMethod($this->command, 'release');
|
$release = new \ReflectionMethod($this->command, 'release');
|
||||||
$release->setAccessible(true);
|
$release->setAccessible(true);
|
||||||
$release->invoke($this->command);
|
$release->invoke($this->command);
|
||||||
@@ -40,30 +42,30 @@ class BpnXmlSyncCommandTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->xmlSource = $this->createMock(FilesystemOperator::class);
|
$this->xmlSource = $this->createStub(FilesystemOperator::class);
|
||||||
$this->xmlExport = $this->createMock(FilesystemOperator::class);
|
$this->xmlExport = $this->createStub(FilesystemOperator::class);
|
||||||
$this->cache = $this->createMock(TagAwareCacheInterface::class);
|
$this->cache = $this->createMock(TagAwareCacheInterface::class);
|
||||||
$this->logger = $this->createMock(LoggerInterface::class);
|
$this->logger = $this->createStub(LoggerInterface::class);
|
||||||
$this->travelLoader = $this->createMock(TravelLoader::class);
|
$this->travelLoader = $this->createMock(TravelLoader::class);
|
||||||
$this->travelDataService = $this->createMock(TravelDataProvider::class);
|
$this->travelDataService = $this->createMock(TravelDataProvider::class);
|
||||||
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
||||||
$this->snapshotRefreshManager = new BpnXmlSnapshotRefreshManager(
|
}
|
||||||
$this->travelLoader,
|
|
||||||
$this->travelDataService,
|
|
||||||
$this->travelSnapshotService,
|
|
||||||
$this->logger,
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->syncManager = new BpnXmlSyncManager(
|
private function command(): BpnXmlSyncCommand
|
||||||
$this->xmlSource,
|
{
|
||||||
$this->xmlExport,
|
return $this->command ??= new BpnXmlSyncCommand(
|
||||||
$this->cache,
|
new BpnXmlSyncManager(
|
||||||
$this->logger,
|
$this->xmlSource,
|
||||||
);
|
$this->xmlExport,
|
||||||
|
$this->cache,
|
||||||
$this->command = new BpnXmlSyncCommand(
|
$this->logger,
|
||||||
$this->syncManager,
|
),
|
||||||
$this->snapshotRefreshManager,
|
new BpnXmlSnapshotRefreshManager(
|
||||||
|
$this->travelLoader,
|
||||||
|
$this->travelDataService,
|
||||||
|
$this->travelSnapshotService,
|
||||||
|
$this->logger,
|
||||||
|
),
|
||||||
$this->logger,
|
$this->logger,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -101,7 +103,7 @@ class BpnXmlSyncCommandTest extends TestCase
|
|||||||
->method('invalidateTags')
|
->method('invalidateTags')
|
||||||
->with(['xml-sync']);
|
->with(['xml-sync']);
|
||||||
|
|
||||||
$tester = new CommandTester($this->command);
|
$tester = new CommandTester($this->command());
|
||||||
$tester->execute([]);
|
$tester->execute([]);
|
||||||
|
|
||||||
$this->assertSame(Command::SUCCESS, $tester->getStatusCode());
|
$this->assertSame(Command::SUCCESS, $tester->getStatusCode());
|
||||||
@@ -121,7 +123,7 @@ class BpnXmlSyncCommandTest extends TestCase
|
|||||||
$this->travelSnapshotService->expects($this->never())->method('purgeOrphanedFutureSnapshots');
|
$this->travelSnapshotService->expects($this->never())->method('purgeOrphanedFutureSnapshots');
|
||||||
$this->cache->expects($this->never())->method('invalidateTags');
|
$this->cache->expects($this->never())->method('invalidateTags');
|
||||||
|
|
||||||
$tester = new CommandTester($this->command);
|
$tester = new CommandTester($this->command());
|
||||||
$tester->execute([]);
|
$tester->execute([]);
|
||||||
|
|
||||||
$this->assertSame(Command::SUCCESS, $tester->getStatusCode());
|
$this->assertSame(Command::SUCCESS, $tester->getStatusCode());
|
||||||
@@ -129,6 +131,8 @@ class BpnXmlSyncCommandTest extends TestCase
|
|||||||
|
|
||||||
public function testSnapshotSyncIsSkippedAndWarningLoggedWhenFileMapGenerationFails(): void
|
public function testSnapshotSyncIsSkippedAndWarningLoggedWhenFileMapGenerationFails(): void
|
||||||
{
|
{
|
||||||
|
$this->logger = $this->createMock(LoggerInterface::class);
|
||||||
|
|
||||||
$newerTimestamp = "24.03.2026 12:00:00\nExport\n3 Dateien\n";
|
$newerTimestamp = "24.03.2026 12:00:00\nExport\n3 Dateien\n";
|
||||||
$olderTimestamp = "24.03.2026 10:00:00\nExport\n3 Dateien\n";
|
$olderTimestamp = "24.03.2026 10:00:00\nExport\n3 Dateien\n";
|
||||||
|
|
||||||
@@ -153,7 +157,7 @@ class BpnXmlSyncCommandTest extends TestCase
|
|||||||
$this->travelSnapshotService->expects($this->never())->method('purgeOrphanedFutureSnapshots');
|
$this->travelSnapshotService->expects($this->never())->method('purgeOrphanedFutureSnapshots');
|
||||||
$this->cache->expects($this->once())->method('invalidateTags')->with(['xml-sync']);
|
$this->cache->expects($this->once())->method('invalidateTags')->with(['xml-sync']);
|
||||||
|
|
||||||
$tester = new CommandTester($this->command);
|
$tester = new CommandTester($this->command());
|
||||||
$tester->execute([]);
|
$tester->execute([]);
|
||||||
|
|
||||||
$this->assertSame(Command::SUCCESS, $tester->getStatusCode());
|
$this->assertSame(Command::SUCCESS, $tester->getStatusCode());
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class DbAnonymizeCommandTest extends TestCase
|
|||||||
{
|
{
|
||||||
return new DbAnonymizeCommand(
|
return new DbAnonymizeCommand(
|
||||||
$anonymizer,
|
$anonymizer,
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
$environment,
|
$environment,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class MailjetNewsletterWebhookCommandTest extends TestCase
|
|||||||
$mailjetApiClient,
|
$mailjetApiClient,
|
||||||
'https://my.ep-reisen.de',
|
'https://my.ep-reisen.de',
|
||||||
'secret',
|
'secret',
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,10 @@ class PersonalDataControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testIndexRendersNewsletterSubscribeCtaWhenNotSubscribed(): void
|
public function testIndexRendersNewsletterSubscribeCtaWhenNotSubscribed(): void
|
||||||
{
|
{
|
||||||
$controller = $this->createController();
|
$controller = $this->createController(
|
||||||
|
apiClient: $this->createMock(ApiClient::class),
|
||||||
|
newsletterManager: $this->createMock(NewsletterManager::class),
|
||||||
|
);
|
||||||
$controller->apiClient
|
$controller->apiClient
|
||||||
->expects(self::once())
|
->expects(self::once())
|
||||||
->method('getPersonalData')
|
->method('getPersonalData')
|
||||||
@@ -55,7 +58,10 @@ class PersonalDataControllerTest extends TestCase
|
|||||||
|
|
||||||
public function testIndexStillTracksPendingNewsletterConfirmationWhenSubscribed(): void
|
public function testIndexStillTracksPendingNewsletterConfirmationWhenSubscribed(): void
|
||||||
{
|
{
|
||||||
$controller = $this->createController();
|
$controller = $this->createController(
|
||||||
|
apiClient: $this->createMock(ApiClient::class),
|
||||||
|
newsletterManager: $this->createMock(NewsletterManager::class),
|
||||||
|
);
|
||||||
$controller->apiClient
|
$controller->apiClient
|
||||||
->expects(self::once())
|
->expects(self::once())
|
||||||
->method('getPersonalData')
|
->method('getPersonalData')
|
||||||
@@ -82,7 +88,10 @@ class PersonalDataControllerTest extends TestCase
|
|||||||
|
|
||||||
public function testNewsletterActionReturnsHtmxRedirectAndFlash(): void
|
public function testNewsletterActionReturnsHtmxRedirectAndFlash(): void
|
||||||
{
|
{
|
||||||
$controller = $this->createController();
|
$controller = $this->createController(
|
||||||
|
apiClient: $this->createMock(ApiClient::class),
|
||||||
|
newsletterManager: $this->createMock(NewsletterManager::class),
|
||||||
|
);
|
||||||
$controller->apiClient
|
$controller->apiClient
|
||||||
->expects(self::once())
|
->expects(self::once())
|
||||||
->method('getPersonalData')
|
->method('getPersonalData')
|
||||||
@@ -122,7 +131,10 @@ class PersonalDataControllerTest extends TestCase
|
|||||||
|
|
||||||
public function testNewsletterActionResendsPendingConfirmation(): void
|
public function testNewsletterActionResendsPendingConfirmation(): void
|
||||||
{
|
{
|
||||||
$controller = $this->createController();
|
$controller = $this->createController(
|
||||||
|
apiClient: $this->createMock(ApiClient::class),
|
||||||
|
newsletterManager: $this->createMock(NewsletterManager::class),
|
||||||
|
);
|
||||||
$controller->apiClient
|
$controller->apiClient
|
||||||
->expects(self::once())
|
->expects(self::once())
|
||||||
->method('getPersonalData')
|
->method('getPersonalData')
|
||||||
@@ -173,7 +185,10 @@ class PersonalDataControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testIndexDoesNotSubmitTheFormWhenPersonalDataCouldNotBeLoaded(): void
|
public function testIndexDoesNotSubmitTheFormWhenPersonalDataCouldNotBeLoaded(): void
|
||||||
{
|
{
|
||||||
$controller = $this->createController();
|
$controller = $this->createController(
|
||||||
|
apiClient: $this->createMock(ApiClient::class),
|
||||||
|
form: $this->createMock(FormInterface::class),
|
||||||
|
);
|
||||||
$controller->apiClient
|
$controller->apiClient
|
||||||
->expects(self::once())
|
->expects(self::once())
|
||||||
->method('getPersonalData')
|
->method('getPersonalData')
|
||||||
@@ -194,20 +209,25 @@ class PersonalDataControllerTest extends TestCase
|
|||||||
self::assertSame('account/personal_data.html.twig', $controller->renderedView);
|
self::assertSame('account/personal_data.html.twig', $controller->renderedView);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createController(): TestablePersonalDataController
|
/**
|
||||||
{
|
* Collaborators default to stubs; a test passes its own mock for whatever it sets
|
||||||
|
* expectations on, and reaches it again through the controller's public property.
|
||||||
|
*/
|
||||||
|
private function createController(
|
||||||
|
?ApiClient $apiClient = null,
|
||||||
|
?NewsletterManager $newsletterManager = null,
|
||||||
|
?FormInterface $form = null,
|
||||||
|
): TestablePersonalDataController {
|
||||||
$user = new User('[email protected]');
|
$user = new User('[email protected]');
|
||||||
$user->setPassword('secret');
|
$user->setPassword('secret');
|
||||||
|
|
||||||
$apiClient = $this->createMock(ApiClient::class);
|
|
||||||
|
|
||||||
$crypt = $this->createMock(Crypt::class);
|
$crypt = $this->createMock(Crypt::class);
|
||||||
$crypt
|
$crypt
|
||||||
->method('decrypt')
|
->method('decrypt')
|
||||||
->with('secret')
|
->with('secret')
|
||||||
->willReturn('secret');
|
->willReturn('secret');
|
||||||
|
|
||||||
$form = $this->createMock(FormInterface::class);
|
$form ??= $this->createStub(FormInterface::class);
|
||||||
$form
|
$form
|
||||||
->method('handleRequest')
|
->method('handleRequest')
|
||||||
->willReturnSelf();
|
->willReturnSelf();
|
||||||
@@ -216,13 +236,13 @@ class PersonalDataControllerTest extends TestCase
|
|||||||
->willReturn(false);
|
->willReturn(false);
|
||||||
|
|
||||||
return new TestablePersonalDataController(
|
return new TestablePersonalDataController(
|
||||||
$apiClient,
|
$apiClient ?? $this->createStub(ApiClient::class),
|
||||||
$crypt,
|
$crypt,
|
||||||
$this->createMock(BookingEditDataLoader::class),
|
$this->createStub(BookingEditDataLoader::class),
|
||||||
$this->createMock(ProfileCompletenessChecker::class),
|
$this->createStub(ProfileCompletenessChecker::class),
|
||||||
$this->createMock(EntityManagerInterface::class),
|
$this->createStub(EntityManagerInterface::class),
|
||||||
$this->createMock(NewsletterManager::class),
|
$newsletterManager ?? $this->createStub(NewsletterManager::class),
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
$user,
|
$user,
|
||||||
$form,
|
$form,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use App\Entity\Groups\Accommodation;
|
|||||||
use App\Entity\Groups\AccommodationBooking;
|
use App\Entity\Groups\AccommodationBooking;
|
||||||
use App\Enum\Groups\AccommodationBookingStatus;
|
use App\Enum\Groups\AccommodationBookingStatus;
|
||||||
use App\Service\AccommodationBookingService;
|
use App\Service\AccommodationBookingService;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
@@ -34,9 +35,7 @@ class ChangeAccommodationControllerTest extends TestCase
|
|||||||
self::assertSame('admin/accommodation_booking/modal_change_accommodation.html.twig', $controller->renderedView);
|
self::assertSame('admin/accommodation_booking/modal_change_accommodation.html.twig', $controller->renderedView);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('lockedStatuses')]
|
||||||
* @dataProvider lockedStatuses
|
|
||||||
*/
|
|
||||||
public function testABookingThatHasLeftEntwurfCannotMoveHouse(AccommodationBookingStatus $status): void
|
public function testABookingThatHasLeftEntwurfCannotMoveHouse(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
// The customer may already be looking at the offer under their access link.
|
// The customer may already be looking at the offer under their access link.
|
||||||
@@ -127,7 +126,7 @@ class ChangeAccommodationControllerTest extends TestCase
|
|||||||
|
|
||||||
private function unsubmittedForm(): FormInterface
|
private function unsubmittedForm(): FormInterface
|
||||||
{
|
{
|
||||||
$form = $this->createMock(FormInterface::class);
|
$form = $this->createStub(FormInterface::class);
|
||||||
$form->method('handleRequest')->willReturn($form);
|
$form->method('handleRequest')->willReturn($form);
|
||||||
$form->method('isSubmitted')->willReturn(false);
|
$form->method('isSubmitted')->willReturn(false);
|
||||||
|
|
||||||
@@ -136,7 +135,7 @@ class ChangeAccommodationControllerTest extends TestCase
|
|||||||
|
|
||||||
private function submittedForm(Accommodation $selected): FormInterface
|
private function submittedForm(Accommodation $selected): FormInterface
|
||||||
{
|
{
|
||||||
$field = $this->createMock(FormInterface::class);
|
$field = $this->createStub(FormInterface::class);
|
||||||
$field->method('getData')->willReturn($selected);
|
$field->method('getData')->willReturn($selected);
|
||||||
|
|
||||||
$form = $this->createMock(FormInterface::class);
|
$form = $this->createMock(FormInterface::class);
|
||||||
@@ -154,7 +153,7 @@ class ChangeAccommodationControllerTest extends TestCase
|
|||||||
): TestableChangeAccommodationController {
|
): TestableChangeAccommodationController {
|
||||||
return new TestableChangeAccommodationController(
|
return new TestableChangeAccommodationController(
|
||||||
$bookingService,
|
$bookingService,
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
$form,
|
$form,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use App\Entity\Groups\AccommodationBooking;
|
|||||||
use App\Enum\Groups\AccommodationBookingStatus;
|
use App\Enum\Groups\AccommodationBookingStatus;
|
||||||
use App\Message\CreateClickUpBookingTaskMessage;
|
use App\Message\CreateClickUpBookingTaskMessage;
|
||||||
use App\Service\AccommodationBookingService;
|
use App\Service\AccommodationBookingService;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
@@ -29,7 +30,7 @@ class ConfirmControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('confirmBooking');
|
$bookingService->expects(self::never())->method('confirmBooking');
|
||||||
|
|
||||||
$controller = new TestableConfirmController($bookingService, $this->neverDispatchingBus(), $this->createMock(LoggerInterface::class));
|
$controller = new TestableConfirmController($bookingService, $this->neverDispatchingBus(), $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($this->receivedBooking(), Request::create('/admin/accommodation-booking/1/confirm'));
|
$response = $controller->index($this->receivedBooking(), Request::create('/admin/accommodation-booking/1/confirm'));
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ class ConfirmControllerTest extends TestCase
|
|||||||
->with(self::isInstanceOf(CreateClickUpBookingTaskMessage::class))
|
->with(self::isInstanceOf(CreateClickUpBookingTaskMessage::class))
|
||||||
->willReturnCallback(static fn (object $message): Envelope => new Envelope($message));
|
->willReturnCallback(static fn (object $message): Envelope => new Envelope($message));
|
||||||
|
|
||||||
$controller = new TestableConfirmController($bookingService, $messageBus, $this->createMock(LoggerInterface::class));
|
$controller = new TestableConfirmController($bookingService, $messageBus, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/confirm', 'POST'));
|
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/confirm', 'POST'));
|
||||||
|
|
||||||
@@ -63,16 +64,14 @@ class ConfirmControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('confirmBooking');
|
$bookingService->expects(self::never())->method('confirmBooking');
|
||||||
|
|
||||||
$controller = new TestableConfirmController($bookingService, $this->neverDispatchingBus(), $this->createMock(LoggerInterface::class), tokenValid: false);
|
$controller = new TestableConfirmController($bookingService, $this->neverDispatchingBus(), $this->createStub(LoggerInterface::class), tokenValid: false);
|
||||||
|
|
||||||
$this->expectException(AccessDeniedException::class);
|
$this->expectException(AccessDeniedException::class);
|
||||||
|
|
||||||
$controller->index($this->receivedBooking(), Request::create('/admin/accommodation-booking/1/confirm', 'POST'));
|
$controller->index($this->receivedBooking(), Request::create('/admin/accommodation-booking/1/confirm', 'POST'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('nonReceivedStatuses')]
|
||||||
* @dataProvider nonReceivedStatuses
|
|
||||||
*/
|
|
||||||
public function testABookingThatIsNotAwaitingValidationCannotBeConfirmed(AccommodationBookingStatus $status): void
|
public function testABookingThatIsNotAwaitingValidationCannotBeConfirmed(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
$booking = $this->receivedBooking();
|
$booking = $this->receivedBooking();
|
||||||
@@ -81,7 +80,7 @@ class ConfirmControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('confirmBooking');
|
$bookingService->expects(self::never())->method('confirmBooking');
|
||||||
|
|
||||||
$controller = new TestableConfirmController($bookingService, $this->neverDispatchingBus(), $this->createMock(LoggerInterface::class));
|
$controller = new TestableConfirmController($bookingService, $this->neverDispatchingBus(), $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/confirm', 'POST'));
|
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/confirm', 'POST'));
|
||||||
|
|
||||||
@@ -108,7 +107,7 @@ class ConfirmControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('confirmBooking');
|
$bookingService->expects(self::never())->method('confirmBooking');
|
||||||
|
|
||||||
$controller = new TestableConfirmController($bookingService, $this->neverDispatchingBus(), $this->createMock(LoggerInterface::class));
|
$controller = new TestableConfirmController($bookingService, $this->neverDispatchingBus(), $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/confirm', 'POST'));
|
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/confirm', 'POST'));
|
||||||
|
|
||||||
|
|||||||
@@ -34,14 +34,14 @@ class CreateControllerTest extends TestCase
|
|||||||
|
|
||||||
private function buildController(?UserInterface $user): TestableCreateController
|
private function buildController(?UserInterface $user): TestableCreateController
|
||||||
{
|
{
|
||||||
$form = $this->createMock(FormInterface::class);
|
$form = $this->createStub(FormInterface::class);
|
||||||
$form->method('handleRequest')->willReturn($form);
|
$form->method('handleRequest')->willReturn($form);
|
||||||
$form->method('isSubmitted')->willReturn(false);
|
$form->method('isSubmitted')->willReturn(false);
|
||||||
|
|
||||||
return new TestableCreateController(
|
return new TestableCreateController(
|
||||||
$this->createMock(EntityManagerInterface::class),
|
$this->createStub(EntityManagerInterface::class),
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
$this->createMock(AccommodationBookingService::class),
|
$this->createStub(AccommodationBookingService::class),
|
||||||
$form,
|
$form,
|
||||||
$user,
|
$user,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use App\Entity\Groups\Accommodation;
|
|||||||
use App\Entity\Groups\AccommodationBooking;
|
use App\Entity\Groups\AccommodationBooking;
|
||||||
use App\Enum\Groups\AccommodationBookingStatus;
|
use App\Enum\Groups\AccommodationBookingStatus;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@@ -53,9 +54,7 @@ class DeleteControllerTest extends TestCase
|
|||||||
self::assertSame('success', $controller->flashes[0]['type']);
|
self::assertSame('success', $controller->flashes[0]['type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('undeletableStatuses')]
|
||||||
* @dataProvider undeletableStatuses
|
|
||||||
*/
|
|
||||||
public function testOnlyADraftCanBeDeleted(AccommodationBookingStatus $status): void
|
public function testOnlyADraftCanBeDeleted(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
// Anything past Entwurf has been in contact with the customer and is closed by an
|
// Anything past Entwurf has been in contact with the customer and is closed by an
|
||||||
@@ -126,7 +125,7 @@ class DeleteControllerTest extends TestCase
|
|||||||
): TestableBookingDeleteController {
|
): TestableBookingDeleteController {
|
||||||
return new TestableBookingDeleteController(
|
return new TestableBookingDeleteController(
|
||||||
$entityManager,
|
$entityManager,
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
$tokenValid,
|
$tokenValid,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Controller\Admin\AccommodationBooking\DiscardController;
|
|||||||
use App\Entity\Groups\AccommodationBooking;
|
use App\Entity\Groups\AccommodationBooking;
|
||||||
use App\Enum\Groups\AccommodationBookingStatus;
|
use App\Enum\Groups\AccommodationBookingStatus;
|
||||||
use App\Service\AccommodationBookingService;
|
use App\Service\AccommodationBookingService;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@@ -25,7 +26,7 @@ class DiscardControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('discardBooking');
|
$bookingService->expects(self::never())->method('discardBooking');
|
||||||
|
|
||||||
$controller = new TestableDiscardController($bookingService, $this->createMock(LoggerInterface::class));
|
$controller = new TestableDiscardController($bookingService, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($this->openBooking(), Request::create('/admin/accommodation-booking/1/discard'));
|
$response = $controller->index($this->openBooking(), Request::create('/admin/accommodation-booking/1/discard'));
|
||||||
|
|
||||||
@@ -33,9 +34,7 @@ class DiscardControllerTest extends TestCase
|
|||||||
self::assertSame('admin/accommodation_booking/modal_discard.html.twig', $controller->renderedView);
|
self::assertSame('admin/accommodation_booking/modal_discard.html.twig', $controller->renderedView);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('discardableStatuses')]
|
||||||
* @dataProvider discardableStatuses
|
|
||||||
*/
|
|
||||||
public function testPostDiscardsTheBookingAndRedirectsTheBrowser(AccommodationBookingStatus $status): void
|
public function testPostDiscardsTheBookingAndRedirectsTheBrowser(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
$booking = $this->openBooking();
|
$booking = $this->openBooking();
|
||||||
@@ -44,7 +43,7 @@ class DiscardControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::once())->method('discardBooking')->with($booking);
|
$bookingService->expects(self::once())->method('discardBooking')->with($booking);
|
||||||
|
|
||||||
$controller = new TestableDiscardController($bookingService, $this->createMock(LoggerInterface::class));
|
$controller = new TestableDiscardController($bookingService, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/discard', 'POST'));
|
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/discard', 'POST'));
|
||||||
|
|
||||||
@@ -62,9 +61,7 @@ class DiscardControllerTest extends TestCase
|
|||||||
yield 'received' => [AccommodationBookingStatus::Received];
|
yield 'received' => [AccommodationBookingStatus::Received];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('closedStatuses')]
|
||||||
* @dataProvider closedStatuses
|
|
||||||
*/
|
|
||||||
public function testAClosedBookingCannotBeDiscarded(AccommodationBookingStatus $status): void
|
public function testAClosedBookingCannotBeDiscarded(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
// A released confirmation is binding, and an Absage is already the end of the line.
|
// A released confirmation is binding, and an Absage is already the end of the line.
|
||||||
@@ -74,7 +71,7 @@ class DiscardControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('discardBooking');
|
$bookingService->expects(self::never())->method('discardBooking');
|
||||||
|
|
||||||
$controller = new TestableDiscardController($bookingService, $this->createMock(LoggerInterface::class));
|
$controller = new TestableDiscardController($bookingService, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/discard', 'POST'));
|
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/discard', 'POST'));
|
||||||
|
|
||||||
@@ -95,7 +92,7 @@ class DiscardControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('discardBooking');
|
$bookingService->expects(self::never())->method('discardBooking');
|
||||||
|
|
||||||
$controller = new TestableDiscardController($bookingService, $this->createMock(LoggerInterface::class), tokenValid: false);
|
$controller = new TestableDiscardController($bookingService, $this->createStub(LoggerInterface::class), tokenValid: false);
|
||||||
|
|
||||||
$this->expectException(AccessDeniedException::class);
|
$this->expectException(AccessDeniedException::class);
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use App\Repository\Groups\BoardServiceRepository;
|
|||||||
use App\Repository\UserRepository;
|
use App\Repository\UserRepository;
|
||||||
use App\Service\AccommodationBookingService;
|
use App\Service\AccommodationBookingService;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
@@ -26,9 +27,7 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
*/
|
*/
|
||||||
class EditControllerTest extends TestCase
|
class EditControllerTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
#[DataProvider('everyStatus')]
|
||||||
* @dataProvider everyStatus
|
|
||||||
*/
|
|
||||||
public function testSavingNeverNotifiesTheCustomer(AccommodationBookingStatus $status): void
|
public function testSavingNeverNotifiesTheCustomer(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
// Sending used to be a side effect of saving a status change, which is how an inquiry
|
// Sending used to be a side effect of saving a status change, which is how an inquiry
|
||||||
@@ -59,7 +58,7 @@ class EditControllerTest extends TestCase
|
|||||||
|
|
||||||
private function submitEdit(AccommodationBooking $booking, AccommodationBookingService $bookingService): void
|
private function submitEdit(AccommodationBooking $booking, AccommodationBookingService $bookingService): void
|
||||||
{
|
{
|
||||||
$form = $this->createMock(FormInterface::class);
|
$form = $this->createStub(FormInterface::class);
|
||||||
$form->method('handleRequest')->willReturn($form);
|
$form->method('handleRequest')->willReturn($form);
|
||||||
$form->method('isSubmitted')->willReturn(true);
|
$form->method('isSubmitted')->willReturn(true);
|
||||||
$form->method('isValid')->willReturn(true);
|
$form->method('isValid')->willReturn(true);
|
||||||
@@ -70,10 +69,10 @@ class EditControllerTest extends TestCase
|
|||||||
|
|
||||||
$controller = new TestableEditController(
|
$controller = new TestableEditController(
|
||||||
$entityManager,
|
$entityManager,
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
$this->createMock(BoardServiceRepository::class),
|
$this->createStub(BoardServiceRepository::class),
|
||||||
$this->createMock(AdditionalServiceRepository::class),
|
$this->createStub(AdditionalServiceRepository::class),
|
||||||
$this->createMock(UserRepository::class),
|
$this->createStub(UserRepository::class),
|
||||||
$bookingService,
|
$bookingService,
|
||||||
$form,
|
$form,
|
||||||
);
|
);
|
||||||
@@ -97,7 +96,7 @@ class EditControllerTest extends TestCase
|
|||||||
public function testAdminGetsTheGroupsStaffAsBetreuerChoices(): void
|
public function testAdminGetsTheGroupsStaffAsBetreuerChoices(): void
|
||||||
{
|
{
|
||||||
$staff = [new User('[email protected]')];
|
$staff = [new User('[email protected]')];
|
||||||
$userRepo = $this->createMock(UserRepository::class);
|
$userRepo = $this->createStub(UserRepository::class);
|
||||||
$userRepo->method('findGroupsStaff')->willReturn($staff);
|
$userRepo->method('findGroupsStaff')->willReturn($staff);
|
||||||
|
|
||||||
$controller = $this->buildController($userRepo, granted: true);
|
$controller = $this->buildController($userRepo, granted: true);
|
||||||
@@ -111,7 +110,7 @@ class EditControllerTest extends TestCase
|
|||||||
$formerManager = new User('[email protected]');
|
$formerManager = new User('[email protected]');
|
||||||
$staff = [new User('[email protected]')];
|
$staff = [new User('[email protected]')];
|
||||||
|
|
||||||
$userRepo = $this->createMock(UserRepository::class);
|
$userRepo = $this->createStub(UserRepository::class);
|
||||||
$userRepo->method('findGroupsStaff')->willReturn($staff);
|
$userRepo->method('findGroupsStaff')->willReturn($staff);
|
||||||
|
|
||||||
$booking = new AccommodationBooking();
|
$booking = new AccommodationBooking();
|
||||||
@@ -127,17 +126,17 @@ class EditControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
// An unsubmitted form: index() falls through to render() and only the options
|
// An unsubmitted form: index() falls through to render() and only the options
|
||||||
// handed to createForm() are of interest here.
|
// handed to createForm() are of interest here.
|
||||||
$form = $this->createMock(FormInterface::class);
|
$form = $this->createStub(FormInterface::class);
|
||||||
$form->method('handleRequest')->willReturn($form);
|
$form->method('handleRequest')->willReturn($form);
|
||||||
$form->method('isSubmitted')->willReturn(false);
|
$form->method('isSubmitted')->willReturn(false);
|
||||||
|
|
||||||
return new TestableEditController(
|
return new TestableEditController(
|
||||||
$this->createMock(EntityManagerInterface::class),
|
$this->createStub(EntityManagerInterface::class),
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
$this->createMock(BoardServiceRepository::class),
|
$this->createStub(BoardServiceRepository::class),
|
||||||
$this->createMock(AdditionalServiceRepository::class),
|
$this->createStub(AdditionalServiceRepository::class),
|
||||||
$userRepo,
|
$userRepo,
|
||||||
$this->createMock(AccommodationBookingService::class),
|
$this->createStub(AccommodationBookingService::class),
|
||||||
$form,
|
$form,
|
||||||
$granted,
|
$granted,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Controller\Admin\AccommodationBooking\GenerateAccessLinkController;
|
|||||||
use App\Entity\Groups\AccommodationBooking;
|
use App\Entity\Groups\AccommodationBooking;
|
||||||
use App\Enum\Groups\AccommodationBookingStatus;
|
use App\Enum\Groups\AccommodationBookingStatus;
|
||||||
use App\Service\AccommodationBookingService;
|
use App\Service\AccommodationBookingService;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@@ -25,7 +26,7 @@ class GenerateAccessLinkControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('generateAccessLink');
|
$bookingService->expects(self::never())->method('generateAccessLink');
|
||||||
|
|
||||||
$controller = new TestableGenerateAccessLinkController($bookingService, $this->createMock(LoggerInterface::class));
|
$controller = new TestableGenerateAccessLinkController($bookingService, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($this->requestedBooking(), Request::create('/admin/accommodation-booking/1/generate-access-link'));
|
$response = $controller->index($this->requestedBooking(), Request::create('/admin/accommodation-booking/1/generate-access-link'));
|
||||||
|
|
||||||
@@ -33,9 +34,7 @@ class GenerateAccessLinkControllerTest extends TestCase
|
|||||||
self::assertSame('admin/accommodation_booking/modal_generate_access_link.html.twig', $controller->renderedView);
|
self::assertSame('admin/accommodation_booking/modal_generate_access_link.html.twig', $controller->renderedView);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('statusesAwaitingAnOffer')]
|
||||||
* @dataProvider statusesAwaitingAnOffer
|
|
||||||
*/
|
|
||||||
public function testPostGeneratesTheLinkAndRedirectsTheBrowser(AccommodationBookingStatus $status): void
|
public function testPostGeneratesTheLinkAndRedirectsTheBrowser(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
$booking = $this->requestedBooking();
|
$booking = $this->requestedBooking();
|
||||||
@@ -44,7 +43,7 @@ class GenerateAccessLinkControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::once())->method('generateAccessLink')->with($booking);
|
$bookingService->expects(self::once())->method('generateAccessLink')->with($booking);
|
||||||
|
|
||||||
$controller = new TestableGenerateAccessLinkController($bookingService, $this->createMock(LoggerInterface::class));
|
$controller = new TestableGenerateAccessLinkController($bookingService, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/generate-access-link', 'POST'));
|
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/generate-access-link', 'POST'));
|
||||||
|
|
||||||
@@ -60,9 +59,7 @@ class GenerateAccessLinkControllerTest extends TestCase
|
|||||||
yield 'requested' => [AccommodationBookingStatus::Requested];
|
yield 'requested' => [AccommodationBookingStatus::Requested];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('statusesPastTheOffer')]
|
||||||
* @dataProvider statusesPastTheOffer
|
|
||||||
*/
|
|
||||||
public function testABookingThatIsNotAwaitingAnOfferGetsNoLink(AccommodationBookingStatus $status): void
|
public function testABookingThatIsNotAwaitingAnOfferGetsNoLink(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
$booking = $this->requestedBooking();
|
$booking = $this->requestedBooking();
|
||||||
@@ -71,7 +68,7 @@ class GenerateAccessLinkControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('generateAccessLink');
|
$bookingService->expects(self::never())->method('generateAccessLink');
|
||||||
|
|
||||||
$controller = new TestableGenerateAccessLinkController($bookingService, $this->createMock(LoggerInterface::class));
|
$controller = new TestableGenerateAccessLinkController($bookingService, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/generate-access-link', 'POST'));
|
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/generate-access-link', 'POST'));
|
||||||
|
|
||||||
@@ -94,7 +91,7 @@ class GenerateAccessLinkControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('generateAccessLink');
|
$bookingService->expects(self::never())->method('generateAccessLink');
|
||||||
|
|
||||||
$controller = new TestableGenerateAccessLinkController($bookingService, $this->createMock(LoggerInterface::class), tokenValid: false);
|
$controller = new TestableGenerateAccessLinkController($bookingService, $this->createStub(LoggerInterface::class), tokenValid: false);
|
||||||
|
|
||||||
$this->expectException(AccessDeniedException::class);
|
$this->expectException(AccessDeniedException::class);
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Controller\Admin\AccommodationBooking\PdfController;
|
|||||||
use App\Entity\Groups\AccommodationBooking;
|
use App\Entity\Groups\AccommodationBooking;
|
||||||
use App\Enum\Groups\AccommodationBookingStatus;
|
use App\Enum\Groups\AccommodationBookingStatus;
|
||||||
use App\Service\AccommodationBookingPdfGenerator;
|
use App\Service\AccommodationBookingPdfGenerator;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
@@ -32,9 +33,7 @@ class PdfControllerTest extends TestCase
|
|||||||
self::assertSame(Response::HTTP_OK, $response->getStatusCode());
|
self::assertSame(Response::HTTP_OK, $response->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('nonConfirmedStatuses')]
|
||||||
* @dataProvider nonConfirmedStatuses
|
|
||||||
*/
|
|
||||||
public function testABookingThatIsNotConfirmedCannotBeDownloaded(AccommodationBookingStatus $status): void
|
public function testABookingThatIsNotConfirmedCannotBeDownloaded(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
$generator = $this->createMock(AccommodationBookingPdfGenerator::class);
|
$generator = $this->createMock(AccommodationBookingPdfGenerator::class);
|
||||||
@@ -61,7 +60,7 @@ class PdfControllerTest extends TestCase
|
|||||||
|
|
||||||
public function testAFailingGeneratorRedirectsWithAFlash(): void
|
public function testAFailingGeneratorRedirectsWithAFlash(): void
|
||||||
{
|
{
|
||||||
$generator = $this->createMock(AccommodationBookingPdfGenerator::class);
|
$generator = $this->createStub(AccommodationBookingPdfGenerator::class);
|
||||||
$generator->method('createDownloadResponse')->willThrowException(new \RuntimeException('keine Preise'));
|
$generator->method('createDownloadResponse')->willThrowException(new \RuntimeException('keine Preise'));
|
||||||
|
|
||||||
$controller = new TestablePdfController($generator);
|
$controller = new TestablePdfController($generator);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Controller\Admin\AccommodationBooking\SendAccessLinkController;
|
|||||||
use App\Entity\Groups\AccommodationBooking;
|
use App\Entity\Groups\AccommodationBooking;
|
||||||
use App\Enum\Groups\AccommodationBookingStatus;
|
use App\Enum\Groups\AccommodationBookingStatus;
|
||||||
use App\Service\AccommodationBookingService;
|
use App\Service\AccommodationBookingService;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@@ -25,7 +26,7 @@ class SendAccessLinkControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('sendAccessLink');
|
$bookingService->expects(self::never())->method('sendAccessLink');
|
||||||
|
|
||||||
$controller = new TestableSendAccessLinkController($bookingService, $this->createMock(LoggerInterface::class));
|
$controller = new TestableSendAccessLinkController($bookingService, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($this->openBooking(), Request::create('/admin/accommodation-booking/1/send-access-link'));
|
$response = $controller->index($this->openBooking(), Request::create('/admin/accommodation-booking/1/send-access-link'));
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ class SendAccessLinkControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::once())->method('sendAccessLink')->with($booking);
|
$bookingService->expects(self::once())->method('sendAccessLink')->with($booking);
|
||||||
|
|
||||||
$controller = new TestableSendAccessLinkController($bookingService, $this->createMock(LoggerInterface::class));
|
$controller = new TestableSendAccessLinkController($bookingService, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-access-link', 'POST'));
|
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-access-link', 'POST'));
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ class SendAccessLinkControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('sendAccessLink');
|
$bookingService->expects(self::never())->method('sendAccessLink');
|
||||||
|
|
||||||
$controller = new TestableSendAccessLinkController($bookingService, $this->createMock(LoggerInterface::class));
|
$controller = new TestableSendAccessLinkController($bookingService, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-access-link', 'POST'));
|
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-access-link', 'POST'));
|
||||||
|
|
||||||
@@ -65,9 +66,8 @@ class SendAccessLinkControllerTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* Drafts are held back even when a link is on the record — a booking pushed back into
|
* Drafts are held back even when a link is on the record — a booking pushed back into
|
||||||
* Entwurf keeps its accessLinkIssuedAt, and it must not be handed out again.
|
* Entwurf keeps its accessLinkIssuedAt, and it must not be handed out again.
|
||||||
*
|
|
||||||
* @dataProvider requestMethods
|
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('requestMethods')]
|
||||||
public function testADraftLinkIsNeverSentEvenIfOneWasIssuedEarlier(string $method): void
|
public function testADraftLinkIsNeverSentEvenIfOneWasIssuedEarlier(string $method): void
|
||||||
{
|
{
|
||||||
$booking = $this->openBooking();
|
$booking = $this->openBooking();
|
||||||
@@ -76,7 +76,7 @@ class SendAccessLinkControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('sendAccessLink');
|
$bookingService->expects(self::never())->method('sendAccessLink');
|
||||||
|
|
||||||
$controller = new TestableSendAccessLinkController($bookingService, $this->createMock(LoggerInterface::class));
|
$controller = new TestableSendAccessLinkController($bookingService, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-access-link', $method));
|
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-access-link', $method));
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ class SendAccessLinkControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('sendAccessLink');
|
$bookingService->expects(self::never())->method('sendAccessLink');
|
||||||
|
|
||||||
$controller = new TestableSendAccessLinkController($bookingService, $this->createMock(LoggerInterface::class), tokenValid: false);
|
$controller = new TestableSendAccessLinkController($bookingService, $this->createStub(LoggerInterface::class), tokenValid: false);
|
||||||
|
|
||||||
$this->expectException(AccessDeniedException::class);
|
$this->expectException(AccessDeniedException::class);
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ class SendAccessLinkControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('sendAccessLink');
|
$bookingService->expects(self::never())->method('sendAccessLink');
|
||||||
|
|
||||||
$controller = new TestableSendAccessLinkController($bookingService, $this->createMock(LoggerInterface::class));
|
$controller = new TestableSendAccessLinkController($bookingService, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-access-link', 'POST'));
|
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-access-link', 'POST'));
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Controller\Admin\AccommodationBooking\SendOfferController;
|
|||||||
use App\Entity\Groups\AccommodationBooking;
|
use App\Entity\Groups\AccommodationBooking;
|
||||||
use App\Enum\Groups\AccommodationBookingStatus;
|
use App\Enum\Groups\AccommodationBookingStatus;
|
||||||
use App\Service\AccommodationBookingService;
|
use App\Service\AccommodationBookingService;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@@ -25,7 +26,7 @@ class SendOfferControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('sendOffer');
|
$bookingService->expects(self::never())->method('sendOffer');
|
||||||
|
|
||||||
$controller = new TestableSendOfferController($bookingService, $this->createMock(LoggerInterface::class));
|
$controller = new TestableSendOfferController($bookingService, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($this->requestedBooking(), Request::create('/admin/accommodation-booking/1/send-offer'));
|
$response = $controller->index($this->requestedBooking(), Request::create('/admin/accommodation-booking/1/send-offer'));
|
||||||
|
|
||||||
@@ -33,9 +34,7 @@ class SendOfferControllerTest extends TestCase
|
|||||||
self::assertSame('admin/accommodation_booking/modal_send_offer.html.twig', $controller->renderedView);
|
self::assertSame('admin/accommodation_booking/modal_send_offer.html.twig', $controller->renderedView);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('statusesAwaitingAnOffer')]
|
||||||
* @dataProvider statusesAwaitingAnOffer
|
|
||||||
*/
|
|
||||||
public function testPostSendsTheOfferAndRedirectsTheBrowser(AccommodationBookingStatus $status): void
|
public function testPostSendsTheOfferAndRedirectsTheBrowser(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
$booking = $this->requestedBooking();
|
$booking = $this->requestedBooking();
|
||||||
@@ -44,7 +43,7 @@ class SendOfferControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::once())->method('sendOffer')->with($booking);
|
$bookingService->expects(self::once())->method('sendOffer')->with($booking);
|
||||||
|
|
||||||
$controller = new TestableSendOfferController($bookingService, $this->createMock(LoggerInterface::class));
|
$controller = new TestableSendOfferController($bookingService, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-offer', 'POST'));
|
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-offer', 'POST'));
|
||||||
|
|
||||||
@@ -61,9 +60,7 @@ class SendOfferControllerTest extends TestCase
|
|||||||
yield 'requested' => [AccommodationBookingStatus::Requested];
|
yield 'requested' => [AccommodationBookingStatus::Requested];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('statusesPastTheOffer')]
|
||||||
* @dataProvider statusesPastTheOffer
|
|
||||||
*/
|
|
||||||
public function testABookingThatIsNotAwaitingAnOfferGetsNone(AccommodationBookingStatus $status): void
|
public function testABookingThatIsNotAwaitingAnOfferGetsNone(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
$booking = $this->requestedBooking();
|
$booking = $this->requestedBooking();
|
||||||
@@ -72,7 +69,7 @@ class SendOfferControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('sendOffer');
|
$bookingService->expects(self::never())->method('sendOffer');
|
||||||
|
|
||||||
$controller = new TestableSendOfferController($bookingService, $this->createMock(LoggerInterface::class));
|
$controller = new TestableSendOfferController($bookingService, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-offer', 'POST'));
|
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-offer', 'POST'));
|
||||||
|
|
||||||
@@ -95,7 +92,7 @@ class SendOfferControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('sendOffer');
|
$bookingService->expects(self::never())->method('sendOffer');
|
||||||
|
|
||||||
$controller = new TestableSendOfferController($bookingService, $this->createMock(LoggerInterface::class), tokenValid: false);
|
$controller = new TestableSendOfferController($bookingService, $this->createStub(LoggerInterface::class), tokenValid: false);
|
||||||
|
|
||||||
$this->expectException(AccessDeniedException::class);
|
$this->expectException(AccessDeniedException::class);
|
||||||
|
|
||||||
@@ -113,7 +110,7 @@ class SendOfferControllerTest extends TestCase
|
|||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('sendOffer');
|
$bookingService->expects(self::never())->method('sendOffer');
|
||||||
|
|
||||||
$controller = new TestableSendOfferController($bookingService, $this->createMock(LoggerInterface::class));
|
$controller = new TestableSendOfferController($bookingService, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-offer', 'POST'));
|
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/send-offer', 'POST'));
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class ApproveRoleControllerTest extends TestCase
|
|||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
$entityManager->expects(self::never())->method('flush');
|
$entityManager->expects(self::never())->method('flush');
|
||||||
|
|
||||||
$controller = new TestableApproveRoleController($entityManager, $this->createMock(LoggerInterface::class));
|
$controller = new TestableApproveRoleController($entityManager, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($user, Role::GROUPS_ADMIN, Request::create('/admin/user/1/approve/ROLE_GROUPS_ADMIN'));
|
$response = $controller->index($user, Role::GROUPS_ADMIN, Request::create('/admin/user/1/approve/ROLE_GROUPS_ADMIN'));
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ class ApproveRoleControllerTest extends TestCase
|
|||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
$entityManager->expects(self::once())->method('flush');
|
$entityManager->expects(self::once())->method('flush');
|
||||||
|
|
||||||
$controller = new TestableApproveRoleController($entityManager, $this->createMock(LoggerInterface::class));
|
$controller = new TestableApproveRoleController($entityManager, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($user, Role::GROUPS_ADMIN, Request::create('/admin/user/1/approve/ROLE_GROUPS_ADMIN', 'POST'));
|
$response = $controller->index($user, Role::GROUPS_ADMIN, Request::create('/admin/user/1/approve/ROLE_GROUPS_ADMIN', 'POST'));
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ class ApproveRoleControllerTest extends TestCase
|
|||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
$entityManager->expects(self::never())->method('flush');
|
$entityManager->expects(self::never())->method('flush');
|
||||||
|
|
||||||
$controller = new TestableApproveRoleController($entityManager, $this->createMock(LoggerInterface::class));
|
$controller = new TestableApproveRoleController($entityManager, $this->createStub(LoggerInterface::class));
|
||||||
|
|
||||||
$this->expectException(NotFoundHttpException::class);
|
$this->expectException(NotFoundHttpException::class);
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ class ApproveRoleControllerTest extends TestCase
|
|||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
$entityManager->expects(self::never())->method('flush');
|
$entityManager->expects(self::never())->method('flush');
|
||||||
|
|
||||||
$controller = new TestableApproveRoleController($entityManager, $this->createMock(LoggerInterface::class), currentUser: $user);
|
$controller = new TestableApproveRoleController($entityManager, $this->createStub(LoggerInterface::class), currentUser: $user);
|
||||||
|
|
||||||
$this->expectException(AccessDeniedException::class);
|
$this->expectException(AccessDeniedException::class);
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ class ApproveRoleControllerTest extends TestCase
|
|||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
$entityManager->expects(self::once())->method('flush');
|
$entityManager->expects(self::once())->method('flush');
|
||||||
|
|
||||||
$controller = new TestableApproveRoleController($entityManager, $this->createMock(LoggerInterface::class), currentUser: $user);
|
$controller = new TestableApproveRoleController($entityManager, $this->createStub(LoggerInterface::class), currentUser: $user);
|
||||||
|
|
||||||
// Only ROLE_ADMIN needs a second pair of eyes — an approver already holds it, so the
|
// Only ROLE_ADMIN needs a second pair of eyes — an approver already holds it, so the
|
||||||
// rest grant less than they could grant themselves anyway.
|
// rest grant less than they could grant themselves anyway.
|
||||||
@@ -104,7 +104,7 @@ class ApproveRoleControllerTest extends TestCase
|
|||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
$entityManager->expects(self::never())->method('flush');
|
$entityManager->expects(self::never())->method('flush');
|
||||||
|
|
||||||
$controller = new TestableApproveRoleController($entityManager, $this->createMock(LoggerInterface::class), tokenValid: false);
|
$controller = new TestableApproveRoleController($entityManager, $this->createStub(LoggerInterface::class), tokenValid: false);
|
||||||
|
|
||||||
$this->expectException(AccessDeniedException::class);
|
$this->expectException(AccessDeniedException::class);
|
||||||
|
|
||||||
@@ -119,8 +119,8 @@ class ApproveRoleControllerTest extends TestCase
|
|||||||
$tokenStorage->setToken(new PostAuthenticationToken($user, 'main', $user->getRoles()));
|
$tokenStorage->setToken(new PostAuthenticationToken($user, 'main', $user->getRoles()));
|
||||||
|
|
||||||
$controller = new TestableApproveRoleController(
|
$controller = new TestableApproveRoleController(
|
||||||
$this->createMock(EntityManagerInterface::class),
|
$this->createStub(EntityManagerInterface::class),
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
currentUser: $user,
|
currentUser: $user,
|
||||||
tokenStorage: $tokenStorage,
|
tokenStorage: $tokenStorage,
|
||||||
);
|
);
|
||||||
@@ -142,8 +142,8 @@ class ApproveRoleControllerTest extends TestCase
|
|||||||
$tokenStorage->setToken($originalToken = new PostAuthenticationToken($admin, 'main', $admin->getRoles()));
|
$tokenStorage->setToken($originalToken = new PostAuthenticationToken($admin, 'main', $admin->getRoles()));
|
||||||
|
|
||||||
$controller = new TestableApproveRoleController(
|
$controller = new TestableApproveRoleController(
|
||||||
$this->createMock(EntityManagerInterface::class),
|
$this->createStub(EntityManagerInterface::class),
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
currentUser: $admin,
|
currentUser: $admin,
|
||||||
tokenStorage: $tokenStorage,
|
tokenStorage: $tokenStorage,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -157,10 +157,10 @@ class AccommodationBookingControllerTest extends TestCase
|
|||||||
->with(['uuid' => $booking->getUuid()])
|
->with(['uuid' => $booking->getUuid()])
|
||||||
->willReturn($booking);
|
->willReturn($booking);
|
||||||
|
|
||||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
$breakdownCalculator = $this->createStub(AccommodationBookingBreakdownCalculator::class);
|
||||||
$breakdownCalculator->method('compute')->willReturn(null);
|
$breakdownCalculator->method('compute')->willReturn(null);
|
||||||
|
|
||||||
$controller = new AccommodationBookingController($bookingRepository, $breakdownCalculator, $this->serializer(), $this->createMock(AccommodationBookingService::class));
|
$controller = new AccommodationBookingController($bookingRepository, $breakdownCalculator, $this->serializer(), $this->createStub(AccommodationBookingService::class));
|
||||||
|
|
||||||
$response = $controller->single($booking->getUuid());
|
$response = $controller->single($booking->getUuid());
|
||||||
$payload = json_decode((string) $response->getContent(), true, 512, JSON_THROW_ON_ERROR);
|
$payload = json_decode((string) $response->getContent(), true, 512, JSON_THROW_ON_ERROR);
|
||||||
@@ -183,7 +183,7 @@ class AccommodationBookingControllerTest extends TestCase
|
|||||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
||||||
$breakdownCalculator->expects(self::never())->method('compute');
|
$breakdownCalculator->expects(self::never())->method('compute');
|
||||||
|
|
||||||
$controller = new AccommodationBookingController($bookingRepository, $breakdownCalculator, $this->serializer(), $this->createMock(AccommodationBookingService::class));
|
$controller = new AccommodationBookingController($bookingRepository, $breakdownCalculator, $this->serializer(), $this->createStub(AccommodationBookingService::class));
|
||||||
|
|
||||||
$response = $controller->single('unknown-uuid');
|
$response = $controller->single('unknown-uuid');
|
||||||
$payload = json_decode((string) $response->getContent(), true, 512, JSON_THROW_ON_ERROR);
|
$payload = json_decode((string) $response->getContent(), true, 512, JSON_THROW_ON_ERROR);
|
||||||
@@ -210,7 +210,7 @@ class AccommodationBookingControllerTest extends TestCase
|
|||||||
->with(['uuid' => $booking->getUuid()])
|
->with(['uuid' => $booking->getUuid()])
|
||||||
->willReturn($booking);
|
->willReturn($booking);
|
||||||
|
|
||||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
$breakdownCalculator = $this->createStub(AccommodationBookingBreakdownCalculator::class);
|
||||||
$breakdownCalculator->method('compute')->willReturn(null);
|
$breakdownCalculator->method('compute')->willReturn(null);
|
||||||
|
|
||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
@@ -256,7 +256,7 @@ class AccommodationBookingControllerTest extends TestCase
|
|||||||
->with(['uuid' => $booking->getUuid()])
|
->with(['uuid' => $booking->getUuid()])
|
||||||
->willReturn($booking);
|
->willReturn($booking);
|
||||||
|
|
||||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
$breakdownCalculator = $this->createStub(AccommodationBookingBreakdownCalculator::class);
|
||||||
$breakdownCalculator->method('compute')->willReturn(null);
|
$breakdownCalculator->method('compute')->willReturn(null);
|
||||||
|
|
||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ class ContingentControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
private function callFullSpanCalendar(?array $bounds, array $prices, array $statuses = []): array
|
private function callFullSpanCalendar(?array $bounds, array $prices, array $statuses = []): array
|
||||||
{
|
{
|
||||||
$priceRepository = $this->createMock(AccommodationPriceRepository::class);
|
$priceRepository = $this->createStub(AccommodationPriceRepository::class);
|
||||||
$priceRepository->method('findPricedDateBoundsByHotelCode')->willReturn($bounds);
|
$priceRepository->method('findPricedDateBoundsByHotelCode')->willReturn($bounds);
|
||||||
$priceRepository->method('findByHotelCodeAndDateRange')->willReturn($prices);
|
$priceRepository->method('findByHotelCodeAndDateRange')->willReturn($prices);
|
||||||
|
|
||||||
@@ -214,13 +214,13 @@ class ContingentControllerTest extends TestCase
|
|||||||
?array $prices = null,
|
?array $prices = null,
|
||||||
?AccommodationPriceRepository $priceRepository = null,
|
?AccommodationPriceRepository $priceRepository = null,
|
||||||
): Response {
|
): Response {
|
||||||
$accommodationRepository = $this->createMock(AccommodationRepository::class);
|
$accommodationRepository = $this->createStub(AccommodationRepository::class);
|
||||||
$accommodationRepository->method('findOneBy')->willReturn((new Accommodation())->setCalendarCode('HOTEL1')->setCurrency('EUR'));
|
$accommodationRepository->method('findOneBy')->willReturn((new Accommodation())->setCalendarCode('HOTEL1')->setCurrency('EUR'));
|
||||||
|
|
||||||
$snapshotReader = $this->createMock(ContingentSnapshotReader::class);
|
$snapshotReader = $this->createStub(ContingentSnapshotReader::class);
|
||||||
$snapshotReader->method('statusesFor')->willReturn($statuses);
|
$snapshotReader->method('statusesFor')->willReturn($statuses);
|
||||||
|
|
||||||
$priceRepository ??= $this->createMock(AccommodationPriceRepository::class);
|
$priceRepository ??= $this->createStub(AccommodationPriceRepository::class);
|
||||||
|
|
||||||
if (null !== $prices) {
|
if (null !== $prices) {
|
||||||
$priceRepository->method('findByHotelCodeAndDateRange')->willReturn($prices);
|
$priceRepository->method('findByHotelCodeAndDateRange')->willReturn($prices);
|
||||||
@@ -231,8 +231,8 @@ class ContingentControllerTest extends TestCase
|
|||||||
$priceRepository,
|
$priceRepository,
|
||||||
$snapshotReader,
|
$snapshotReader,
|
||||||
new PriceTimelineBuilder(),
|
new PriceTimelineBuilder(),
|
||||||
new AccommodationPriceCoverage($this->createMock(AccommodationPriceRepository::class)),
|
new AccommodationPriceCoverage($this->createStub(AccommodationPriceRepository::class)),
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
// No 'serializer' service registered, so AbstractController::json() falls back to
|
// No 'serializer' service registered, so AbstractController::json() falls back to
|
||||||
@@ -245,12 +245,12 @@ class ContingentControllerTest extends TestCase
|
|||||||
private function createController(): ContingentController
|
private function createController(): ContingentController
|
||||||
{
|
{
|
||||||
return new ContingentController(
|
return new ContingentController(
|
||||||
$this->createMock(AccommodationRepository::class),
|
$this->createStub(AccommodationRepository::class),
|
||||||
$this->createMock(AccommodationPriceRepository::class),
|
$this->createStub(AccommodationPriceRepository::class),
|
||||||
$this->createMock(ContingentSnapshotReader::class),
|
$this->createStub(ContingentSnapshotReader::class),
|
||||||
new PriceTimelineBuilder(),
|
new PriceTimelineBuilder(),
|
||||||
new AccommodationPriceCoverage($this->createMock(AccommodationPriceRepository::class)),
|
new AccommodationPriceCoverage($this->createStub(AccommodationPriceRepository::class)),
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ use App\Service\BookingEditDraftManager;
|
|||||||
use App\Service\BookingEditPreFlightChecker;
|
use App\Service\BookingEditPreFlightChecker;
|
||||||
use App\Service\BookingEditSubmitter;
|
use App\Service\BookingEditSubmitter;
|
||||||
use App\Service\BookingSessionManager;
|
use App\Service\BookingSessionManager;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Log\NullLogger;
|
use Psr\Log\NullLogger;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
@@ -62,7 +63,7 @@ class IndexControllerTest extends TestCase
|
|||||||
];
|
];
|
||||||
$bookingData = $this->createBooking();
|
$bookingData = $this->createBooking();
|
||||||
|
|
||||||
$form = $this->createMock(FormInterface::class);
|
$form = $this->createStub(FormInterface::class);
|
||||||
$form->method('isSubmitted')->willReturn(false);
|
$form->method('isSubmitted')->willReturn(false);
|
||||||
|
|
||||||
$fingerprintService = $this->createMock(BookingChangeTracker::class);
|
$fingerprintService = $this->createMock(BookingChangeTracker::class);
|
||||||
@@ -110,13 +111,13 @@ class IndexControllerTest extends TestCase
|
|||||||
|
|
||||||
$controller = new TestableIndexController(
|
$controller = new TestableIndexController(
|
||||||
$dataLoader,
|
$dataLoader,
|
||||||
$this->createMock(BookingEditDraftManager::class),
|
$this->createStub(BookingEditDraftManager::class),
|
||||||
$bookingSessionService,
|
$bookingSessionService,
|
||||||
$fingerprintService,
|
$fingerprintService,
|
||||||
$bookingConfigurator,
|
$bookingConfigurator,
|
||||||
$contextFactory,
|
$contextFactory,
|
||||||
$preflightChecker,
|
$preflightChecker,
|
||||||
$this->createMock(BookingEditSubmitter::class),
|
$this->createStub(BookingEditSubmitter::class),
|
||||||
$user,
|
$user,
|
||||||
$form,
|
$form,
|
||||||
);
|
);
|
||||||
@@ -147,7 +148,7 @@ class IndexControllerTest extends TestCase
|
|||||||
];
|
];
|
||||||
$bookingData = $this->createBooking();
|
$bookingData = $this->createBooking();
|
||||||
|
|
||||||
$form = $this->createMock(FormInterface::class);
|
$form = $this->createStub(FormInterface::class);
|
||||||
$form->method('isSubmitted')->willReturn(false);
|
$form->method('isSubmitted')->willReturn(false);
|
||||||
|
|
||||||
$fingerprintService = $this->createMock(BookingChangeTracker::class);
|
$fingerprintService = $this->createMock(BookingChangeTracker::class);
|
||||||
@@ -187,13 +188,13 @@ class IndexControllerTest extends TestCase
|
|||||||
|
|
||||||
$controller = new TestableIndexController(
|
$controller = new TestableIndexController(
|
||||||
$dataLoader,
|
$dataLoader,
|
||||||
$this->createMock(BookingEditDraftManager::class),
|
$this->createStub(BookingEditDraftManager::class),
|
||||||
$this->createMock(BookingSessionManager::class),
|
$this->createStub(BookingSessionManager::class),
|
||||||
$fingerprintService,
|
$fingerprintService,
|
||||||
$this->createMock(BookingConfigurator::class),
|
$this->createStub(BookingConfigurator::class),
|
||||||
$contextFactory,
|
$contextFactory,
|
||||||
$preflightChecker,
|
$preflightChecker,
|
||||||
$this->createMock(BookingEditSubmitter::class),
|
$this->createStub(BookingEditSubmitter::class),
|
||||||
$user,
|
$user,
|
||||||
$form,
|
$form,
|
||||||
);
|
);
|
||||||
@@ -275,10 +276,10 @@ class IndexControllerTest extends TestCase
|
|||||||
|
|
||||||
$controller = new TestableIndexController(
|
$controller = new TestableIndexController(
|
||||||
$dataLoader,
|
$dataLoader,
|
||||||
$this->createMock(BookingEditDraftManager::class),
|
$this->createStub(BookingEditDraftManager::class),
|
||||||
$this->createMock(BookingSessionManager::class),
|
$this->createStub(BookingSessionManager::class),
|
||||||
$fingerprintService,
|
$fingerprintService,
|
||||||
$this->createMock(BookingConfigurator::class),
|
$this->createStub(BookingConfigurator::class),
|
||||||
$contextFactory,
|
$contextFactory,
|
||||||
$preflightChecker,
|
$preflightChecker,
|
||||||
$submitter,
|
$submitter,
|
||||||
@@ -362,10 +363,10 @@ class IndexControllerTest extends TestCase
|
|||||||
|
|
||||||
$controller = new TestableIndexController(
|
$controller = new TestableIndexController(
|
||||||
$dataLoader,
|
$dataLoader,
|
||||||
$this->createMock(BookingEditDraftManager::class),
|
$this->createStub(BookingEditDraftManager::class),
|
||||||
$this->createMock(BookingSessionManager::class),
|
$this->createStub(BookingSessionManager::class),
|
||||||
$fingerprintService,
|
$fingerprintService,
|
||||||
$this->createMock(BookingConfigurator::class),
|
$this->createStub(BookingConfigurator::class),
|
||||||
$contextFactory,
|
$contextFactory,
|
||||||
$preflightChecker,
|
$preflightChecker,
|
||||||
$submitter,
|
$submitter,
|
||||||
@@ -390,7 +391,7 @@ class IndexControllerTest extends TestCase
|
|||||||
$bookingDto->participants = [$this->createParticipant()];
|
$bookingDto->participants = [$this->createParticipant()];
|
||||||
$bookingData = $this->createBooking();
|
$bookingData = $this->createBooking();
|
||||||
|
|
||||||
$form = $this->createMock(FormInterface::class);
|
$form = $this->createStub(FormInterface::class);
|
||||||
$form->method('isSubmitted')->willReturn(false);
|
$form->method('isSubmitted')->willReturn(false);
|
||||||
|
|
||||||
$fingerprintService = $this->createMock(BookingChangeTracker::class);
|
$fingerprintService = $this->createMock(BookingChangeTracker::class);
|
||||||
@@ -433,13 +434,13 @@ class IndexControllerTest extends TestCase
|
|||||||
|
|
||||||
$controller = new TestableIndexController(
|
$controller = new TestableIndexController(
|
||||||
$dataLoader,
|
$dataLoader,
|
||||||
$this->createMock(BookingEditDraftManager::class),
|
$this->createStub(BookingEditDraftManager::class),
|
||||||
$this->createMock(BookingSessionManager::class),
|
$this->createStub(BookingSessionManager::class),
|
||||||
$fingerprintService,
|
$fingerprintService,
|
||||||
$bookingConfigurator,
|
$bookingConfigurator,
|
||||||
$contextFactory,
|
$contextFactory,
|
||||||
$this->createPreflightChecker($bookingDto),
|
$this->createPreflightChecker($bookingDto),
|
||||||
$this->createMock(BookingEditSubmitter::class),
|
$this->createStub(BookingEditSubmitter::class),
|
||||||
$user,
|
$user,
|
||||||
$form,
|
$form,
|
||||||
);
|
);
|
||||||
@@ -460,7 +461,7 @@ class IndexControllerTest extends TestCase
|
|||||||
$bookingDto->participants = [$this->createParticipant()];
|
$bookingDto->participants = [$this->createParticipant()];
|
||||||
$bookingData = $this->createBooking();
|
$bookingData = $this->createBooking();
|
||||||
|
|
||||||
$form = $this->createMock(FormInterface::class);
|
$form = $this->createStub(FormInterface::class);
|
||||||
$form->method('isSubmitted')->willReturn(false);
|
$form->method('isSubmitted')->willReturn(false);
|
||||||
|
|
||||||
$fingerprintService = $this->createMock(BookingChangeTracker::class);
|
$fingerprintService = $this->createMock(BookingChangeTracker::class);
|
||||||
@@ -501,13 +502,13 @@ class IndexControllerTest extends TestCase
|
|||||||
|
|
||||||
$controller = new TestableIndexController(
|
$controller = new TestableIndexController(
|
||||||
$dataLoader,
|
$dataLoader,
|
||||||
$this->createMock(BookingEditDraftManager::class),
|
$this->createStub(BookingEditDraftManager::class),
|
||||||
$this->createMock(BookingSessionManager::class),
|
$this->createStub(BookingSessionManager::class),
|
||||||
$fingerprintService,
|
$fingerprintService,
|
||||||
$bookingConfigurator,
|
$bookingConfigurator,
|
||||||
$contextFactory,
|
$contextFactory,
|
||||||
$this->createPreflightChecker($bookingDto),
|
$this->createPreflightChecker($bookingDto),
|
||||||
$this->createMock(BookingEditSubmitter::class),
|
$this->createStub(BookingEditSubmitter::class),
|
||||||
$user,
|
$user,
|
||||||
$form,
|
$form,
|
||||||
);
|
);
|
||||||
@@ -543,13 +544,13 @@ class IndexControllerTest extends TestCase
|
|||||||
$dataLoader,
|
$dataLoader,
|
||||||
$draftService,
|
$draftService,
|
||||||
$bookingSessionService,
|
$bookingSessionService,
|
||||||
$this->createMock(BookingChangeTracker::class),
|
$this->createStub(BookingChangeTracker::class),
|
||||||
$this->createMock(BookingConfigurator::class),
|
$this->createStub(BookingConfigurator::class),
|
||||||
$this->createMock(BookingEditContextFactory::class),
|
$this->createStub(BookingEditContextFactory::class),
|
||||||
$this->createMock(BookingEditPreFlightChecker::class),
|
$this->createStub(BookingEditPreFlightChecker::class),
|
||||||
$this->createMock(BookingEditSubmitter::class),
|
$this->createStub(BookingEditSubmitter::class),
|
||||||
$user,
|
$user,
|
||||||
$this->createMock(FormInterface::class),
|
$this->createStub(FormInterface::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $controller->reloadFromApi(42, $request);
|
$response = $controller->reloadFromApi(42, $request);
|
||||||
@@ -560,11 +561,11 @@ class IndexControllerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider submissionResultProvider
|
|
||||||
*
|
|
||||||
* @param array<int, array{0: string, 1: string}> $expectedFlashes
|
* @param array<int, array{0: string, 1: string}> $expectedFlashes
|
||||||
|
*
|
||||||
* @phpstan-param array<int, array{0: string, 1: string}> $expectedFlashes
|
* @phpstan-param array<int, array{0: string, 1: string}> $expectedFlashes
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('submissionResultProvider')]
|
||||||
public function testIndexAppliesErrorSubmissionResultFlashesAndRedirectsBackToEditPage(
|
public function testIndexAppliesErrorSubmissionResultFlashesAndRedirectsBackToEditPage(
|
||||||
BookingEditSubmissionResult $submissionResult,
|
BookingEditSubmissionResult $submissionResult,
|
||||||
array $expectedFlashes,
|
array $expectedFlashes,
|
||||||
@@ -673,7 +674,7 @@ class IndexControllerTest extends TestCase
|
|||||||
bookingDto: $bookingDto,
|
bookingDto: $bookingDto,
|
||||||
bookingData: $bookingData,
|
bookingData: $bookingData,
|
||||||
mutableData: null,
|
mutableData: null,
|
||||||
summaryData: $this->createMock(BookingSummaryDto::class),
|
summaryData: $this->createStub(BookingSummaryDto::class),
|
||||||
cardsData: [
|
cardsData: [
|
||||||
0 => new ParticipantCardDataDto(
|
0 => new ParticipantCardDataDto(
|
||||||
'One',
|
'One',
|
||||||
@@ -755,11 +756,11 @@ class IndexControllerTest extends TestCase
|
|||||||
|
|
||||||
$controller = new TestableIndexController(
|
$controller = new TestableIndexController(
|
||||||
$dataLoader,
|
$dataLoader,
|
||||||
$this->createMock(BookingEditDraftManager::class),
|
$this->createStub(BookingEditDraftManager::class),
|
||||||
$this->createMock(BookingSessionManager::class),
|
$this->createStub(BookingSessionManager::class),
|
||||||
$fingerprintService,
|
$fingerprintService,
|
||||||
$this->createMock(BookingConfigurator::class),
|
$this->createStub(BookingConfigurator::class),
|
||||||
$this->createMock(BookingEditContextFactory::class),
|
$this->createStub(BookingEditContextFactory::class),
|
||||||
$preflightChecker,
|
$preflightChecker,
|
||||||
$submitter,
|
$submitter,
|
||||||
$user,
|
$user,
|
||||||
|
|||||||
@@ -86,9 +86,9 @@ class ParticipantControllerTest extends TestCase
|
|||||||
->with($user, 42, $bookingDto);
|
->with($user, 42, $bookingDto);
|
||||||
|
|
||||||
$prepopulationService = new ParticipantDataPrefiller(
|
$prepopulationService = new ParticipantDataPrefiller(
|
||||||
$this->createMock(ApiClient::class),
|
$this->createStub(ApiClient::class),
|
||||||
$this->createMock(Crypt::class),
|
$this->createStub(Crypt::class),
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
$participantFormSupportService = $this->createMock(ParticipantFormSupport::class);
|
$participantFormSupportService = $this->createMock(ParticipantFormSupport::class);
|
||||||
@@ -115,7 +115,7 @@ class ParticipantControllerTest extends TestCase
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$summaryData = $this->createMock(BookingSummaryDto::class);
|
$summaryData = $this->createStub(BookingSummaryDto::class);
|
||||||
$context = new BookingEditContext($bookingDto, $bookingData, null, $summaryData);
|
$context = new BookingEditContext($bookingDto, $bookingData, null, $summaryData);
|
||||||
|
|
||||||
$contextFactory = $this->createMock(BookingEditContextFactory::class);
|
$contextFactory = $this->createMock(BookingEditContextFactory::class);
|
||||||
@@ -131,7 +131,7 @@ class ParticipantControllerTest extends TestCase
|
|||||||
$dataLoader,
|
$dataLoader,
|
||||||
$draftService,
|
$draftService,
|
||||||
$contextFactory,
|
$contextFactory,
|
||||||
$this->createMock(BookingConfigurator::class),
|
$this->createStub(BookingConfigurator::class),
|
||||||
$bookingSessionService,
|
$bookingSessionService,
|
||||||
$prepopulationService,
|
$prepopulationService,
|
||||||
$participantFormSupportService,
|
$participantFormSupportService,
|
||||||
@@ -217,7 +217,7 @@ class ParticipantControllerTest extends TestCase
|
|||||||
->with($bookingDto)
|
->with($bookingDto)
|
||||||
->willReturn([]);
|
->willReturn([]);
|
||||||
|
|
||||||
$summaryData = $this->createMock(BookingSummaryDto::class);
|
$summaryData = $this->createStub(BookingSummaryDto::class);
|
||||||
$context = new BookingEditContext($bookingDto, $bookingData, null, $summaryData);
|
$context = new BookingEditContext($bookingDto, $bookingData, null, $summaryData);
|
||||||
|
|
||||||
$contextFactory = $this->createMock(BookingEditContextFactory::class);
|
$contextFactory = $this->createMock(BookingEditContextFactory::class);
|
||||||
@@ -230,14 +230,14 @@ class ParticipantControllerTest extends TestCase
|
|||||||
->willReturn($context);
|
->willReturn($context);
|
||||||
|
|
||||||
$prepopulationService = new ParticipantDataPrefiller(
|
$prepopulationService = new ParticipantDataPrefiller(
|
||||||
$this->createMock(ApiClient::class),
|
$this->createStub(ApiClient::class),
|
||||||
$this->createMock(Crypt::class),
|
$this->createStub(Crypt::class),
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
$controller = new TestableParticipantController(
|
$controller = new TestableParticipantController(
|
||||||
$dataLoader,
|
$dataLoader,
|
||||||
$this->createMock(BookingEditDraftManager::class),
|
$this->createStub(BookingEditDraftManager::class),
|
||||||
$contextFactory,
|
$contextFactory,
|
||||||
$bookingConfigurator,
|
$bookingConfigurator,
|
||||||
$bookingSessionService,
|
$bookingSessionService,
|
||||||
@@ -286,17 +286,17 @@ class ParticipantControllerTest extends TestCase
|
|||||||
$bookingDto->originalFingerprint = $changeTracker->generateFingerprint($bookingDto);
|
$bookingDto->originalFingerprint = $changeTracker->generateFingerprint($bookingDto);
|
||||||
$this->assertFalse($changeTracker->isDirty($bookingDto), 'Baseline must start clean');
|
$this->assertFalse($changeTracker->isDirty($bookingDto), 'Baseline must start clean');
|
||||||
|
|
||||||
$form = $this->createMock(FormInterface::class);
|
$form = $this->createStub(FormInterface::class);
|
||||||
$form->method('handleRequest')->willReturnSelf();
|
$form->method('handleRequest')->willReturnSelf();
|
||||||
$form->method('createView')->willReturn(new FormView());
|
$form->method('createView')->willReturn(new FormView());
|
||||||
|
|
||||||
$dataLoader = $this->createMock(BookingEditDataLoader::class);
|
$dataLoader = $this->createStub(BookingEditDataLoader::class);
|
||||||
$dataLoader->method('fetchBookingData')->willReturn($bookingData);
|
$dataLoader->method('fetchBookingData')->willReturn($bookingData);
|
||||||
|
|
||||||
$bookingSessionService = $this->createMock(BookingSessionManager::class);
|
$bookingSessionService = $this->createStub(BookingSessionManager::class);
|
||||||
$bookingSessionService->method('getBookingDto')->willReturn($bookingDto);
|
$bookingSessionService->method('getBookingDto')->willReturn($bookingDto);
|
||||||
|
|
||||||
$participantFormSupportService = $this->createMock(ParticipantFormSupport::class);
|
$participantFormSupportService = $this->createStub(ParticipantFormSupport::class);
|
||||||
$participantFormSupportService->method('ensureParticipantExists')->willReturn($participant);
|
$participantFormSupportService->method('ensureParticipantExists')->willReturn($participant);
|
||||||
$participantFormSupportService->method('createParticipantEditDto')
|
$participantFormSupportService->method('createParticipantEditDto')
|
||||||
->willReturn(new ParticipantEditDto($participant, $bookingDto));
|
->willReturn(new ParticipantEditDto($participant, $bookingDto));
|
||||||
@@ -306,21 +306,21 @@ class ParticipantControllerTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
$participantFormSupportService->method('collectAndClearNotifications')->willReturn([]);
|
$participantFormSupportService->method('collectAndClearNotifications')->willReturn([]);
|
||||||
|
|
||||||
$summaryData = $this->createMock(BookingSummaryDto::class);
|
$summaryData = $this->createStub(BookingSummaryDto::class);
|
||||||
$contextFactory = $this->createMock(BookingEditContextFactory::class);
|
$contextFactory = $this->createStub(BookingEditContextFactory::class);
|
||||||
$contextFactory->method('createParticipantContext')
|
$contextFactory->method('createParticipantContext')
|
||||||
->willReturn(new BookingEditContext($bookingDto, $bookingData, null, $summaryData));
|
->willReturn(new BookingEditContext($bookingDto, $bookingData, null, $summaryData));
|
||||||
|
|
||||||
$controller = new TestableParticipantController(
|
$controller = new TestableParticipantController(
|
||||||
$dataLoader,
|
$dataLoader,
|
||||||
$this->createMock(BookingEditDraftManager::class),
|
$this->createStub(BookingEditDraftManager::class),
|
||||||
$contextFactory,
|
$contextFactory,
|
||||||
$this->createMock(BookingConfigurator::class),
|
$this->createStub(BookingConfigurator::class),
|
||||||
$bookingSessionService,
|
$bookingSessionService,
|
||||||
new ParticipantDataPrefiller(
|
new ParticipantDataPrefiller(
|
||||||
$this->createMock(ApiClient::class),
|
$this->createStub(ApiClient::class),
|
||||||
$this->createMock(Crypt::class),
|
$this->createStub(Crypt::class),
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
),
|
),
|
||||||
$participantFormSupportService,
|
$participantFormSupportService,
|
||||||
$user,
|
$user,
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ class IndexControllerTest extends TestCase
|
|||||||
private function makeController(): TestableAccommodationIndexController
|
private function makeController(): TestableAccommodationIndexController
|
||||||
{
|
{
|
||||||
return new TestableAccommodationIndexController(
|
return new TestableAccommodationIndexController(
|
||||||
$this->createMock(AccommodationBookingService::class),
|
$this->createStub(AccommodationBookingService::class),
|
||||||
$this->createMock(AccommodationSessionManager::class),
|
$this->createStub(AccommodationSessionManager::class),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,20 +106,20 @@ class Step1CalendarDataTest extends TestCase
|
|||||||
string $dateFrom,
|
string $dateFrom,
|
||||||
string $dateTo,
|
string $dateTo,
|
||||||
): array {
|
): array {
|
||||||
$snapshotReader = $this->createMock(ContingentSnapshotReader::class);
|
$snapshotReader = $this->createStub(ContingentSnapshotReader::class);
|
||||||
$snapshotReader->method('statusesFor')->willReturn($statuses);
|
$snapshotReader->method('statusesFor')->willReturn($statuses);
|
||||||
|
|
||||||
$priceRepository = $this->createMock(AccommodationPriceRepository::class);
|
$priceRepository = $this->createStub(AccommodationPriceRepository::class);
|
||||||
$priceRepository->method('findByHotelCodeAndDateRange')->willReturn($prices);
|
$priceRepository->method('findByHotelCodeAndDateRange')->willReturn($prices);
|
||||||
|
|
||||||
$controller = new Step1Controller(
|
$controller = new Step1Controller(
|
||||||
$this->createMock(AccommodationBookingService::class),
|
$this->createStub(AccommodationBookingService::class),
|
||||||
$this->createMock(AccommodationSessionManager::class),
|
$this->createStub(AccommodationSessionManager::class),
|
||||||
$priceRepository,
|
$priceRepository,
|
||||||
new PriceTimelineBuilder(),
|
new PriceTimelineBuilder(),
|
||||||
$snapshotReader,
|
$snapshotReader,
|
||||||
$this->createMock(CalendarGridBuilder::class),
|
$this->createStub(CalendarGridBuilder::class),
|
||||||
$this->createMock(GroupsPriceCalculator::class),
|
$this->createStub(GroupsPriceCalculator::class),
|
||||||
new AccommodationPriceCoverage($priceRepository),
|
new AccommodationPriceCoverage($priceRepository),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ class Step1ControllerTest extends TestCase
|
|||||||
$sessionManager = new AccommodationSessionManager();
|
$sessionManager = new AccommodationSessionManager();
|
||||||
$sessionManager->save($request, $dto);
|
$sessionManager->save($request, $dto);
|
||||||
|
|
||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createStub(AccommodationBookingService::class);
|
||||||
$bookingService
|
$bookingService
|
||||||
->method('applyDates')
|
->method('applyDates')
|
||||||
->willThrowException(new \InvalidArgumentException('Ungültiges Datumsformat. Erwartet: YYYY-MM-DD.'));
|
->willThrowException(new \InvalidArgumentException('Ungültiges Datumsformat. Erwartet: YYYY-MM-DD.'));
|
||||||
@@ -105,14 +105,14 @@ class Step1ControllerTest extends TestCase
|
|||||||
AccommodationBookingService $bookingService,
|
AccommodationBookingService $bookingService,
|
||||||
AccommodationSessionManager $sessionManager,
|
AccommodationSessionManager $sessionManager,
|
||||||
): TestableAccommodationStep1Controller {
|
): TestableAccommodationStep1Controller {
|
||||||
$priceRepository = $this->createMock(AccommodationPriceRepository::class);
|
$priceRepository = $this->createStub(AccommodationPriceRepository::class);
|
||||||
|
|
||||||
return new TestableAccommodationStep1Controller(
|
return new TestableAccommodationStep1Controller(
|
||||||
$bookingService,
|
$bookingService,
|
||||||
$sessionManager,
|
$sessionManager,
|
||||||
$priceRepository,
|
$priceRepository,
|
||||||
new PriceTimelineBuilder(),
|
new PriceTimelineBuilder(),
|
||||||
$this->createMock(ContingentSnapshotReader::class),
|
$this->createStub(ContingentSnapshotReader::class),
|
||||||
new CalendarGridBuilder(),
|
new CalendarGridBuilder(),
|
||||||
new GroupsPriceCalculator(new PriceTimelineBuilder(), ['runningCostsEur' => 0, 'runningCostsChf' => 0, 'undersubscription30Eur' => 0, 'undersubscription30Chf' => 0, 'undersubscription40Eur' => 0, 'undersubscription40Chf' => 0]),
|
new GroupsPriceCalculator(new PriceTimelineBuilder(), ['runningCostsEur' => 0, 'runningCostsChf' => 0, 'undersubscription30Eur' => 0, 'undersubscription30Chf' => 0, 'undersubscription40Eur' => 0, 'undersubscription40Chf' => 0]),
|
||||||
new AccommodationPriceCoverage($priceRepository),
|
new AccommodationPriceCoverage($priceRepository),
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class Step2ControllerTest extends TestCase
|
|||||||
$sessionManager = new AccommodationSessionManager();
|
$sessionManager = new AccommodationSessionManager();
|
||||||
$sessionManager->save($request, $dto);
|
$sessionManager->save($request, $dto);
|
||||||
|
|
||||||
$form = $this->createMock(FormInterface::class);
|
$form = $this->createStub(FormInterface::class);
|
||||||
$form
|
$form
|
||||||
->method('handleRequest')
|
->method('handleRequest')
|
||||||
->willReturnCallback(function () use ($dto, $form): FormInterface {
|
->willReturnCallback(function () use ($dto, $form): FormInterface {
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ class Step3ControllerTest extends TestCase
|
|||||||
|
|
||||||
private function createFormMock(bool $submitted, bool $valid): FormInterface
|
private function createFormMock(bool $submitted, bool $valid): FormInterface
|
||||||
{
|
{
|
||||||
$form = $this->createMock(FormInterface::class);
|
$form = $this->createStub(FormInterface::class);
|
||||||
$form->method('handleRequest')->willReturnSelf();
|
$form->method('handleRequest')->willReturnSelf();
|
||||||
$form->method('isSubmitted')->willReturn($submitted);
|
$form->method('isSubmitted')->willReturn($submitted);
|
||||||
$form->method('isValid')->willReturn($valid);
|
$form->method('isValid')->willReturn($valid);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class Step4ControllerTest extends TestCase
|
|||||||
'ungroupedAdditionalServices' => [],
|
'ungroupedAdditionalServices' => [],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$controller = new TestableStep4Controller($bookingService, $sessionManager, $this->createMock(FormInterface::class));
|
$controller = new TestableStep4Controller($bookingService, $sessionManager, $this->createStub(FormInterface::class));
|
||||||
|
|
||||||
$response = $controller->index($request);
|
$response = $controller->index($request);
|
||||||
|
|
||||||
@@ -73,9 +73,9 @@ class Step4ControllerTest extends TestCase
|
|||||||
$sessionManager->save($request, $dto);
|
$sessionManager->save($request, $dto);
|
||||||
|
|
||||||
$controller = new TestableStep4Controller(
|
$controller = new TestableStep4Controller(
|
||||||
$this->createMock(AccommodationBookingService::class),
|
$this->createStub(AccommodationBookingService::class),
|
||||||
$sessionManager,
|
$sessionManager,
|
||||||
$this->createMock(FormInterface::class),
|
$this->createStub(FormInterface::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $controller->index($request);
|
$response = $controller->index($request);
|
||||||
@@ -115,7 +115,7 @@ class Step4ControllerTest extends TestCase
|
|||||||
$bookingService->method('loadPrices')->willReturn([]);
|
$bookingService->method('loadPrices')->willReturn([]);
|
||||||
$bookingService->expects(self::once())->method('finalizeBooking')->willReturn($booking);
|
$bookingService->expects(self::once())->method('finalizeBooking')->willReturn($booking);
|
||||||
|
|
||||||
$inquiryForm = $this->createMock(FormInterface::class);
|
$inquiryForm = $this->createStub(FormInterface::class);
|
||||||
$inquiryForm->method('handleRequest')->willReturnSelf();
|
$inquiryForm->method('handleRequest')->willReturnSelf();
|
||||||
$inquiryForm->method('isSubmitted')->willReturn(true);
|
$inquiryForm->method('isSubmitted')->willReturn(true);
|
||||||
$inquiryForm->method('isValid')->willReturn(true);
|
$inquiryForm->method('isValid')->willReturn(true);
|
||||||
@@ -158,7 +158,7 @@ class Step4ControllerTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
$bookingService->expects(self::never())->method('finalizeBooking');
|
$bookingService->expects(self::never())->method('finalizeBooking');
|
||||||
|
|
||||||
$inquiryForm = $this->createMock(FormInterface::class);
|
$inquiryForm = $this->createStub(FormInterface::class);
|
||||||
$inquiryForm->method('handleRequest')->willReturnSelf();
|
$inquiryForm->method('handleRequest')->willReturnSelf();
|
||||||
$inquiryForm->method('isSubmitted')->willReturn(true);
|
$inquiryForm->method('isSubmitted')->willReturn(true);
|
||||||
$inquiryForm->method('isValid')->willReturn(false);
|
$inquiryForm->method('isValid')->willReturn(false);
|
||||||
@@ -184,9 +184,9 @@ class Step4ControllerTest extends TestCase
|
|||||||
$sessionManager->save($request, $dto);
|
$sessionManager->save($request, $dto);
|
||||||
|
|
||||||
$controller = new TestableStep4Controller(
|
$controller = new TestableStep4Controller(
|
||||||
$this->createMock(AccommodationBookingService::class),
|
$this->createStub(AccommodationBookingService::class),
|
||||||
$sessionManager,
|
$sessionManager,
|
||||||
$this->createMock(FormInterface::class),
|
$this->createStub(FormInterface::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $controller->confirmInquiry($request);
|
$response = $controller->confirmInquiry($request);
|
||||||
@@ -209,9 +209,9 @@ class Step4ControllerTest extends TestCase
|
|||||||
$sessionManager->save($request, $dto);
|
$sessionManager->save($request, $dto);
|
||||||
|
|
||||||
$controller = new TestableStep4Controller(
|
$controller = new TestableStep4Controller(
|
||||||
$this->createMock(AccommodationBookingService::class),
|
$this->createStub(AccommodationBookingService::class),
|
||||||
$sessionManager,
|
$sessionManager,
|
||||||
$this->createMock(FormInterface::class),
|
$this->createStub(FormInterface::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $controller->confirmInquiry($request);
|
$response = $controller->confirmInquiry($request);
|
||||||
@@ -242,7 +242,7 @@ class Step4ControllerTest extends TestCase
|
|||||||
$bookingService->method('loadAccommodation')->with(1)->willReturn($accommodation);
|
$bookingService->method('loadAccommodation')->with(1)->willReturn($accommodation);
|
||||||
$bookingService->expects(self::never())->method('finalizeBooking');
|
$bookingService->expects(self::never())->method('finalizeBooking');
|
||||||
|
|
||||||
$confirmationForm = $this->createMock(FormInterface::class);
|
$confirmationForm = $this->createStub(FormInterface::class);
|
||||||
$confirmationForm->method('handleRequest')->willReturnSelf();
|
$confirmationForm->method('handleRequest')->willReturnSelf();
|
||||||
$confirmationForm->method('isSubmitted')->willReturn(false);
|
$confirmationForm->method('isSubmitted')->willReturn(false);
|
||||||
|
|
||||||
@@ -288,7 +288,7 @@ class Step4ControllerTest extends TestCase
|
|||||||
$bookingService->method('loadPrices')->willReturn([]);
|
$bookingService->method('loadPrices')->willReturn([]);
|
||||||
$bookingService->expects(self::once())->method('finalizeBooking')->willReturn($booking);
|
$bookingService->expects(self::once())->method('finalizeBooking')->willReturn($booking);
|
||||||
|
|
||||||
$confirmationForm = $this->createMock(FormInterface::class);
|
$confirmationForm = $this->createStub(FormInterface::class);
|
||||||
$confirmationForm->method('handleRequest')->willReturnSelf();
|
$confirmationForm->method('handleRequest')->willReturnSelf();
|
||||||
$confirmationForm->method('isSubmitted')->willReturn(true);
|
$confirmationForm->method('isSubmitted')->willReturn(true);
|
||||||
$confirmationForm->method('isValid')->willReturn(true);
|
$confirmationForm->method('isValid')->willReturn(true);
|
||||||
@@ -324,7 +324,7 @@ class Step4ControllerTest extends TestCase
|
|||||||
$bookingService->method('loadAccommodation')->with(1)->willReturn($accommodation);
|
$bookingService->method('loadAccommodation')->with(1)->willReturn($accommodation);
|
||||||
$bookingService->expects(self::never())->method('finalizeBooking');
|
$bookingService->expects(self::never())->method('finalizeBooking');
|
||||||
|
|
||||||
$confirmationForm = $this->createMock(FormInterface::class);
|
$confirmationForm = $this->createStub(FormInterface::class);
|
||||||
$confirmationForm->method('handleRequest')->willReturnSelf();
|
$confirmationForm->method('handleRequest')->willReturnSelf();
|
||||||
$confirmationForm->method('isSubmitted')->willReturn(true);
|
$confirmationForm->method('isSubmitted')->willReturn(true);
|
||||||
$confirmationForm->method('isValid')->willReturn(false);
|
$confirmationForm->method('isValid')->willReturn(false);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ use App\Service\AccommodationBookingBreakdownCalculator;
|
|||||||
use App\Service\AccommodationBookingLinkSigner;
|
use App\Service\AccommodationBookingLinkSigner;
|
||||||
use App\Service\AccommodationBookingService;
|
use App\Service\AccommodationBookingService;
|
||||||
use App\Service\AccommodationTermsUrlProvider;
|
use App\Service\AccommodationTermsUrlProvider;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
@@ -39,8 +40,8 @@ class IndexControllerTest extends TestCase
|
|||||||
$controller = new TestableOfferController(
|
$controller = new TestableOfferController(
|
||||||
$bookingRepository,
|
$bookingRepository,
|
||||||
$linkSigner,
|
$linkSigner,
|
||||||
$this->createMock(AccommodationBookingBreakdownCalculator::class),
|
$this->createStub(AccommodationBookingBreakdownCalculator::class),
|
||||||
$this->createMock(AccommodationBookingService::class),
|
$this->createStub(AccommodationBookingService::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $controller->access($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid()));
|
$response = $controller->access($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid()));
|
||||||
@@ -53,7 +54,7 @@ class IndexControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$booking = new AccommodationBooking();
|
$booking = new AccommodationBooking();
|
||||||
|
|
||||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
|
||||||
$bookingRepository->method('findOneBy')->willReturn($booking);
|
$bookingRepository->method('findOneBy')->willReturn($booking);
|
||||||
|
|
||||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
||||||
@@ -63,8 +64,8 @@ class IndexControllerTest extends TestCase
|
|||||||
$controller = new TestableOfferController(
|
$controller = new TestableOfferController(
|
||||||
$bookingRepository,
|
$bookingRepository,
|
||||||
$linkSigner,
|
$linkSigner,
|
||||||
$this->createMock(AccommodationBookingBreakdownCalculator::class),
|
$this->createStub(AccommodationBookingBreakdownCalculator::class),
|
||||||
$this->createMock(AccommodationBookingService::class),
|
$this->createStub(AccommodationBookingService::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $controller->access($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid()));
|
$response = $controller->access($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid()));
|
||||||
@@ -75,7 +76,7 @@ class IndexControllerTest extends TestCase
|
|||||||
|
|
||||||
public function testAccessRendersUnavailableForUnknownUuid(): void
|
public function testAccessRendersUnavailableForUnknownUuid(): void
|
||||||
{
|
{
|
||||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
|
||||||
$bookingRepository->method('findOneBy')->willReturn(null);
|
$bookingRepository->method('findOneBy')->willReturn(null);
|
||||||
|
|
||||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
||||||
@@ -84,8 +85,8 @@ class IndexControllerTest extends TestCase
|
|||||||
$controller = new TestableOfferController(
|
$controller = new TestableOfferController(
|
||||||
$bookingRepository,
|
$bookingRepository,
|
||||||
$linkSigner,
|
$linkSigner,
|
||||||
$this->createMock(AccommodationBookingBreakdownCalculator::class),
|
$this->createStub(AccommodationBookingBreakdownCalculator::class),
|
||||||
$this->createMock(AccommodationBookingService::class),
|
$this->createStub(AccommodationBookingService::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $controller->access('unknown-uuid', Request::create('/groups/booking/offer/unknown-uuid'));
|
$response = $controller->access('unknown-uuid', Request::create('/groups/booking/offer/unknown-uuid'));
|
||||||
@@ -94,15 +95,13 @@ class IndexControllerTest extends TestCase
|
|||||||
self::assertSame('groups/offer/unavailable.html.twig', $controller->renderedView);
|
self::assertSame('groups/offer/unavailable.html.twig', $controller->renderedView);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('statusesTheCustomerMustNotSee')]
|
||||||
* @dataProvider statusesTheCustomerMustNotSee
|
|
||||||
*/
|
|
||||||
public function testAccessRendersUnavailableForABookingThatIsNotOfferedYet(AccommodationBookingStatus $status): void
|
public function testAccessRendersUnavailableForABookingThatIsNotOfferedYet(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
$booking = new AccommodationBooking();
|
$booking = new AccommodationBooking();
|
||||||
$booking->setStatus($status);
|
$booking->setStatus($status);
|
||||||
|
|
||||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
|
||||||
$bookingRepository->method('findOneBy')->willReturn($booking);
|
$bookingRepository->method('findOneBy')->willReturn($booking);
|
||||||
|
|
||||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
||||||
@@ -112,8 +111,8 @@ class IndexControllerTest extends TestCase
|
|||||||
$controller = new TestableOfferController(
|
$controller = new TestableOfferController(
|
||||||
$bookingRepository,
|
$bookingRepository,
|
||||||
$linkSigner,
|
$linkSigner,
|
||||||
$this->createMock(AccommodationBookingBreakdownCalculator::class),
|
$this->createStub(AccommodationBookingBreakdownCalculator::class),
|
||||||
$this->createMock(AccommodationBookingService::class),
|
$this->createStub(AccommodationBookingService::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $controller->access($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid()));
|
$response = $controller->access($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid()));
|
||||||
@@ -137,19 +136,18 @@ class IndexControllerTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* The status is re-read on every view, so an authorized session is no free pass: a
|
* The status is re-read on every view, so an authorized session is no free pass: a
|
||||||
* booking pushed back into Entwurf stops showing the offer from that moment on.
|
* booking pushed back into Entwurf stops showing the offer from that moment on.
|
||||||
*
|
|
||||||
* @dataProvider statusesTheCustomerMustNotSee
|
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('statusesTheCustomerMustNotSee')]
|
||||||
public function testViewRendersUnavailableForABookingTheCustomerMustNotSee(AccommodationBookingStatus $status): void
|
public function testViewRendersUnavailableForABookingTheCustomerMustNotSee(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
$booking = new AccommodationBooking();
|
$booking = new AccommodationBooking();
|
||||||
$booking->setStatus($status);
|
$booking->setStatus($status);
|
||||||
$booking->setAccommodation(new Accommodation());
|
$booking->setAccommodation(new Accommodation());
|
||||||
|
|
||||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
|
||||||
$bookingRepository->method('findOneBy')->willReturn($booking);
|
$bookingRepository->method('findOneBy')->willReturn($booking);
|
||||||
|
|
||||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
|
||||||
$linkSigner->method('isSessionAuthorized')->willReturn(true);
|
$linkSigner->method('isSessionAuthorized')->willReturn(true);
|
||||||
|
|
||||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
||||||
@@ -159,7 +157,7 @@ class IndexControllerTest extends TestCase
|
|||||||
$bookingRepository,
|
$bookingRepository,
|
||||||
$linkSigner,
|
$linkSigner,
|
||||||
$breakdownCalculator,
|
$breakdownCalculator,
|
||||||
$this->createMock(AccommodationBookingService::class),
|
$this->createStub(AccommodationBookingService::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
$request = Request::create('/groups/booking/offer/'.$booking->getUuid().'/view');
|
$request = Request::create('/groups/booking/offer/'.$booking->getUuid().'/view');
|
||||||
@@ -179,7 +177,7 @@ class IndexControllerTest extends TestCase
|
|||||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
||||||
$bookingRepository->method('findOneBy')->with(['uuid' => $booking->getUuid()])->willReturn($booking);
|
$bookingRepository->method('findOneBy')->with(['uuid' => $booking->getUuid()])->willReturn($booking);
|
||||||
|
|
||||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
|
||||||
$linkSigner->method('isSessionAuthorized')->willReturn(true);
|
$linkSigner->method('isSessionAuthorized')->willReturn(true);
|
||||||
|
|
||||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
||||||
@@ -207,17 +205,17 @@ class IndexControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$booking = new AccommodationBooking();
|
$booking = new AccommodationBooking();
|
||||||
|
|
||||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
|
||||||
$bookingRepository->method('findOneBy')->willReturn($booking);
|
$bookingRepository->method('findOneBy')->willReturn($booking);
|
||||||
|
|
||||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
|
||||||
$linkSigner->method('isSessionAuthorized')->willReturn(false);
|
$linkSigner->method('isSessionAuthorized')->willReturn(false);
|
||||||
|
|
||||||
$controller = new TestableOfferController(
|
$controller = new TestableOfferController(
|
||||||
$bookingRepository,
|
$bookingRepository,
|
||||||
$linkSigner,
|
$linkSigner,
|
||||||
$this->createMock(AccommodationBookingBreakdownCalculator::class),
|
$this->createStub(AccommodationBookingBreakdownCalculator::class),
|
||||||
$this->createMock(AccommodationBookingService::class),
|
$this->createStub(AccommodationBookingService::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $controller->view($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid().'/view'));
|
$response = $controller->view($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid().'/view'));
|
||||||
@@ -235,18 +233,18 @@ class IndexControllerTest extends TestCase
|
|||||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
||||||
$bookingRepository->method('findOneBy')->with(['uuid' => $booking->getUuid()])->willReturn($booking);
|
$bookingRepository->method('findOneBy')->with(['uuid' => $booking->getUuid()])->willReturn($booking);
|
||||||
|
|
||||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
|
||||||
$linkSigner->method('isSessionAuthorized')->willReturn(true);
|
$linkSigner->method('isSessionAuthorized')->willReturn(true);
|
||||||
|
|
||||||
$confirmationForm = $this->createMock(FormInterface::class);
|
$confirmationForm = $this->createStub(FormInterface::class);
|
||||||
$confirmationForm->method('handleRequest')->willReturnSelf();
|
$confirmationForm->method('handleRequest')->willReturnSelf();
|
||||||
$confirmationForm->method('isSubmitted')->willReturn(false);
|
$confirmationForm->method('isSubmitted')->willReturn(false);
|
||||||
|
|
||||||
$controller = new TestableOfferController(
|
$controller = new TestableOfferController(
|
||||||
$bookingRepository,
|
$bookingRepository,
|
||||||
$linkSigner,
|
$linkSigner,
|
||||||
$this->createMock(AccommodationBookingBreakdownCalculator::class),
|
$this->createStub(AccommodationBookingBreakdownCalculator::class),
|
||||||
$this->createMock(AccommodationBookingService::class),
|
$this->createStub(AccommodationBookingService::class),
|
||||||
$confirmationForm,
|
$confirmationForm,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -268,16 +266,16 @@ class IndexControllerTest extends TestCase
|
|||||||
$booking->setStatus(AccommodationBookingStatus::Open);
|
$booking->setStatus(AccommodationBookingStatus::Open);
|
||||||
$booking->setRemarks('Bitte Zimmer im EG');
|
$booking->setRemarks('Bitte Zimmer im EG');
|
||||||
|
|
||||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
|
||||||
$bookingRepository->method('findOneBy')->willReturn($booking);
|
$bookingRepository->method('findOneBy')->willReturn($booking);
|
||||||
|
|
||||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
|
||||||
$linkSigner->method('isSessionAuthorized')->willReturn(true);
|
$linkSigner->method('isSessionAuthorized')->willReturn(true);
|
||||||
|
|
||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::once())->method('acceptBooking')->with($booking, 'Bitte Zimmer im EG');
|
$bookingService->expects(self::once())->method('acceptBooking')->with($booking, 'Bitte Zimmer im EG');
|
||||||
|
|
||||||
$confirmationForm = $this->createMock(FormInterface::class);
|
$confirmationForm = $this->createStub(FormInterface::class);
|
||||||
$confirmationForm->method('handleRequest')->willReturnSelf();
|
$confirmationForm->method('handleRequest')->willReturnSelf();
|
||||||
$confirmationForm->method('isSubmitted')->willReturn(true);
|
$confirmationForm->method('isSubmitted')->willReturn(true);
|
||||||
$confirmationForm->method('isValid')->willReturn(true);
|
$confirmationForm->method('isValid')->willReturn(true);
|
||||||
@@ -285,7 +283,7 @@ class IndexControllerTest extends TestCase
|
|||||||
$controller = new TestableOfferController(
|
$controller = new TestableOfferController(
|
||||||
$bookingRepository,
|
$bookingRepository,
|
||||||
$linkSigner,
|
$linkSigner,
|
||||||
$this->createMock(AccommodationBookingBreakdownCalculator::class),
|
$this->createStub(AccommodationBookingBreakdownCalculator::class),
|
||||||
$bookingService,
|
$bookingService,
|
||||||
$confirmationForm,
|
$confirmationForm,
|
||||||
);
|
);
|
||||||
@@ -303,17 +301,17 @@ class IndexControllerTest extends TestCase
|
|||||||
$booking = new AccommodationBooking();
|
$booking = new AccommodationBooking();
|
||||||
$booking->setStatus(AccommodationBookingStatus::Open);
|
$booking->setStatus(AccommodationBookingStatus::Open);
|
||||||
|
|
||||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
|
||||||
$bookingRepository->method('findOneBy')->willReturn($booking);
|
$bookingRepository->method('findOneBy')->willReturn($booking);
|
||||||
|
|
||||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
|
||||||
$linkSigner->method('isSessionAuthorized')->willReturn(true);
|
$linkSigner->method('isSessionAuthorized')->willReturn(true);
|
||||||
|
|
||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
// No remark on the booking and none submitted: the empty string clears rather than keeps.
|
// No remark on the booking and none submitted: the empty string clears rather than keeps.
|
||||||
$bookingService->expects(self::once())->method('acceptBooking')->with($booking, '');
|
$bookingService->expects(self::once())->method('acceptBooking')->with($booking, '');
|
||||||
|
|
||||||
$confirmationForm = $this->createMock(FormInterface::class);
|
$confirmationForm = $this->createStub(FormInterface::class);
|
||||||
$confirmationForm->method('handleRequest')->willReturnSelf();
|
$confirmationForm->method('handleRequest')->willReturnSelf();
|
||||||
$confirmationForm->method('isSubmitted')->willReturn(true);
|
$confirmationForm->method('isSubmitted')->willReturn(true);
|
||||||
$confirmationForm->method('isValid')->willReturn(true);
|
$confirmationForm->method('isValid')->willReturn(true);
|
||||||
@@ -321,7 +319,7 @@ class IndexControllerTest extends TestCase
|
|||||||
$controller = new TestableOfferController(
|
$controller = new TestableOfferController(
|
||||||
$bookingRepository,
|
$bookingRepository,
|
||||||
$linkSigner,
|
$linkSigner,
|
||||||
$this->createMock(AccommodationBookingBreakdownCalculator::class),
|
$this->createStub(AccommodationBookingBreakdownCalculator::class),
|
||||||
$bookingService,
|
$bookingService,
|
||||||
$confirmationForm,
|
$confirmationForm,
|
||||||
);
|
);
|
||||||
@@ -339,16 +337,16 @@ class IndexControllerTest extends TestCase
|
|||||||
$booking = new AccommodationBooking();
|
$booking = new AccommodationBooking();
|
||||||
$booking->setStatus(AccommodationBookingStatus::Open);
|
$booking->setStatus(AccommodationBookingStatus::Open);
|
||||||
|
|
||||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
|
||||||
$bookingRepository->method('findOneBy')->willReturn($booking);
|
$bookingRepository->method('findOneBy')->willReturn($booking);
|
||||||
|
|
||||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
|
||||||
$linkSigner->method('isSessionAuthorized')->willReturn(true);
|
$linkSigner->method('isSessionAuthorized')->willReturn(true);
|
||||||
|
|
||||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||||
$bookingService->expects(self::never())->method('acceptBooking');
|
$bookingService->expects(self::never())->method('acceptBooking');
|
||||||
|
|
||||||
$confirmationForm = $this->createMock(FormInterface::class);
|
$confirmationForm = $this->createStub(FormInterface::class);
|
||||||
$confirmationForm->method('handleRequest')->willReturnSelf();
|
$confirmationForm->method('handleRequest')->willReturnSelf();
|
||||||
$confirmationForm->method('isSubmitted')->willReturn(true);
|
$confirmationForm->method('isSubmitted')->willReturn(true);
|
||||||
$confirmationForm->method('isValid')->willReturn(false);
|
$confirmationForm->method('isValid')->willReturn(false);
|
||||||
@@ -356,7 +354,7 @@ class IndexControllerTest extends TestCase
|
|||||||
$controller = new TestableOfferController(
|
$controller = new TestableOfferController(
|
||||||
$bookingRepository,
|
$bookingRepository,
|
||||||
$linkSigner,
|
$linkSigner,
|
||||||
$this->createMock(AccommodationBookingBreakdownCalculator::class),
|
$this->createStub(AccommodationBookingBreakdownCalculator::class),
|
||||||
$bookingService,
|
$bookingService,
|
||||||
$confirmationForm,
|
$confirmationForm,
|
||||||
);
|
);
|
||||||
@@ -373,17 +371,17 @@ class IndexControllerTest extends TestCase
|
|||||||
$booking = new AccommodationBooking();
|
$booking = new AccommodationBooking();
|
||||||
$booking->setStatus(AccommodationBookingStatus::Received);
|
$booking->setStatus(AccommodationBookingStatus::Received);
|
||||||
|
|
||||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
|
||||||
$bookingRepository->method('findOneBy')->willReturn($booking);
|
$bookingRepository->method('findOneBy')->willReturn($booking);
|
||||||
|
|
||||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
|
||||||
$linkSigner->method('isSessionAuthorized')->willReturn(true);
|
$linkSigner->method('isSessionAuthorized')->willReturn(true);
|
||||||
|
|
||||||
$controller = new TestableOfferController(
|
$controller = new TestableOfferController(
|
||||||
$bookingRepository,
|
$bookingRepository,
|
||||||
$linkSigner,
|
$linkSigner,
|
||||||
$this->createMock(AccommodationBookingBreakdownCalculator::class),
|
$this->createStub(AccommodationBookingBreakdownCalculator::class),
|
||||||
$this->createMock(AccommodationBookingService::class),
|
$this->createStub(AccommodationBookingService::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $controller->confirm($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid().'/confirm'));
|
$response = $controller->confirm($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid().'/confirm'));
|
||||||
@@ -395,17 +393,17 @@ class IndexControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$booking = new AccommodationBooking();
|
$booking = new AccommodationBooking();
|
||||||
|
|
||||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
|
||||||
$bookingRepository->method('findOneBy')->willReturn($booking);
|
$bookingRepository->method('findOneBy')->willReturn($booking);
|
||||||
|
|
||||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
|
||||||
$linkSigner->method('isSessionAuthorized')->willReturn(false);
|
$linkSigner->method('isSessionAuthorized')->willReturn(false);
|
||||||
|
|
||||||
$controller = new TestableOfferController(
|
$controller = new TestableOfferController(
|
||||||
$bookingRepository,
|
$bookingRepository,
|
||||||
$linkSigner,
|
$linkSigner,
|
||||||
$this->createMock(AccommodationBookingBreakdownCalculator::class),
|
$this->createStub(AccommodationBookingBreakdownCalculator::class),
|
||||||
$this->createMock(AccommodationBookingService::class),
|
$this->createStub(AccommodationBookingService::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $controller->confirm($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid().'/confirm'));
|
$response = $controller->confirm($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid().'/confirm'));
|
||||||
@@ -415,7 +413,7 @@ class IndexControllerTest extends TestCase
|
|||||||
|
|
||||||
public function testConfirmRedirectsForUnknownUuid(): void
|
public function testConfirmRedirectsForUnknownUuid(): void
|
||||||
{
|
{
|
||||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
$bookingRepository = $this->createStub(AccommodationBookingRepository::class);
|
||||||
$bookingRepository->method('findOneBy')->willReturn(null);
|
$bookingRepository->method('findOneBy')->willReturn(null);
|
||||||
|
|
||||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
||||||
@@ -424,8 +422,8 @@ class IndexControllerTest extends TestCase
|
|||||||
$controller = new TestableOfferController(
|
$controller = new TestableOfferController(
|
||||||
$bookingRepository,
|
$bookingRepository,
|
||||||
$linkSigner,
|
$linkSigner,
|
||||||
$this->createMock(AccommodationBookingBreakdownCalculator::class),
|
$this->createStub(AccommodationBookingBreakdownCalculator::class),
|
||||||
$this->createMock(AccommodationBookingService::class),
|
$this->createStub(AccommodationBookingService::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $controller->confirm('unknown-uuid', Request::create('/groups/booking/offer/unknown-uuid/confirm'));
|
$response = $controller->confirm('unknown-uuid', Request::create('/groups/booking/offer/unknown-uuid/confirm'));
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class DashboardWidgetRegistryTest extends TestCase
|
|||||||
|
|
||||||
private function provider(string $role, int $priority, ?DashboardWidget $widget): DashboardWidgetProviderInterface
|
private function provider(string $role, int $priority, ?DashboardWidget $widget): DashboardWidgetProviderInterface
|
||||||
{
|
{
|
||||||
$provider = $this->createMock(DashboardWidgetProviderInterface::class);
|
$provider = $this->createStub(DashboardWidgetProviderInterface::class);
|
||||||
$provider->method('getRequiredRole')->willReturn($role);
|
$provider->method('getRequiredRole')->willReturn($role);
|
||||||
$provider->method('getPriority')->willReturn($priority);
|
$provider->method('getPriority')->willReturn($priority);
|
||||||
$provider->method('build')->willReturn($widget);
|
$provider->method('build')->willReturn($widget);
|
||||||
@@ -93,7 +93,7 @@ class DashboardWidgetRegistryTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
private function securityGranting(array $grantedRoles): Security
|
private function securityGranting(array $grantedRoles): Security
|
||||||
{
|
{
|
||||||
$security = $this->createMock(Security::class);
|
$security = $this->createStub(Security::class);
|
||||||
$security->method('isGranted')->willReturnCallback(
|
$security->method('isGranted')->willReturnCallback(
|
||||||
static fn (mixed $role): bool => \in_array($role, $grantedRoles, true),
|
static fn (mixed $role): bool => \in_array($role, $grantedRoles, true),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -64,10 +64,10 @@ class PendingRoleApprovalsWidgetProviderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
private function provider(array $pending): PendingRoleApprovalsWidgetProvider
|
private function provider(array $pending): PendingRoleApprovalsWidgetProvider
|
||||||
{
|
{
|
||||||
$repository = $this->createMock(UserRepository::class);
|
$repository = $this->createStub(UserRepository::class);
|
||||||
$repository->method('findWithPendingRoles')->willReturn($pending);
|
$repository->method('findWithPendingRoles')->willReturn($pending);
|
||||||
|
|
||||||
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
$urlGenerator = $this->createStub(UrlGeneratorInterface::class);
|
||||||
$urlGenerator->method('generate')->willReturnCallback(
|
$urlGenerator->method('generate')->willReturnCallback(
|
||||||
static function (string $route, array $parameters = []): string {
|
static function (string $route, array $parameters = []): string {
|
||||||
$path = '/'.str_replace('_', '/', substr($route, \strlen('app_')));
|
$path = '/'.str_replace('_', '/', substr($route, \strlen('app_')));
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class RecentLogEntriesWidgetProviderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
private function provider(array $entries): RecentLogEntriesWidgetProvider
|
private function provider(array $entries): RecentLogEntriesWidgetProvider
|
||||||
{
|
{
|
||||||
$repository = $this->createMock(LogEntryRepository::class);
|
$repository = $this->createStub(LogEntryRepository::class);
|
||||||
$repository->method('findLatest')->willReturn($entries);
|
$repository->method('findLatest')->willReturn($entries);
|
||||||
|
|
||||||
return new RecentLogEntriesWidgetProvider($repository, $this->urlGenerator());
|
return new RecentLogEntriesWidgetProvider($repository, $this->urlGenerator());
|
||||||
@@ -74,7 +74,7 @@ class RecentLogEntriesWidgetProviderTest extends TestCase
|
|||||||
|
|
||||||
private function urlGenerator(): UrlGeneratorInterface
|
private function urlGenerator(): UrlGeneratorInterface
|
||||||
{
|
{
|
||||||
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
$urlGenerator = $this->createStub(UrlGeneratorInterface::class);
|
||||||
$urlGenerator->method('generate')->willReturnCallback(
|
$urlGenerator->method('generate')->willReturnCallback(
|
||||||
static fn (string $route): string => '/'.str_replace('_', '/', substr($route, \strlen('app_'))),
|
static fn (string $route): string => '/'.str_replace('_', '/', substr($route, \strlen('app_'))),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace App\Tests\Entity\Groups;
|
|||||||
use App\Entity\Groups\AccommodationBooking;
|
use App\Entity\Groups\AccommodationBooking;
|
||||||
use App\Enum\Groups\AccommodationBookingOrigin;
|
use App\Enum\Groups\AccommodationBookingOrigin;
|
||||||
use App\Enum\Groups\AccommodationBookingStatus;
|
use App\Enum\Groups\AccommodationBookingStatus;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class AccommodationBookingTest extends TestCase
|
class AccommodationBookingTest extends TestCase
|
||||||
@@ -14,9 +15,8 @@ class AccommodationBookingTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* The label is what the backoffice prints next to the status, so it must never
|
* The label is what the backoffice prints next to the status, so it must never
|
||||||
* contradict it — "Angebot · Bestätigt" is the shape of mistake this replaces.
|
* contradict it — "Angebot · Bestätigt" is the shape of mistake this replaces.
|
||||||
*
|
|
||||||
* @dataProvider statusesBeforeTheCustomerCommits
|
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('statusesBeforeTheCustomerCommits')]
|
||||||
public function testARecordIsCalledAnOfferUntilTheCustomerCommits(AccommodationBookingStatus $status): void
|
public function testARecordIsCalledAnOfferUntilTheCustomerCommits(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
$booking = new AccommodationBooking();
|
$booking = new AccommodationBooking();
|
||||||
@@ -36,9 +36,7 @@ class AccommodationBookingTest extends TestCase
|
|||||||
yield 'open' => [AccommodationBookingStatus::Open];
|
yield 'open' => [AccommodationBookingStatus::Open];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('statusesAfterTheCustomerCommits')]
|
||||||
* @dataProvider statusesAfterTheCustomerCommits
|
|
||||||
*/
|
|
||||||
public function testARecordIsCalledABookingOnceTheCustomerHasCommitted(AccommodationBookingStatus $status): void
|
public function testARecordIsCalledABookingOnceTheCustomerHasCommitted(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
$booking = new AccommodationBooking();
|
$booking = new AccommodationBooking();
|
||||||
|
|||||||
@@ -104,20 +104,20 @@ class AccessDeniedListenerTest extends TestCase
|
|||||||
|
|
||||||
private function dispatch(Request $request, ?UserInterface $user): ExceptionEvent
|
private function dispatch(Request $request, ?UserInterface $user): ExceptionEvent
|
||||||
{
|
{
|
||||||
$security = $this->createMock(Security::class);
|
$security = $this->createStub(Security::class);
|
||||||
$security->method('getUser')->willReturn($user);
|
$security->method('getUser')->willReturn($user);
|
||||||
|
|
||||||
$resolver = $this->createMock(DefaultRouteResolver::class);
|
$resolver = $this->createStub(DefaultRouteResolver::class);
|
||||||
$resolver->method('resolveUrl')->willReturn('/admin/dashboard');
|
$resolver->method('resolveUrl')->willReturn('/admin/dashboard');
|
||||||
|
|
||||||
$listener = new AccessDeniedListener(
|
$listener = new AccessDeniedListener(
|
||||||
$security,
|
$security,
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
$resolver,
|
$resolver,
|
||||||
);
|
);
|
||||||
|
|
||||||
$event = new ExceptionEvent(
|
$event = new ExceptionEvent(
|
||||||
$this->createMock(HttpKernelInterface::class),
|
$this->createStub(HttpKernelInterface::class),
|
||||||
$request,
|
$request,
|
||||||
HttpKernelInterface::MAIN_REQUEST,
|
HttpKernelInterface::MAIN_REQUEST,
|
||||||
new AccessDeniedException(),
|
new AccessDeniedException(),
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class DomainThemeListenerTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->kernel = $this->createMock(HttpKernelInterface::class);
|
$this->kernel = $this->createStub(HttpKernelInterface::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSetsThemeAttributeForMatchingDomain(): void
|
public function testSetsThemeAttributeForMatchingDomain(): void
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class AccommodationBookingChangeAccommodationTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$fields = [];
|
$fields = [];
|
||||||
|
|
||||||
$builder = $this->createMock(FormBuilderInterface::class);
|
$builder = $this->createStub(FormBuilderInterface::class);
|
||||||
$builder->method('add')->willReturnCallback(
|
$builder->method('add')->willReturnCallback(
|
||||||
static function (string $name, ?string $type = null, array $fieldOptions = []) use (&$fields, $builder) {
|
static function (string $name, ?string $type = null, array $fieldOptions = []) use (&$fields, $builder) {
|
||||||
$fields[$name] = $fieldOptions;
|
$fields[$name] = $fieldOptions;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class AccommodationBookingCreateTypeTest extends TestCase
|
|||||||
{
|
{
|
||||||
$names = [];
|
$names = [];
|
||||||
|
|
||||||
$builder = $this->createMock(FormBuilderInterface::class);
|
$builder = $this->createStub(FormBuilderInterface::class);
|
||||||
$builder->method('add')->willReturnCallback(static function (string $name) use (&$names, $builder) {
|
$builder->method('add')->willReturnCallback(static function (string $name) use (&$names, $builder) {
|
||||||
$names[] = $name;
|
$names[] = $name;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace App\Tests\Form\Admin\Groups;
|
|||||||
use App\Entity\Groups\AccommodationBooking;
|
use App\Entity\Groups\AccommodationBooking;
|
||||||
use App\Enum\Groups\AccommodationBookingStatus;
|
use App\Enum\Groups\AccommodationBookingStatus;
|
||||||
use App\Form\Admin\Groups\AccommodationBookingType;
|
use App\Form\Admin\Groups\AccommodationBookingType;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
@@ -17,17 +18,13 @@ use Symfony\Component\Validator\Validation;
|
|||||||
|
|
||||||
class AccommodationBookingTypeTest extends TestCase
|
class AccommodationBookingTypeTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
#[DataProvider('statusesWithoutMandatoryFields')]
|
||||||
* @dataProvider statusesWithoutMandatoryFields
|
|
||||||
*/
|
|
||||||
public function testDraftAndDiscardedAreValidatedWithoutTheEditGroup(AccommodationBookingStatus $status): void
|
public function testDraftAndDiscardedAreValidatedWithoutTheEditGroup(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
self::assertSame(['Default'], $this->resolveValidationGroups($status));
|
self::assertSame(['Default'], $this->resolveValidationGroups($status));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('customerFacingStatuses')]
|
||||||
* @dataProvider customerFacingStatuses
|
|
||||||
*/
|
|
||||||
public function testCustomerFacingStatusesAddTheEditGroup(AccommodationBookingStatus $status): void
|
public function testCustomerFacingStatusesAddTheEditGroup(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
self::assertSame(['Default', 'edit'], $this->resolveValidationGroups($status));
|
self::assertSame(['Default', 'edit'], $this->resolveValidationGroups($status));
|
||||||
@@ -52,9 +49,7 @@ class AccommodationBookingTypeTest extends TestCase
|
|||||||
yield 'confirmed' => [AccommodationBookingStatus::Confirmed];
|
yield 'confirmed' => [AccommodationBookingStatus::Confirmed];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('statusesWithoutMandatoryFields')]
|
||||||
* @dataProvider statusesWithoutMandatoryFields
|
|
||||||
*/
|
|
||||||
public function testEmptyContactDataPassesValidation(AccommodationBookingStatus $status): void
|
public function testEmptyContactDataPassesValidation(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
$booking = new AccommodationBooking();
|
$booking = new AccommodationBooking();
|
||||||
@@ -89,7 +84,7 @@ class AccommodationBookingTypeTest extends TestCase
|
|||||||
$booking = new AccommodationBooking();
|
$booking = new AccommodationBooking();
|
||||||
$booking->setStatus($status);
|
$booking->setStatus($status);
|
||||||
|
|
||||||
$form = $this->createMock(FormInterface::class);
|
$form = $this->createStub(FormInterface::class);
|
||||||
$form->method('getData')->willReturn($booking);
|
$form->method('getData')->willReturn($booking);
|
||||||
|
|
||||||
return ($resolver->resolve()['validation_groups'])($form);
|
return ($resolver->resolve()['validation_groups'])($form);
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ declare(strict_types=1);
|
|||||||
namespace App\Tests\Form\Model;
|
namespace App\Tests\Form\Model;
|
||||||
|
|
||||||
use App\BusProNet\Constants;
|
use App\BusProNet\Constants;
|
||||||
use App\BusProNet\Model\Booking;
|
|
||||||
use App\BusProNet\Model\Address;
|
use App\BusProNet\Model\Address;
|
||||||
use App\Form\Model\AddressDto;
|
use App\BusProNet\Model\Booking;
|
||||||
use App\BusProNet\Model\Service;
|
|
||||||
use App\BusProNet\Model\Insurance;
|
use App\BusProNet\Model\Insurance;
|
||||||
|
use App\BusProNet\Model\Service;
|
||||||
use App\BusProNet\Model\Travel;
|
use App\BusProNet\Model\Travel;
|
||||||
use App\BusProNet\XmlLoader\AgencyLoader;
|
use App\BusProNet\XmlLoader\AgencyLoader;
|
||||||
|
use App\Form\Model\AddressDto;
|
||||||
use App\Form\Model\BookingDto;
|
use App\Form\Model\BookingDto;
|
||||||
use App\Form\Model\ParticipantDto;
|
use App\Form\Model\ParticipantDto;
|
||||||
use App\Form\Model\ParticipantEditDto;
|
use App\Form\Model\ParticipantEditDto;
|
||||||
@@ -47,10 +47,10 @@ class ParticipantEditDtoTest extends TestCase
|
|||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
// Create mock services for validator dependencies
|
// Create mock services for validator dependencies
|
||||||
$mockVoucherService = $this->createMock(VoucherValidator::class);
|
$mockVoucherService = $this->createStub(VoucherValidator::class);
|
||||||
$mockPriceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
$mockPriceCalculatorService = $this->createStub(BookingPriceCalculator::class);
|
||||||
$mockParticipantEligibilityChecker = $this->createMock(ParticipantEligibilityChecker::class);
|
$mockParticipantEligibilityChecker = $this->createStub(ParticipantEligibilityChecker::class);
|
||||||
$mockServiceAgeEvaluator = $this->createMock(ServiceAgeEvaluator::class);
|
$mockServiceAgeEvaluator = $this->createStub(ServiceAgeEvaluator::class);
|
||||||
|
|
||||||
// Ski pass validation is exercised against the real gate, not a mock: which participant
|
// Ski pass validation is exercised against the real gate, not a mock: which participant
|
||||||
// needs a pass is exactly the behaviour under test here.
|
// needs a pass is exactly the behaviour under test here.
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ class PersonalDataTypeTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
private function createForm(PersonalData $personalData, array $options = []): FormInterface
|
private function createForm(PersonalData $personalData, array $options = []): FormInterface
|
||||||
{
|
{
|
||||||
$countries = $this->createMock(CountryDataProvider::class);
|
$countries = $this->createStub(CountryDataProvider::class);
|
||||||
$countries->method('getAll')->willReturn([]);
|
$countries->method('getAll')->willReturn([]);
|
||||||
|
|
||||||
return Forms::createFormFactoryBuilder()
|
return Forms::createFormFactoryBuilder()
|
||||||
|
|||||||
@@ -28,17 +28,17 @@ class ParticipantFieldOptionsProviderBabyTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
$this->serviceAvailabilityCalculator = $this->createStub(ServiceAvailabilityCalculator::class);
|
||||||
// These tests target age filtering, so availability filtering passes everything through
|
// These tests target age filtering, so availability filtering passes everything through
|
||||||
// unless a test stubs it explicitly
|
// unless a test stubs it explicitly
|
||||||
$this->serviceAvailabilityCalculator
|
$this->serviceAvailabilityCalculator
|
||||||
->method('filterAvailableServices')
|
->method('filterAvailableServices')
|
||||||
->willReturnArgument(0)
|
->willReturnArgument(0)
|
||||||
;
|
;
|
||||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
$insuranceService = $this->createStub(InsuranceManager::class);
|
||||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
$priceCalculatorService = $this->createStub(BookingPriceCalculator::class);
|
||||||
$serviceLabelFormatter = new ServiceLabelFormatter();
|
$serviceLabelFormatter = new ServiceLabelFormatter();
|
||||||
$translator = $this->createMock(TranslatorInterface::class);
|
$translator = $this->createStub(TranslatorInterface::class);
|
||||||
$translator->method('trans')->willReturnCallback(
|
$translator->method('trans')->willReturnCallback(
|
||||||
function (string $message, array $parameters = []): string {
|
function (string $message, array $parameters = []): string {
|
||||||
return match ($message) {
|
return match ($message) {
|
||||||
|
|||||||
@@ -29,13 +29,13 @@ class ParticipantFieldOptionsProviderInsuranceTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
$serviceAvailabilityCalculator = $this->createStub(ServiceAvailabilityCalculator::class);
|
||||||
// InsuranceManager is stateless - use the real implementation so actual
|
// InsuranceManager is stateless - use the real implementation so actual
|
||||||
// eligibility/price-tier filtering runs, not a stubbed-out mock.
|
// eligibility/price-tier filtering runs, not a stubbed-out mock.
|
||||||
$insuranceService = new InsuranceManager();
|
$insuranceService = new InsuranceManager();
|
||||||
$this->priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
$this->priceCalculatorService = $this->createStub(BookingPriceCalculator::class);
|
||||||
$serviceLabelFormatter = new ServiceLabelFormatter();
|
$serviceLabelFormatter = new ServiceLabelFormatter();
|
||||||
$translator = $this->createMock(TranslatorInterface::class);
|
$translator = $this->createStub(TranslatorInterface::class);
|
||||||
$translator->method('trans')->willReturnCallback(fn (string $message) => $message);
|
$translator->method('trans')->willReturnCallback(fn (string $message) => $message);
|
||||||
|
|
||||||
$this->provider = new ParticipantFieldOptionsProvider(
|
$this->provider = new ParticipantFieldOptionsProvider(
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ class ParticipantFieldOptionsProviderMandatoryServiceTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
$serviceAvailabilityCalculator = $this->createStub(ServiceAvailabilityCalculator::class);
|
||||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
$insuranceService = $this->createStub(InsuranceManager::class);
|
||||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
$priceCalculatorService = $this->createStub(BookingPriceCalculator::class);
|
||||||
$serviceLabelFormatter = new ServiceLabelFormatter();
|
$serviceLabelFormatter = new ServiceLabelFormatter();
|
||||||
$translator = $this->createMock(TranslatorInterface::class);
|
$translator = $this->createStub(TranslatorInterface::class);
|
||||||
|
|
||||||
$this->provider = new ParticipantFieldOptionsProvider(
|
$this->provider = new ParticipantFieldOptionsProvider(
|
||||||
$serviceAvailabilityCalculator,
|
$serviceAvailabilityCalculator,
|
||||||
@@ -159,10 +159,10 @@ class ParticipantFieldOptionsProviderMandatoryServiceTest extends TestCase
|
|||||||
|
|
||||||
$provider = new ParticipantFieldOptionsProvider(
|
$provider = new ParticipantFieldOptionsProvider(
|
||||||
$serviceAvailabilityCalculator,
|
$serviceAvailabilityCalculator,
|
||||||
$this->createMock(InsuranceManager::class),
|
$this->createStub(InsuranceManager::class),
|
||||||
$this->createMock(BookingPriceCalculator::class),
|
$this->createStub(BookingPriceCalculator::class),
|
||||||
new ServiceLabelFormatter(),
|
new ServiceLabelFormatter(),
|
||||||
$this->createMock(TranslatorInterface::class)
|
$this->createStub(TranslatorInterface::class)
|
||||||
);
|
);
|
||||||
|
|
||||||
$options = $provider->getFieldOptions('parking', $bookingDto, 0);
|
$options = $provider->getFieldOptions('parking', $bookingDto, 0);
|
||||||
|
|||||||
@@ -30,13 +30,13 @@ class ParticipantFieldOptionsProviderSkiPassAvailabilityTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$translator = $this->createMock(TranslatorInterface::class);
|
$translator = $this->createStub(TranslatorInterface::class);
|
||||||
$translator->method('trans')->willReturnArgument(0);
|
$translator->method('trans')->willReturnArgument(0);
|
||||||
|
|
||||||
$this->provider = new ParticipantFieldOptionsProvider(
|
$this->provider = new ParticipantFieldOptionsProvider(
|
||||||
new ServiceAvailabilityCalculator(),
|
new ServiceAvailabilityCalculator(),
|
||||||
$this->createMock(InsuranceManager::class),
|
$this->createStub(InsuranceManager::class),
|
||||||
$this->createMock(BookingPriceCalculator::class),
|
$this->createStub(BookingPriceCalculator::class),
|
||||||
new ServiceLabelFormatter(),
|
new ServiceLabelFormatter(),
|
||||||
$translator
|
$translator
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -12,32 +12,46 @@ use App\Form\Service\ParticipantInsuranceFieldHandler;
|
|||||||
use App\Service\BookingPriceCalculator;
|
use App\Service\BookingPriceCalculator;
|
||||||
use App\Service\FamilyInsuranceAvailabilityChecker;
|
use App\Service\FamilyInsuranceAvailabilityChecker;
|
||||||
use App\Service\InsuranceManager;
|
use App\Service\InsuranceManager;
|
||||||
|
use PHPUnit\Framework\MockObject\Stub;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class ParticipantInsuranceFieldHandlerTest extends TestCase
|
class ParticipantInsuranceFieldHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
private ParticipantInsuranceFieldHandler $handler;
|
private ?ParticipantInsuranceFieldHandler $handler = null;
|
||||||
private InsuranceManager $insuranceService;
|
private InsuranceManager $insuranceService;
|
||||||
private BookingPriceCalculator $priceCalculatorService;
|
private BookingPriceCalculator $priceCalculatorService;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->insuranceService = $this->createMock(InsuranceManager::class);
|
$this->useInsuranceService($this->createStub(InsuranceManager::class));
|
||||||
$this->priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
|
||||||
|
|
||||||
// Mock getSelectableInsurances to return input array
|
$this->priceCalculatorService = $this->createStub(BookingPriceCalculator::class);
|
||||||
$this->insuranceService->method('getSelectableInsurances')
|
|
||||||
->willReturnCallback(fn (Travel $travel) => $travel->insurances ?? []);
|
|
||||||
|
|
||||||
// Mock price calculator to return a default price
|
// Price calculator returns a default price
|
||||||
$this->priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')
|
$this->priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')
|
||||||
->willReturn(500.0);
|
->willReturn(500.0);
|
||||||
$this->priceCalculatorService->method('resolveInsuranceTravelPrice')
|
$this->priceCalculatorService->method('resolveInsuranceTravelPrice')
|
||||||
->willReturn(500.0);
|
->willReturn(500.0);
|
||||||
|
}
|
||||||
|
|
||||||
// Real checker over the mocked collaborators - the selection-time recording below is
|
/**
|
||||||
|
* Installs the insurance service every test runs against, applying the
|
||||||
|
* getSelectableInsurances() pass-through they all rely on. Tests that set
|
||||||
|
* expectations pass a mock in here instead of the setUp() stub.
|
||||||
|
*/
|
||||||
|
private function useInsuranceService(InsuranceManager&Stub $insuranceService): void
|
||||||
|
{
|
||||||
|
$insuranceService->method('getSelectableInsurances')
|
||||||
|
->willReturnCallback(fn (Travel $travel) => $travel->insurances ?? []);
|
||||||
|
|
||||||
|
$this->insuranceService = $insuranceService;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function handler(): ParticipantInsuranceFieldHandler
|
||||||
|
{
|
||||||
|
// Real checker over the doubled collaborators - the selection-time recording below is
|
||||||
// only meaningful against the actual "is a family insurance available" definition
|
// only meaningful against the actual "is a family insurance available" definition
|
||||||
$this->handler = new ParticipantInsuranceFieldHandler(
|
return $this->handler ??= new ParticipantInsuranceFieldHandler(
|
||||||
$this->insuranceService,
|
$this->insuranceService,
|
||||||
$this->priceCalculatorService,
|
$this->priceCalculatorService,
|
||||||
new FamilyInsuranceAvailabilityChecker($this->insuranceService, $this->priceCalculatorService),
|
new FamilyInsuranceAvailabilityChecker($this->insuranceService, $this->priceCalculatorService),
|
||||||
@@ -46,12 +60,12 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
|||||||
|
|
||||||
public function testGetFieldName(): void
|
public function testGetFieldName(): void
|
||||||
{
|
{
|
||||||
$this->assertEquals('insurance', $this->handler->getFieldName());
|
$this->assertEquals('insurance', $this->handler()->getFieldName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetDependencies(): void
|
public function testGetDependencies(): void
|
||||||
{
|
{
|
||||||
$dependencies = $this->handler->getDependencies();
|
$dependencies = $this->handler()->getDependencies();
|
||||||
|
|
||||||
// Insurance handler depends on all price-affecting fields to ensure accurate reassignment
|
// Insurance handler depends on all price-affecting fields to ensure accurate reassignment
|
||||||
$expectedDependencies = [
|
$expectedDependencies = [
|
||||||
@@ -72,14 +86,14 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
|||||||
|
|
||||||
public function testShouldProcessReturnsTrueInCreateMode(): void
|
public function testShouldProcessReturnsTrueInCreateMode(): void
|
||||||
{
|
{
|
||||||
$result = $this->handler->shouldProcess([], BookingDto::MODE_CREATE, 0);
|
$result = $this->handler()->shouldProcess([], BookingDto::MODE_CREATE, 0);
|
||||||
|
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testShouldProcessReturnsFalseInEditMode(): void
|
public function testShouldProcessReturnsFalseInEditMode(): void
|
||||||
{
|
{
|
||||||
$result = $this->handler->shouldProcess([], BookingDto::MODE_EDIT, 0);
|
$result = $this->handler()->shouldProcess([], BookingDto::MODE_EDIT, 0);
|
||||||
|
|
||||||
$this->assertFalse($result, 'Insurance handler should not process in edit mode as API does not return insurance data');
|
$this->assertFalse($result, 'Insurance handler should not process in edit mode as API does not return insurance data');
|
||||||
}
|
}
|
||||||
@@ -89,7 +103,7 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
|||||||
$bookingDto = $this->createMockBookingDto();
|
$bookingDto = $this->createMockBookingDto();
|
||||||
$bookingDto->method('getParticipant')->with(0)->willReturn(null);
|
$bookingDto->method('getParticipant')->with(0)->willReturn(null);
|
||||||
|
|
||||||
$this->handler->processField(['insurance' => '123'], $bookingDto, 0);
|
$this->handler()->processField(['insurance' => '123'], $bookingDto, 0);
|
||||||
|
|
||||||
// No assertions needed - just ensure no exceptions are thrown
|
// No assertions needed - just ensure no exceptions are thrown
|
||||||
$this->addToAssertionCount(1);
|
$this->addToAssertionCount(1);
|
||||||
@@ -107,7 +121,7 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
|||||||
$bookingDto->method('getParticipant')->with(0)->willReturn($participant);
|
$bookingDto->method('getParticipant')->with(0)->willReturn($participant);
|
||||||
$bookingDto->travel = $travel;
|
$bookingDto->travel = $travel;
|
||||||
|
|
||||||
$this->handler->processField(['insurance' => null], $bookingDto, 0);
|
$this->handler()->processField(['insurance' => null], $bookingDto, 0);
|
||||||
|
|
||||||
$this->assertNull($participant->insurance);
|
$this->assertNull($participant->insurance);
|
||||||
}
|
}
|
||||||
@@ -124,7 +138,7 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
|||||||
$bookingDto->method('getParticipant')->with(0)->willReturn($participant);
|
$bookingDto->method('getParticipant')->with(0)->willReturn($participant);
|
||||||
$bookingDto->travel = $travel;
|
$bookingDto->travel = $travel;
|
||||||
|
|
||||||
$this->handler->processField(['insurance' => ''], $bookingDto, 0);
|
$this->handler()->processField(['insurance' => ''], $bookingDto, 0);
|
||||||
|
|
||||||
$this->assertNull($participant->insurance);
|
$this->assertNull($participant->insurance);
|
||||||
}
|
}
|
||||||
@@ -141,7 +155,7 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
|||||||
$bookingDto->method('getParticipant')->with(0)->willReturn($participant);
|
$bookingDto->method('getParticipant')->with(0)->willReturn($participant);
|
||||||
$bookingDto->travel = $travel;
|
$bookingDto->travel = $travel;
|
||||||
|
|
||||||
$this->handler->processField([], $bookingDto, 0);
|
$this->handler()->processField([], $bookingDto, 0);
|
||||||
|
|
||||||
$this->assertNull($participant->insurance);
|
$this->assertNull($participant->insurance);
|
||||||
}
|
}
|
||||||
@@ -156,13 +170,15 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
|||||||
$bookingDto->method('getParticipant')->with(0)->willReturn($participant);
|
$bookingDto->method('getParticipant')->with(0)->willReturn($participant);
|
||||||
$bookingDto->travel = $travel;
|
$bookingDto->travel = $travel;
|
||||||
|
|
||||||
$this->handler->processField(['insurance' => '123'], $bookingDto, 0);
|
$this->handler()->processField(['insurance' => '123'], $bookingDto, 0);
|
||||||
|
|
||||||
$this->assertNull($participant->insurance);
|
$this->assertNull($participant->insurance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testProcessFieldSetsInsuranceWhenEligible(): void
|
public function testProcessFieldSetsInsuranceWhenEligible(): void
|
||||||
{
|
{
|
||||||
|
$this->useInsuranceService($this->createMock(InsuranceManager::class));
|
||||||
|
|
||||||
$insurance = $this->createInsurance('123');
|
$insurance = $this->createInsurance('123');
|
||||||
$participant = new ParticipantDto();
|
$participant = new ParticipantDto();
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
@@ -178,13 +194,15 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
|||||||
->with([$insurance], $participant, $bookingDto, 500.0)
|
->with([$insurance], $participant, $bookingDto, 500.0)
|
||||||
->willReturn([$insurance]);
|
->willReturn([$insurance]);
|
||||||
|
|
||||||
$this->handler->processField(['insurance' => '123'], $bookingDto, 0);
|
$this->handler()->processField(['insurance' => '123'], $bookingDto, 0);
|
||||||
|
|
||||||
$this->assertSame($insurance, $participant->insurance);
|
$this->assertSame($insurance, $participant->insurance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testProcessFieldClearsInsuranceWhenNotEligible(): void
|
public function testProcessFieldClearsInsuranceWhenNotEligible(): void
|
||||||
{
|
{
|
||||||
|
$this->useInsuranceService($this->createMock(InsuranceManager::class));
|
||||||
|
|
||||||
$insurance = $this->createInsurance('123');
|
$insurance = $this->createInsurance('123');
|
||||||
$participant = new ParticipantDto();
|
$participant = new ParticipantDto();
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
@@ -200,13 +218,15 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
|||||||
->with([$insurance], $participant, $bookingDto, 500.0)
|
->with([$insurance], $participant, $bookingDto, 500.0)
|
||||||
->willReturn([]); // Not eligible
|
->willReturn([]); // Not eligible
|
||||||
|
|
||||||
$this->handler->processField(['insurance' => '123'], $bookingDto, 0);
|
$this->handler()->processField(['insurance' => '123'], $bookingDto, 0);
|
||||||
|
|
||||||
$this->assertNull($participant->insurance);
|
$this->assertNull($participant->insurance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testProcessFieldSwitchingToNewInsuranceIsNotOverwrittenByStaleResubmissionCheck(): void
|
public function testProcessFieldSwitchingToNewInsuranceIsNotOverwrittenByStaleResubmissionCheck(): void
|
||||||
{
|
{
|
||||||
|
$this->useInsuranceService($this->createMock(InsuranceManager::class));
|
||||||
|
|
||||||
// Regression: switching from one already-selected insurance to a different one must
|
// Regression: switching from one already-selected insurance to a different one must
|
||||||
// not be re-validated (and potentially overwritten) against the OLD, now-stale
|
// not be re-validated (and potentially overwritten) against the OLD, now-stale
|
||||||
// insurance by the "form resubmission" block afterward.
|
// insurance by the "form resubmission" block afterward.
|
||||||
@@ -230,13 +250,15 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
|||||||
->method('getEligibleInsurances')
|
->method('getEligibleInsurances')
|
||||||
->willReturn([$newInsurance]);
|
->willReturn([$newInsurance]);
|
||||||
|
|
||||||
$this->handler->processField(['insurance' => '2'], $bookingDto, 0);
|
$this->handler()->processField(['insurance' => '2'], $bookingDto, 0);
|
||||||
|
|
||||||
$this->assertSame($newInsurance, $participant->insurance);
|
$this->assertSame($newInsurance, $participant->insurance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testProcessFieldWorksWithStringAndIntegerIds(): void
|
public function testProcessFieldWorksWithStringAndIntegerIds(): void
|
||||||
{
|
{
|
||||||
|
$this->useInsuranceService($this->createMock(InsuranceManager::class));
|
||||||
|
|
||||||
$insurance = $this->createInsurance(123); // Integer ID
|
$insurance = $this->createInsurance(123); // Integer ID
|
||||||
$participant = new ParticipantDto();
|
$participant = new ParticipantDto();
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
@@ -251,7 +273,7 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
|||||||
->method('getEligibleInsurances')
|
->method('getEligibleInsurances')
|
||||||
->willReturn([$insurance]);
|
->willReturn([$insurance]);
|
||||||
|
|
||||||
$this->handler->processField(['insurance' => '123'], $bookingDto, 0); // String selection
|
$this->handler()->processField(['insurance' => '123'], $bookingDto, 0); // String selection
|
||||||
|
|
||||||
$this->assertSame($insurance, $participant->insurance);
|
$this->assertSame($insurance, $participant->insurance);
|
||||||
}
|
}
|
||||||
@@ -266,7 +288,7 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
|||||||
$bookingDto->method('getParticipant')->with(0)->willReturn($participant);
|
$bookingDto->method('getParticipant')->with(0)->willReturn($participant);
|
||||||
$bookingDto->travel = $travel;
|
$bookingDto->travel = $travel;
|
||||||
|
|
||||||
$this->handler->processField(['insurance' => '123'], $bookingDto, 0);
|
$this->handler()->processField(['insurance' => '123'], $bookingDto, 0);
|
||||||
|
|
||||||
$this->assertNull($participant->insurance);
|
$this->assertNull($participant->insurance);
|
||||||
}
|
}
|
||||||
@@ -281,7 +303,7 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
|||||||
$bookingDto->method('getParticipant')->with(0)->willReturn($participant);
|
$bookingDto->method('getParticipant')->with(0)->willReturn($participant);
|
||||||
$bookingDto->travel = $travel;
|
$bookingDto->travel = $travel;
|
||||||
|
|
||||||
$this->handler->processField(['insurance' => '123'], $bookingDto, 0);
|
$this->handler()->processField(['insurance' => '123'], $bookingDto, 0);
|
||||||
|
|
||||||
$this->assertNull($participant->insurance);
|
$this->assertNull($participant->insurance);
|
||||||
}
|
}
|
||||||
@@ -306,7 +328,7 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
|||||||
|
|
||||||
$this->insuranceService->method('getEligibleInsurances')->willReturn([$nonFamilyInsurance]);
|
$this->insuranceService->method('getEligibleInsurances')->willReturn([$nonFamilyInsurance]);
|
||||||
|
|
||||||
$this->handler->processField(['insurance' => '1'], $bookingDto, 0);
|
$this->handler()->processField(['insurance' => '1'], $bookingDto, 0);
|
||||||
|
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$bookingDto->applicantInsuranceChosenWhileFamilyIneligible,
|
$bookingDto->applicantInsuranceChosenWhileFamilyIneligible,
|
||||||
@@ -346,7 +368,7 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
|||||||
fn (array $insurances) => $insurances
|
fn (array $insurances) => $insurances
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->handler->processField(['insurance' => '1'], $bookingDto, 0);
|
$this->handler()->processField(['insurance' => '1'], $bookingDto, 0);
|
||||||
|
|
||||||
$this->assertFalse(
|
$this->assertFalse(
|
||||||
$bookingDto->applicantInsuranceChosenWhileFamilyIneligible,
|
$bookingDto->applicantInsuranceChosenWhileFamilyIneligible,
|
||||||
@@ -389,7 +411,7 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
|||||||
fn (array $insurances) => array_values(array_filter($insurances, fn ($i) => false === $i->familyInsurance))
|
fn (array $insurances) => array_values(array_filter($insurances, fn ($i) => false === $i->familyInsurance))
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->handler->processField(['insurance' => '1'], $bookingDto, 0);
|
$this->handler()->processField(['insurance' => '1'], $bookingDto, 0);
|
||||||
|
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$bookingDto->applicantInsuranceChosenWhileFamilyIneligible,
|
$bookingDto->applicantInsuranceChosenWhileFamilyIneligible,
|
||||||
@@ -399,9 +421,9 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
|||||||
|
|
||||||
public function testGetFieldStateModificationsReturnsEmptyArray(): void
|
public function testGetFieldStateModificationsReturnsEmptyArray(): void
|
||||||
{
|
{
|
||||||
$bookingDto = $this->createMockBookingDto();
|
$bookingDto = $this->createStub(BookingDto::class);
|
||||||
|
|
||||||
$result = $this->handler->getFieldStateModifications([], $bookingDto, 0);
|
$result = $this->handler()->getFieldStateModifications([], $bookingDto, 0);
|
||||||
|
|
||||||
$this->assertIsArray($result);
|
$this->assertIsArray($result);
|
||||||
$this->assertEmpty($result);
|
$this->assertEmpty($result);
|
||||||
@@ -409,7 +431,7 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
|||||||
|
|
||||||
public function testGetAffectedFieldNamesReturnsEmptyArray(): void
|
public function testGetAffectedFieldNamesReturnsEmptyArray(): void
|
||||||
{
|
{
|
||||||
$result = $this->handler->getAffectedFieldNames();
|
$result = $this->handler()->getAffectedFieldNames();
|
||||||
|
|
||||||
$this->assertIsArray($result);
|
$this->assertIsArray($result);
|
||||||
$this->assertEmpty($result);
|
$this->assertEmpty($result);
|
||||||
|
|||||||
@@ -4,14 +4,15 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Tests\Form\Service;
|
namespace App\Tests\Form\Service;
|
||||||
|
|
||||||
|
use App\BusProNet\Constants;
|
||||||
use App\BusProNet\Model\Service;
|
use App\BusProNet\Model\Service;
|
||||||
use App\BusProNet\Model\Travel;
|
use App\BusProNet\Model\Travel;
|
||||||
use App\BusProNet\Utility\DirectionMapper;
|
use App\BusProNet\Utility\DirectionMapper;
|
||||||
use App\BusProNet\Constants;
|
|
||||||
use App\Form\Model\BookingDto;
|
use App\Form\Model\BookingDto;
|
||||||
use App\Form\Model\ParticipantDto;
|
use App\Form\Model\ParticipantDto;
|
||||||
use App\Form\Service\ParticipantParkingFieldHandler;
|
use App\Form\Service\ParticipantParkingFieldHandler;
|
||||||
use App\Service\ServiceAvailabilityCalculator;
|
use App\Service\ServiceAvailabilityCalculator;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class ParticipantParkingFieldHandlerTest extends TestCase
|
class ParticipantParkingFieldHandlerTest extends TestCase
|
||||||
@@ -39,17 +40,13 @@ class ParticipantParkingFieldHandlerTest extends TestCase
|
|||||||
$this->assertTrue($this->handler->shouldProcess(['some' => 'data'], BookingDto::MODE_EDIT, 5));
|
$this->assertTrue($this->handler->shouldProcess(['some' => 'data'], BookingDto::MODE_EDIT, 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('normalizeCheckboxValueCheckedProvider')]
|
||||||
* @dataProvider normalizeCheckboxValueCheckedProvider
|
|
||||||
*/
|
|
||||||
public function testNormalizeCheckboxValueReturnsTrueWhenChecked(mixed $value): void
|
public function testNormalizeCheckboxValueReturnsTrueWhenChecked(mixed $value): void
|
||||||
{
|
{
|
||||||
$this->assertTrue($this->invokeNormalizeCheckboxValue($value));
|
$this->assertTrue($this->invokeNormalizeCheckboxValue($value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('normalizeCheckboxValueUncheckedProvider')]
|
||||||
* @dataProvider normalizeCheckboxValueUncheckedProvider
|
|
||||||
*/
|
|
||||||
public function testNormalizeCheckboxValueReturnsFalseWhenUnchecked(mixed $value): void
|
public function testNormalizeCheckboxValueReturnsFalseWhenUnchecked(mixed $value): void
|
||||||
{
|
{
|
||||||
$this->assertFalse($this->invokeNormalizeCheckboxValue($value));
|
$this->assertFalse($this->invokeNormalizeCheckboxValue($value));
|
||||||
|
|||||||
+35
-19
@@ -15,31 +15,35 @@ use PHPUnit\Framework\TestCase;
|
|||||||
|
|
||||||
class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestCase
|
class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
private ParticipantTransportationDiscountReplacementFieldHandler $handler;
|
private ?ParticipantTransportationDiscountReplacementFieldHandler $handler = null;
|
||||||
private ServiceAvailabilityCalculator $serviceAvailabilityCalculator;
|
private ServiceAvailabilityCalculator $serviceAvailabilityCalculator;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
$this->serviceAvailabilityCalculator = $this->createStub(ServiceAvailabilityCalculator::class);
|
||||||
$this->handler = new ParticipantTransportationDiscountReplacementFieldHandler(
|
}
|
||||||
|
|
||||||
|
private function handler(): ParticipantTransportationDiscountReplacementFieldHandler
|
||||||
|
{
|
||||||
|
return $this->handler ??= new ParticipantTransportationDiscountReplacementFieldHandler(
|
||||||
$this->serviceAvailabilityCalculator
|
$this->serviceAvailabilityCalculator
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetFieldName(): void
|
public function testGetFieldName(): void
|
||||||
{
|
{
|
||||||
$this->assertSame('transportationDiscountReplacement', $this->handler->getFieldName());
|
$this->assertSame('transportationDiscountReplacement', $this->handler()->getFieldName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetDependencies(): void
|
public function testGetDependencies(): void
|
||||||
{
|
{
|
||||||
$this->assertSame(['transportationOutbound', 'transportationInbound'], $this->handler->getDependencies());
|
$this->assertSame(['transportationOutbound', 'transportationInbound'], $this->handler()->getDependencies());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testShouldProcessAlwaysReturnsTrue(): void
|
public function testShouldProcessAlwaysReturnsTrue(): void
|
||||||
{
|
{
|
||||||
$this->assertTrue($this->handler->shouldProcess([], BookingDto::MODE_CREATE, 0));
|
$this->assertTrue($this->handler()->shouldProcess([], BookingDto::MODE_CREATE, 0));
|
||||||
$this->assertTrue($this->handler->shouldProcess(['some' => 'data'], BookingDto::MODE_EDIT, 5));
|
$this->assertTrue($this->handler()->shouldProcess(['some' => 'data'], BookingDto::MODE_EDIT, 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testProcessFieldReplacesDiscountedWithRegularWhenInboundIsBus(): void
|
public function testProcessFieldReplacesDiscountedWithRegularWhenInboundIsBus(): void
|
||||||
@@ -62,7 +66,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
|||||||
$submittedData = [];
|
$submittedData = [];
|
||||||
|
|
||||||
// Process
|
// Process
|
||||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||||
|
|
||||||
// Assert outbound was replaced with regular PKW
|
// Assert outbound was replaced with regular PKW
|
||||||
$this->assertSame($regularPkw->id, $participant->transportationOutbound->id);
|
$this->assertSame($regularPkw->id, $participant->transportationOutbound->id);
|
||||||
@@ -79,6 +83,8 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
|||||||
|
|
||||||
public function testProcessFieldRestoresDiscountedPkwWhenInboundChangesToPkw(): void
|
public function testProcessFieldRestoresDiscountedPkwWhenInboundChangesToPkw(): void
|
||||||
{
|
{
|
||||||
|
$this->serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
||||||
|
|
||||||
// Setup services
|
// Setup services
|
||||||
$discountedPkw = $this->createPkwService(100, 'Selbstorganisiert (-15€ Rabatt)', -15.0);
|
$discountedPkw = $this->createPkwService(100, 'Selbstorganisiert (-15€ Rabatt)', -15.0);
|
||||||
$regularPkw = $this->createPkwService(101, 'Selbstorganisiert', 0.0);
|
$regularPkw = $this->createPkwService(101, 'Selbstorganisiert', 0.0);
|
||||||
@@ -104,7 +110,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
|||||||
$submittedData = [];
|
$submittedData = [];
|
||||||
|
|
||||||
// Process
|
// Process
|
||||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||||
|
|
||||||
// Assert outbound was replaced with discounted PKW
|
// Assert outbound was replaced with discounted PKW
|
||||||
$this->assertSame($discountedPkw->id, $participant->transportationOutbound->id);
|
$this->assertSame($discountedPkw->id, $participant->transportationOutbound->id);
|
||||||
@@ -120,6 +126,8 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
|||||||
|
|
||||||
public function testProcessFieldDoesNotRestoreDiscountWhenUnavailable(): void
|
public function testProcessFieldDoesNotRestoreDiscountWhenUnavailable(): void
|
||||||
{
|
{
|
||||||
|
$this->serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
||||||
|
|
||||||
// Setup services
|
// Setup services
|
||||||
$discountedPkw = $this->createPkwService(100, 'Selbstorganisiert (-15€ Rabatt)', -15.0);
|
$discountedPkw = $this->createPkwService(100, 'Selbstorganisiert (-15€ Rabatt)', -15.0);
|
||||||
$regularPkw = $this->createPkwService(101, 'Selbstorganisiert', 0.0);
|
$regularPkw = $this->createPkwService(101, 'Selbstorganisiert', 0.0);
|
||||||
@@ -145,7 +153,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
|||||||
$submittedData = [];
|
$submittedData = [];
|
||||||
|
|
||||||
// Process
|
// Process
|
||||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||||
|
|
||||||
// Assert outbound remains regular PKW
|
// Assert outbound remains regular PKW
|
||||||
$this->assertSame($regularPkw, $participant->transportationOutbound);
|
$this->assertSame($regularPkw, $participant->transportationOutbound);
|
||||||
@@ -174,7 +182,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
|||||||
$submittedData = [];
|
$submittedData = [];
|
||||||
|
|
||||||
// Process
|
// Process
|
||||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||||
|
|
||||||
// Assert outbound remains BUS (no replacement)
|
// Assert outbound remains BUS (no replacement)
|
||||||
$this->assertSame($busOutbound, $participant->transportationOutbound);
|
$this->assertSame($busOutbound, $participant->transportationOutbound);
|
||||||
@@ -203,7 +211,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
|||||||
$submittedData = [];
|
$submittedData = [];
|
||||||
|
|
||||||
// Process
|
// Process
|
||||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||||
|
|
||||||
// Assert outbound remains regular PKW (already correct)
|
// Assert outbound remains regular PKW (already correct)
|
||||||
$this->assertSame($regularPkw, $participant->transportationOutbound);
|
$this->assertSame($regularPkw, $participant->transportationOutbound);
|
||||||
@@ -232,7 +240,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
|||||||
$submittedData = [];
|
$submittedData = [];
|
||||||
|
|
||||||
// Process
|
// Process
|
||||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||||
|
|
||||||
// Assert outbound remains discounted PKW (already optimal)
|
// Assert outbound remains discounted PKW (already optimal)
|
||||||
$this->assertSame($discountedPkw, $participant->transportationOutbound);
|
$this->assertSame($discountedPkw, $participant->transportationOutbound);
|
||||||
@@ -256,7 +264,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
|||||||
$submittedData = [];
|
$submittedData = [];
|
||||||
|
|
||||||
// Process - should handle gracefully
|
// Process - should handle gracefully
|
||||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||||
|
|
||||||
// Assert no error and no notification
|
// Assert no error and no notification
|
||||||
$this->assertNull($participant->transportationOutbound);
|
$this->assertNull($participant->transportationOutbound);
|
||||||
@@ -265,6 +273,8 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
|||||||
|
|
||||||
public function testProcessFieldHandlesNullInbound(): void
|
public function testProcessFieldHandlesNullInbound(): void
|
||||||
{
|
{
|
||||||
|
$this->serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
||||||
|
|
||||||
// Setup services
|
// Setup services
|
||||||
$discountedPkw = $this->createPkwService(100, 'Selbstorganisiert (-15€ Rabatt)', -15.0);
|
$discountedPkw = $this->createPkwService(100, 'Selbstorganisiert (-15€ Rabatt)', -15.0);
|
||||||
$regularPkw = $this->createPkwService(101, 'Selbstorganisiert', 0.0);
|
$regularPkw = $this->createPkwService(101, 'Selbstorganisiert', 0.0);
|
||||||
@@ -289,7 +299,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
|||||||
$submittedData = [];
|
$submittedData = [];
|
||||||
|
|
||||||
// Process - null inbound is treated as non-BUS, should attempt restoration
|
// Process - null inbound is treated as non-BUS, should attempt restoration
|
||||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||||
|
|
||||||
// Assert outbound was replaced with discounted PKW
|
// Assert outbound was replaced with discounted PKW
|
||||||
$this->assertSame($discountedPkw->id, $participant->transportationOutbound->id);
|
$this->assertSame($discountedPkw->id, $participant->transportationOutbound->id);
|
||||||
@@ -306,7 +316,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
|||||||
$submittedData = [];
|
$submittedData = [];
|
||||||
|
|
||||||
// Process - should handle gracefully
|
// Process - should handle gracefully
|
||||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||||
|
|
||||||
// Should not throw error
|
// Should not throw error
|
||||||
$this->expectNotToPerformAssertions();
|
$this->expectNotToPerformAssertions();
|
||||||
@@ -314,6 +324,8 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
|||||||
|
|
||||||
public function testProcessFieldSkipsDiscountRestorationForBabyParticipant(): void
|
public function testProcessFieldSkipsDiscountRestorationForBabyParticipant(): void
|
||||||
{
|
{
|
||||||
|
$this->serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
||||||
|
|
||||||
// Setup services
|
// Setup services
|
||||||
$discountedPkw = $this->createPkwService(100, 'Selbstorganisiert (-15€ Rabatt)', -15.0);
|
$discountedPkw = $this->createPkwService(100, 'Selbstorganisiert (-15€ Rabatt)', -15.0);
|
||||||
$regularPkw = $this->createPkwService(101, 'Selbstorganisiert', 0.0);
|
$regularPkw = $this->createPkwService(101, 'Selbstorganisiert', 0.0);
|
||||||
@@ -339,7 +351,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
|||||||
$submittedData = [];
|
$submittedData = [];
|
||||||
|
|
||||||
// Process
|
// Process
|
||||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||||
|
|
||||||
// Assert outbound remains regular PKW (no discount restoration for babies)
|
// Assert outbound remains regular PKW (no discount restoration for babies)
|
||||||
$this->assertSame($regularPkw->id, $participant->transportationOutbound->id);
|
$this->assertSame($regularPkw->id, $participant->transportationOutbound->id);
|
||||||
@@ -350,6 +362,8 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
|||||||
|
|
||||||
public function testProcessFieldSkipsDiscountRestorationForTwoYearOldParticipant(): void
|
public function testProcessFieldSkipsDiscountRestorationForTwoYearOldParticipant(): void
|
||||||
{
|
{
|
||||||
|
$this->serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
||||||
|
|
||||||
// Setup services
|
// Setup services
|
||||||
$discountedPkw = $this->createPkwService(100, 'Selbstorganisiert (-15€ Rabatt)', -15.0);
|
$discountedPkw = $this->createPkwService(100, 'Selbstorganisiert (-15€ Rabatt)', -15.0);
|
||||||
$regularPkw = $this->createPkwService(101, 'Selbstorganisiert', 0.0);
|
$regularPkw = $this->createPkwService(101, 'Selbstorganisiert', 0.0);
|
||||||
@@ -375,7 +389,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
|||||||
$submittedData = [];
|
$submittedData = [];
|
||||||
|
|
||||||
// Process
|
// Process
|
||||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||||
|
|
||||||
// Assert outbound remains regular PKW
|
// Assert outbound remains regular PKW
|
||||||
$this->assertSame($regularPkw->id, $participant->transportationOutbound->id);
|
$this->assertSame($regularPkw->id, $participant->transportationOutbound->id);
|
||||||
@@ -386,6 +400,8 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
|||||||
|
|
||||||
public function testProcessFieldRestoresDiscountForThreeYearOldParticipant(): void
|
public function testProcessFieldRestoresDiscountForThreeYearOldParticipant(): void
|
||||||
{
|
{
|
||||||
|
$this->serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
||||||
|
|
||||||
// Setup services
|
// Setup services
|
||||||
$discountedPkw = $this->createPkwService(100, 'Selbstorganisiert (-15€ Rabatt)', -15.0);
|
$discountedPkw = $this->createPkwService(100, 'Selbstorganisiert (-15€ Rabatt)', -15.0);
|
||||||
$regularPkw = $this->createPkwService(101, 'Selbstorganisiert', 0.0);
|
$regularPkw = $this->createPkwService(101, 'Selbstorganisiert', 0.0);
|
||||||
@@ -414,7 +430,7 @@ class ParticipantTransportationDiscountReplacementFieldHandlerTest extends TestC
|
|||||||
$submittedData = [];
|
$submittedData = [];
|
||||||
|
|
||||||
// Process
|
// Process
|
||||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
$this->handler()->processField($submittedData, $bookingDto, 0);
|
||||||
|
|
||||||
// Assert outbound was replaced with discounted PKW (3-year-old is eligible)
|
// Assert outbound was replaced with discounted PKW (3-year-old is eligible)
|
||||||
$this->assertSame($discountedPkw->id, $participant->transportationOutbound->id);
|
$this->assertSame($discountedPkw->id, $participant->transportationOutbound->id);
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ class ParticipantVegFieldHandlerTest extends TestCase
|
|||||||
|
|
||||||
private function createMockBookingDto(?Travel $travel = null): BookingDto
|
private function createMockBookingDto(?Travel $travel = null): BookingDto
|
||||||
{
|
{
|
||||||
$bookingDto = $this->createMock(BookingDto::class);
|
$bookingDto = $this->createStub(BookingDto::class);
|
||||||
|
|
||||||
if (null !== $travel) {
|
if (null !== $travel) {
|
||||||
$bookingDto->travel = $travel;
|
$bookingDto->travel = $travel;
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ class DatabaseHandlerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
private function connection(?string &$table, ?array &$data, ?array &$types): Connection
|
private function connection(?string &$table, ?array &$data, ?array &$types): Connection
|
||||||
{
|
{
|
||||||
$connection = $this->createMock(Connection::class);
|
$connection = $this->createStub(Connection::class);
|
||||||
$connection
|
$connection
|
||||||
->method('insert')
|
->method('insert')
|
||||||
->willReturnCallback(
|
->willReturnCallback(
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use App\Entity\Groups\AccommodationBooking;
|
|||||||
use App\Message\CreateClickUpBookingTaskMessage;
|
use App\Message\CreateClickUpBookingTaskMessage;
|
||||||
use App\MessageHandler\CreateClickUpBookingTaskHandler;
|
use App\MessageHandler\CreateClickUpBookingTaskHandler;
|
||||||
use App\Repository\Groups\AccommodationBookingRepository;
|
use App\Repository\Groups\AccommodationBookingRepository;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Log\NullLogger;
|
use Psr\Log\NullLogger;
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ class CreateClickUpBookingTaskHandlerTest extends TestCase
|
|||||||
|
|
||||||
public function testAVanishedBookingIsSkipped(): void
|
public function testAVanishedBookingIsSkipped(): void
|
||||||
{
|
{
|
||||||
$repository = $this->createMock(AccommodationBookingRepository::class);
|
$repository = $this->createStub(AccommodationBookingRepository::class);
|
||||||
$repository->method('find')->willReturn(null);
|
$repository->method('find')->willReturn(null);
|
||||||
|
|
||||||
$client = $this->createMock(ApiClient::class);
|
$client = $this->createMock(ApiClient::class);
|
||||||
@@ -58,15 +59,13 @@ class CreateClickUpBookingTaskHandlerTest extends TestCase
|
|||||||
$this->handler($repository, $client)(new CreateClickUpBookingTaskMessage(42));
|
$this->handler($repository, $client)(new CreateClickUpBookingTaskMessage(42));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('incompleteBookings')]
|
||||||
* @dataProvider incompleteBookings
|
|
||||||
*/
|
|
||||||
public function testABookingWithoutTheDataForATaskNameIsSkipped(callable $mutate): void
|
public function testABookingWithoutTheDataForATaskNameIsSkipped(callable $mutate): void
|
||||||
{
|
{
|
||||||
$booking = $this->booking();
|
$booking = $this->booking();
|
||||||
$mutate($booking);
|
$mutate($booking);
|
||||||
|
|
||||||
$repository = $this->createMock(AccommodationBookingRepository::class);
|
$repository = $this->createStub(AccommodationBookingRepository::class);
|
||||||
$repository->method('find')->willReturn($booking);
|
$repository->method('find')->willReturn($booking);
|
||||||
|
|
||||||
$client = $this->createMock(ApiClient::class);
|
$client = $this->createMock(ApiClient::class);
|
||||||
@@ -94,10 +93,10 @@ class CreateClickUpBookingTaskHandlerTest extends TestCase
|
|||||||
|
|
||||||
public function testAFailingStatusUpdateDoesNotRetryTheTaskCreation(): void
|
public function testAFailingStatusUpdateDoesNotRetryTheTaskCreation(): void
|
||||||
{
|
{
|
||||||
$repository = $this->createMock(AccommodationBookingRepository::class);
|
$repository = $this->createStub(AccommodationBookingRepository::class);
|
||||||
$repository->method('find')->willReturn($this->booking());
|
$repository->method('find')->willReturn($this->booking());
|
||||||
|
|
||||||
$client = $this->createMock(ApiClient::class);
|
$client = $this->createStub(ApiClient::class);
|
||||||
$client->method('isConfigured')->willReturn(true);
|
$client->method('isConfigured')->willReturn(true);
|
||||||
$client->method('createTaskFromTemplate')->willReturn('abc123');
|
$client->method('createTaskFromTemplate')->willReturn('abc123');
|
||||||
$client->method('updateTaskStatus')->willThrowException(new ClickUpException('boom'));
|
$client->method('updateTaskStatus')->willThrowException(new ClickUpException('boom'));
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class MailjetNewsletterEventHandlerTest extends TestCase
|
|||||||
$consent = new NewsletterConsent('[email protected]', 123);
|
$consent = new NewsletterConsent('[email protected]', 123);
|
||||||
$consent->markRevoked(new \DateTimeImmutable('2026-04-29T11:00:00+00:00'));
|
$consent->markRevoked(new \DateTimeImmutable('2026-04-29T11:00:00+00:00'));
|
||||||
|
|
||||||
$repository = $this->createMock(NewsletterConsentRepository::class);
|
$repository = $this->createStub(NewsletterConsentRepository::class);
|
||||||
$repository->method('findOneByEmailAndListId')->willReturn($consent);
|
$repository->method('findOneByEmailAndListId')->willReturn($consent);
|
||||||
|
|
||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
@@ -103,7 +103,7 @@ class MailjetNewsletterEventHandlerTest extends TestCase
|
|||||||
$consent = new NewsletterConsent('[email protected]', 123);
|
$consent = new NewsletterConsent('[email protected]', 123);
|
||||||
$consent->markConfirmed(new \DateTimeImmutable('2026-04-29T11:00:00+00:00'));
|
$consent->markConfirmed(new \DateTimeImmutable('2026-04-29T11:00:00+00:00'));
|
||||||
|
|
||||||
$repository = $this->createMock(NewsletterConsentRepository::class);
|
$repository = $this->createStub(NewsletterConsentRepository::class);
|
||||||
$repository->method('findOneByEmailAndListId')->willReturn($consent);
|
$repository->method('findOneByEmailAndListId')->willReturn($consent);
|
||||||
|
|
||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
@@ -126,7 +126,7 @@ class MailjetNewsletterEventHandlerTest extends TestCase
|
|||||||
$consent = new NewsletterConsent('[email protected]', 123);
|
$consent = new NewsletterConsent('[email protected]', 123);
|
||||||
$consent->markRevoked(new \DateTimeImmutable('2026-04-29T11:00:00+00:00'));
|
$consent->markRevoked(new \DateTimeImmutable('2026-04-29T11:00:00+00:00'));
|
||||||
|
|
||||||
$repository = $this->createMock(NewsletterConsentRepository::class);
|
$repository = $this->createStub(NewsletterConsentRepository::class);
|
||||||
$repository->method('findOneByEmailAndListId')->willReturn($consent);
|
$repository->method('findOneByEmailAndListId')->willReturn($consent);
|
||||||
|
|
||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace App\Tests\Model;
|
|||||||
|
|
||||||
use App\Model\ContingentCalendarQuery;
|
use App\Model\ContingentCalendarQuery;
|
||||||
use App\Model\ContingentPricesQuery;
|
use App\Model\ContingentPricesQuery;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Validator\Validation;
|
use Symfony\Component\Validator\Validation;
|
||||||
|
|
||||||
@@ -30,15 +31,13 @@ class ContingentQueryTest extends TestCase
|
|||||||
self::assertNull($query->dateToDate());
|
self::assertNull($query->dateToDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('invalidCalendarQueries')]
|
||||||
* @dataProvider invalidCalendarQueries
|
|
||||||
*/
|
|
||||||
public function testCalendarQueryRejectsInvalidInput(ContingentCalendarQuery $query): void
|
public function testCalendarQueryRejectsInvalidInput(ContingentCalendarQuery $query): void
|
||||||
{
|
{
|
||||||
self::assertGreaterThan(0, $this->validator()->validate($query)->count());
|
self::assertGreaterThan(0, $this->validator()->validate($query)->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function invalidCalendarQueries(): iterable
|
public static function invalidCalendarQueries(): iterable
|
||||||
{
|
{
|
||||||
yield 'normalized invalid date' => [new ContingentCalendarQuery('HOTEL', '2026-02-31', '2026-03-01')];
|
yield 'normalized invalid date' => [new ContingentCalendarQuery('HOTEL', '2026-02-31', '2026-03-01')];
|
||||||
yield 'reversed range' => [new ContingentCalendarQuery('HOTEL', '2026-03-02', '2026-03-01')];
|
yield 'reversed range' => [new ContingentCalendarQuery('HOTEL', '2026-03-02', '2026-03-01')];
|
||||||
|
|||||||
@@ -4,13 +4,14 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Tests\Model;
|
namespace App\Tests\Model;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use App\Model\NewsletterSubscriptionRequest;
|
use App\Model\NewsletterSubscriptionRequest;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Validator\Constraint;
|
use Symfony\Component\Validator\Constraint;
|
||||||
use Symfony\Component\Validator\ConstraintValidatorFactory;
|
|
||||||
use Symfony\Component\Validator\ConstraintValidatorInterface;
|
|
||||||
use Symfony\Component\Validator\Constraints\Email;
|
use Symfony\Component\Validator\Constraints\Email;
|
||||||
use Symfony\Component\Validator\Constraints\EmailValidator;
|
use Symfony\Component\Validator\Constraints\EmailValidator;
|
||||||
|
use Symfony\Component\Validator\ConstraintValidatorFactory;
|
||||||
|
use Symfony\Component\Validator\ConstraintValidatorInterface;
|
||||||
use Symfony\Component\Validator\Validation;
|
use Symfony\Component\Validator\Validation;
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
|
|
||||||
@@ -43,10 +44,9 @@ class NewsletterSubscriptionRequestTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider invalidRequests
|
|
||||||
*
|
|
||||||
* @param list<mixed> $listIds
|
* @param list<mixed> $listIds
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('invalidRequests')]
|
||||||
public function testInvalidRequestFailsValidation(?string $email, array $listIds): void
|
public function testInvalidRequestFailsValidation(?string $email, array $listIds): void
|
||||||
{
|
{
|
||||||
$request = new NewsletterSubscriptionRequest();
|
$request = new NewsletterSubscriptionRequest();
|
||||||
@@ -61,7 +61,7 @@ class NewsletterSubscriptionRequestTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @return iterable<string, array{0: ?string, 1: list<mixed>}>
|
* @return iterable<string, array{0: ?string, 1: list<mixed>}>
|
||||||
*/
|
*/
|
||||||
public function invalidRequests(): iterable
|
public static function invalidRequests(): iterable
|
||||||
{
|
{
|
||||||
yield 'invalid email' => ['not-an-email', [10321569]];
|
yield 'invalid email' => ['not-an-email', [10321569]];
|
||||||
yield 'empty list ids' => ['[email protected]', []];
|
yield 'empty list ids' => ['[email protected]', []];
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use App\Repository\Filter\AppliesListFiltersTrait;
|
|||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\Query\Expr;
|
use Doctrine\ORM\Query\Expr;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class AppliesListFiltersTraitTest extends TestCase
|
class AppliesListFiltersTraitTest extends TestCase
|
||||||
@@ -25,9 +26,7 @@ class AppliesListFiltersTraitTest extends TestCase
|
|||||||
self::assertSame('%bonn%', $qb->getParameter('searchTerm1')?->getValue());
|
self::assertSame('%bonn%', $qb->getParameter('searchTerm1')?->getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('emptyTerms')]
|
||||||
* @dataProvider emptyTerms
|
|
||||||
*/
|
|
||||||
public function testAnEmptyTermNarrowsNothing(?string $term): void
|
public function testAnEmptyTermNarrowsNothing(?string $term): void
|
||||||
{
|
{
|
||||||
$qb = $this->queryBuilder();
|
$qb = $this->queryBuilder();
|
||||||
@@ -119,7 +118,7 @@ class AppliesListFiltersTraitTest extends TestCase
|
|||||||
|
|
||||||
private function queryBuilder(): QueryBuilder
|
private function queryBuilder(): QueryBuilder
|
||||||
{
|
{
|
||||||
$em = $this->createMock(EntityManagerInterface::class);
|
$em = $this->createStub(EntityManagerInterface::class);
|
||||||
$em->method('getExpressionBuilder')->willReturn(new Expr());
|
$em->method('getExpressionBuilder')->willReturn(new Expr());
|
||||||
|
|
||||||
return (new QueryBuilder($em))->select('b')->from('Booking', 'b');
|
return (new QueryBuilder($em))->select('b')->from('Booking', 'b');
|
||||||
|
|||||||
@@ -206,14 +206,14 @@ class BpnAuthenticatorTest extends TestCase
|
|||||||
$personalData->personId = 42;
|
$personalData->personId = 42;
|
||||||
$personalData->addressId = 4711;
|
$personalData->addressId = 4711;
|
||||||
|
|
||||||
$apiClient = $this->createMock(ApiClient::class);
|
$apiClient = $this->createStub(ApiClient::class);
|
||||||
$apiClient->method('getPersonalData')->willReturn($personalData);
|
$apiClient->method('getPersonalData')->willReturn($personalData);
|
||||||
$apiClient->method('getCrmAttributes')->willReturn($crmAttributes);
|
$apiClient->method('getCrmAttributes')->willReturn($crmAttributes);
|
||||||
|
|
||||||
$repository = $this->createMock(EntityRepository::class);
|
$repository = $this->createStub(EntityRepository::class);
|
||||||
$repository->method('findOneBy')->willReturn($existing);
|
$repository->method('findOneBy')->willReturn($existing);
|
||||||
|
|
||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createStub(EntityManagerInterface::class);
|
||||||
$entityManager->method('getRepository')->willReturn($repository);
|
$entityManager->method('getRepository')->willReturn($repository);
|
||||||
$entityManager
|
$entityManager
|
||||||
->method('persist')
|
->method('persist')
|
||||||
@@ -225,19 +225,19 @@ class BpnAuthenticatorTest extends TestCase
|
|||||||
})
|
})
|
||||||
;
|
;
|
||||||
|
|
||||||
$crypt = $this->createMock(Crypt::class);
|
$crypt = $this->createStub(Crypt::class);
|
||||||
$crypt->method('encrypt')->willReturn('encrypted');
|
$crypt->method('encrypt')->willReturn('encrypted');
|
||||||
|
|
||||||
$completenessChecker = $this->createMock(ProfileCompletenessChecker::class);
|
$completenessChecker = $this->createStub(ProfileCompletenessChecker::class);
|
||||||
$completenessChecker->method('isComplete')->willReturn(true);
|
$completenessChecker->method('isComplete')->willReturn(true);
|
||||||
|
|
||||||
return new BpnAuthenticator(
|
return new BpnAuthenticator(
|
||||||
$this->createMock(UrlGeneratorInterface::class),
|
$this->createStub(UrlGeneratorInterface::class),
|
||||||
$apiClient,
|
$apiClient,
|
||||||
$entityManager,
|
$entityManager,
|
||||||
$crypt,
|
$crypt,
|
||||||
$completenessChecker,
|
$completenessChecker,
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class DefaultRouteResolverTest extends TestCase
|
|||||||
->willReturn($hasAdministrativeAccess)
|
->willReturn($hasAdministrativeAccess)
|
||||||
;
|
;
|
||||||
|
|
||||||
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
$urlGenerator = $this->createStub(UrlGeneratorInterface::class);
|
||||||
$urlGenerator
|
$urlGenerator
|
||||||
->method('generate')
|
->method('generate')
|
||||||
->willReturnCallback(static fn (string $route): string => match ($route) {
|
->willReturnCallback(static fn (string $route): string => match ($route) {
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ class AccommodationBookingBreakdownCalculatorTest extends TestCase
|
|||||||
'undersubscription40Eur' => 0,
|
'undersubscription40Eur' => 0,
|
||||||
'undersubscription40Chf' => 0,
|
'undersubscription40Chf' => 0,
|
||||||
]),
|
]),
|
||||||
$priceRepository ?? $this->createMock(AccommodationPriceRepository::class),
|
$priceRepository ?? $this->createStub(AccommodationPriceRepository::class),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ class AccommodationBookingLinkSignerTest extends TestCase
|
|||||||
|
|
||||||
private function createSigner(): AccommodationBookingLinkSigner
|
private function createSigner(): AccommodationBookingLinkSigner
|
||||||
{
|
{
|
||||||
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
|
$urlGenerator = $this->createStub(UrlGeneratorInterface::class);
|
||||||
$urlGenerator
|
$urlGenerator
|
||||||
->method('generate')
|
->method('generate')
|
||||||
->willReturnCallback(static fn (string $name, array $parameters) => sprintf(
|
->willReturnCallback(static fn (string $name, array $parameters) => sprintf(
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class AccommodationBookingPdfGeneratorTest extends TestCase
|
|||||||
$twig = new Environment(new FilesystemLoader(__DIR__.'/../../templates'));
|
$twig = new Environment(new FilesystemLoader(__DIR__.'/../../templates'));
|
||||||
$twig->addExtension(new IntlExtension());
|
$twig->addExtension(new IntlExtension());
|
||||||
|
|
||||||
$calculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
$calculator = $this->createStub(AccommodationBookingBreakdownCalculator::class);
|
||||||
$calculator->method('compute')->willReturn($breakdown);
|
$calculator->method('compute')->willReturn($breakdown);
|
||||||
|
|
||||||
return new AccommodationBookingPdfGenerator($twig, $calculator, \dirname(__DIR__, 2));
|
return new AccommodationBookingPdfGenerator($twig, $calculator, \dirname(__DIR__, 2));
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ use App\Service\AccommodationBookingService;
|
|||||||
use App\Service\CmsDataProvider;
|
use App\Service\CmsDataProvider;
|
||||||
use App\Service\PriceTimelineBuilder;
|
use App\Service\PriceTimelineBuilder;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
@@ -153,10 +154,10 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
$booking->setStatus(AccommodationBookingStatus::Open);
|
$booking->setStatus(AccommodationBookingStatus::Open);
|
||||||
$booking->setAccessLinkIssuedAt(new \DateTimeImmutable());
|
$booking->setAccessLinkIssuedAt(new \DateTimeImmutable());
|
||||||
|
|
||||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
$linkSigner = $this->createStub(AccommodationBookingLinkSigner::class);
|
||||||
$linkSigner->method('sign')->willReturn('https://example.com/offer/signed-link');
|
$linkSigner->method('sign')->willReturn('https://example.com/offer/signed-link');
|
||||||
|
|
||||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
$breakdownCalculator = $this->createStub(AccommodationBookingBreakdownCalculator::class);
|
||||||
$breakdownCalculator->method('compute')->willReturn(null);
|
$breakdownCalculator->method('compute')->willReturn(null);
|
||||||
|
|
||||||
$mailer = $this->createMock(Mailer::class);
|
$mailer = $this->createMock(Mailer::class);
|
||||||
@@ -183,7 +184,7 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
||||||
$linkSigner->method('sign')->with($booking)->willReturn('https://example.com/offer/signed-link');
|
$linkSigner->method('sign')->with($booking)->willReturn('https://example.com/offer/signed-link');
|
||||||
|
|
||||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
$breakdownCalculator = $this->createStub(AccommodationBookingBreakdownCalculator::class);
|
||||||
$breakdownCalculator->method('compute')->willReturn(['total' => 1000, 'currency' => 'EUR']);
|
$breakdownCalculator->method('compute')->willReturn(['total' => 1000, 'currency' => 'EUR']);
|
||||||
|
|
||||||
$mailer = $this->createMock(Mailer::class);
|
$mailer = $this->createMock(Mailer::class);
|
||||||
@@ -208,7 +209,7 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
$booking->setEmail('[email protected]');
|
$booking->setEmail('[email protected]');
|
||||||
$booking->setStatus(AccommodationBookingStatus::Open);
|
$booking->setStatus(AccommodationBookingStatus::Open);
|
||||||
|
|
||||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
$breakdownCalculator = $this->createStub(AccommodationBookingBreakdownCalculator::class);
|
||||||
$breakdownCalculator->method('compute')->willReturn(null);
|
$breakdownCalculator->method('compute')->willReturn(null);
|
||||||
|
|
||||||
$mailer = $this->createMock(Mailer::class);
|
$mailer = $this->createMock(Mailer::class);
|
||||||
@@ -231,10 +232,10 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
$booking->setEmail('[email protected]');
|
$booking->setEmail('[email protected]');
|
||||||
$booking->setStatus(AccommodationBookingStatus::Open);
|
$booking->setStatus(AccommodationBookingStatus::Open);
|
||||||
|
|
||||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
$breakdownCalculator = $this->createStub(AccommodationBookingBreakdownCalculator::class);
|
||||||
$breakdownCalculator->method('compute')->willReturn(null);
|
$breakdownCalculator->method('compute')->willReturn(null);
|
||||||
|
|
||||||
$mailer = $this->createMock(Mailer::class);
|
$mailer = $this->createStub(Mailer::class);
|
||||||
$mailer->method('createAndSendEmail')->willThrowException(new \RuntimeException('SMTP down'));
|
$mailer->method('createAndSendEmail')->willThrowException(new \RuntimeException('SMTP down'));
|
||||||
|
|
||||||
$logger = $this->createMock(LoggerInterface::class);
|
$logger = $this->createMock(LoggerInterface::class);
|
||||||
@@ -258,7 +259,7 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
$entityManager->expects(self::once())->method('flush');
|
$entityManager->expects(self::once())->method('flush');
|
||||||
|
|
||||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
$breakdownCalculator = $this->createStub(AccommodationBookingBreakdownCalculator::class);
|
||||||
$breakdownCalculator->method('compute')->willReturn(null);
|
$breakdownCalculator->method('compute')->willReturn(null);
|
||||||
|
|
||||||
$mailer = $this->createMock(Mailer::class);
|
$mailer = $this->createMock(Mailer::class);
|
||||||
@@ -416,9 +417,7 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
self::assertSame($issuedAt, $booking->getAccessLinkIssuedAt());
|
self::assertSame($issuedAt, $booking->getAccessLinkIssuedAt());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('statusesThatAreNotAwaitingAnOffer')]
|
||||||
* @dataProvider statusesThatAreNotAwaitingAnOffer
|
|
||||||
*/
|
|
||||||
public function testSendOfferNoOpsOnceTheOfferIsOut(AccommodationBookingStatus $status): void
|
public function testSendOfferNoOpsOnceTheOfferIsOut(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
@@ -495,9 +494,7 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
self::assertSame($issuedAt, $booking->getAccessLinkIssuedAt());
|
self::assertSame($issuedAt, $booking->getAccessLinkIssuedAt());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('statusesThatAreNotAwaitingAnOffer')]
|
||||||
* @dataProvider statusesThatAreNotAwaitingAnOffer
|
|
||||||
*/
|
|
||||||
public function testGenerateAccessLinkNoOpsOnceTheOfferIsOut(AccommodationBookingStatus $status): void
|
public function testGenerateAccessLinkNoOpsOnceTheOfferIsOut(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
@@ -533,9 +530,7 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
self::assertSame(AccommodationBookingStatus::Discarded, $booking->getStatus());
|
self::assertSame(AccommodationBookingStatus::Discarded, $booking->getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('closedStatuses')]
|
||||||
* @dataProvider closedStatuses
|
|
||||||
*/
|
|
||||||
public function testDiscardBookingNoOpsForAClosedBooking(AccommodationBookingStatus $status): void
|
public function testDiscardBookingNoOpsForAClosedBooking(AccommodationBookingStatus $status): void
|
||||||
{
|
{
|
||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
@@ -643,7 +638,7 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
$booking->setEmail('[email protected]');
|
$booking->setEmail('[email protected]');
|
||||||
$booking->setRemarks('vom Telefonat');
|
$booking->setRemarks('vom Telefonat');
|
||||||
|
|
||||||
$service = $this->createServiceWithAccommodation(mailer: $this->createMock(Mailer::class));
|
$service = $this->createServiceWithAccommodation(mailer: $this->createStub(Mailer::class));
|
||||||
|
|
||||||
$service->acceptBooking($booking, " Bitte Zimmer im EG\nund Frühstück um 8 \n");
|
$service->acceptBooking($booking, " Bitte Zimmer im EG\nund Frühstück um 8 \n");
|
||||||
|
|
||||||
@@ -657,7 +652,7 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
$booking->setEmail('[email protected]');
|
$booking->setEmail('[email protected]');
|
||||||
$booking->setRemarks('vom Telefonat');
|
$booking->setRemarks('vom Telefonat');
|
||||||
|
|
||||||
$service = $this->createServiceWithAccommodation(mailer: $this->createMock(Mailer::class));
|
$service = $this->createServiceWithAccommodation(mailer: $this->createStub(Mailer::class));
|
||||||
|
|
||||||
$service->acceptBooking($booking, ' ');
|
$service->acceptBooking($booking, ' ');
|
||||||
|
|
||||||
@@ -671,7 +666,7 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
$booking->setEmail('[email protected]');
|
$booking->setEmail('[email protected]');
|
||||||
$booking->setRemarks('vom Telefonat');
|
$booking->setRemarks('vom Telefonat');
|
||||||
|
|
||||||
$service = $this->createServiceWithAccommodation(mailer: $this->createMock(Mailer::class));
|
$service = $this->createServiceWithAccommodation(mailer: $this->createStub(Mailer::class));
|
||||||
|
|
||||||
$service->acceptBooking($booking);
|
$service->acceptBooking($booking);
|
||||||
|
|
||||||
@@ -684,7 +679,7 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
$booking->setStatus(AccommodationBookingStatus::Received);
|
$booking->setStatus(AccommodationBookingStatus::Received);
|
||||||
$booking->setRemarks('vom Telefonat');
|
$booking->setRemarks('vom Telefonat');
|
||||||
|
|
||||||
$service = $this->createServiceWithAccommodation(mailer: $this->createMock(Mailer::class));
|
$service = $this->createServiceWithAccommodation(mailer: $this->createStub(Mailer::class));
|
||||||
|
|
||||||
$service->acceptBooking($booking, 'zu spät');
|
$service->acceptBooking($booking, 'zu spät');
|
||||||
|
|
||||||
@@ -693,7 +688,7 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
|
|
||||||
public function testConfirmBookingConfirmsReceivedBookingAndNotifiesTheCustomer(): void
|
public function testConfirmBookingConfirmsReceivedBookingAndNotifiesTheCustomer(): void
|
||||||
{
|
{
|
||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createStub(EntityManagerInterface::class);
|
||||||
|
|
||||||
$booking = new AccommodationBooking();
|
$booking = new AccommodationBooking();
|
||||||
$booking->setStatus(AccommodationBookingStatus::Received);
|
$booking->setStatus(AccommodationBookingStatus::Received);
|
||||||
@@ -835,7 +830,7 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
$booking = new AccommodationBooking();
|
$booking = new AccommodationBooking();
|
||||||
$booking->setStatus(AccommodationBookingStatus::Received);
|
$booking->setStatus(AccommodationBookingStatus::Received);
|
||||||
|
|
||||||
$mailer = $this->createMock(Mailer::class);
|
$mailer = $this->createStub(Mailer::class);
|
||||||
$mailer->method('createAndSendEmail')->willThrowException(new \RuntimeException('SMTP down'));
|
$mailer->method('createAndSendEmail')->willThrowException(new \RuntimeException('SMTP down'));
|
||||||
|
|
||||||
$logger = $this->createMock(LoggerInterface::class);
|
$logger = $this->createMock(LoggerInterface::class);
|
||||||
@@ -852,7 +847,7 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
$booking->setEmail('[email protected]');
|
$booking->setEmail('[email protected]');
|
||||||
$booking->setStatus(AccommodationBookingStatus::Confirmed);
|
$booking->setStatus(AccommodationBookingStatus::Confirmed);
|
||||||
|
|
||||||
$mailer = $this->createMock(Mailer::class);
|
$mailer = $this->createStub(Mailer::class);
|
||||||
$mailer->method('createAndSendEmail')->willThrowException(new \RuntimeException('SMTP down'));
|
$mailer->method('createAndSendEmail')->willThrowException(new \RuntimeException('SMTP down'));
|
||||||
|
|
||||||
$logger = $this->createMock(LoggerInterface::class);
|
$logger = $this->createMock(LoggerInterface::class);
|
||||||
@@ -894,7 +889,7 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
$booking->setEmail('[email protected]');
|
$booking->setEmail('[email protected]');
|
||||||
$booking->setStatus(AccommodationBookingStatus::Confirmed);
|
$booking->setStatus(AccommodationBookingStatus::Confirmed);
|
||||||
|
|
||||||
$pdfGenerator = $this->createMock(AccommodationBookingPdfGenerator::class);
|
$pdfGenerator = $this->createStub(AccommodationBookingPdfGenerator::class);
|
||||||
$pdfGenerator->method('createAttachment')->willThrowException(new \RuntimeException('no prices'));
|
$pdfGenerator->method('createAttachment')->willThrowException(new \RuntimeException('no prices'));
|
||||||
|
|
||||||
$mailer = $this->createMock(Mailer::class);
|
$mailer = $this->createMock(Mailer::class);
|
||||||
@@ -1038,7 +1033,7 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
->with(['calendarCode' => 'HOTEL'])
|
->with(['calendarCode' => 'HOTEL'])
|
||||||
->willReturn($accommodation);
|
->willReturn($accommodation);
|
||||||
|
|
||||||
$priceRepo = $this->createMock(AccommodationPriceRepository::class);
|
$priceRepo = $this->createStub(AccommodationPriceRepository::class);
|
||||||
$priceRepo
|
$priceRepo
|
||||||
->method('findByHotelCodeAndDateRange')
|
->method('findByHotelCodeAndDateRange')
|
||||||
->willReturn($prices);
|
->willReturn($prices);
|
||||||
@@ -1046,16 +1041,16 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
return new AccommodationBookingService(
|
return new AccommodationBookingService(
|
||||||
$accommodationRepo,
|
$accommodationRepo,
|
||||||
$priceRepo,
|
$priceRepo,
|
||||||
$this->createMock(AdditionalServiceRepository::class),
|
$this->createStub(AdditionalServiceRepository::class),
|
||||||
$this->createMock(BoardServiceRepository::class),
|
$this->createStub(BoardServiceRepository::class),
|
||||||
new PriceTimelineBuilder(),
|
new PriceTimelineBuilder(),
|
||||||
$entityManager ?? $this->createMock(EntityManagerInterface::class),
|
$entityManager ?? $this->createStub(EntityManagerInterface::class),
|
||||||
$mailer ?? $this->createMock(Mailer::class),
|
$mailer ?? $this->createStub(Mailer::class),
|
||||||
$logger ?? $this->createMock(LoggerInterface::class),
|
$logger ?? $this->createStub(LoggerInterface::class),
|
||||||
$this->createMock(CmsDataProvider::class),
|
$this->createStub(CmsDataProvider::class),
|
||||||
$linkSigner ?? $this->createMock(AccommodationBookingLinkSigner::class),
|
$linkSigner ?? $this->createStub(AccommodationBookingLinkSigner::class),
|
||||||
$breakdownCalculator ?? $this->createMock(AccommodationBookingBreakdownCalculator::class),
|
$breakdownCalculator ?? $this->createStub(AccommodationBookingBreakdownCalculator::class),
|
||||||
$pdfGenerator ?? $this->createMock(AccommodationBookingPdfGenerator::class),
|
$pdfGenerator ?? $this->createStub(AccommodationBookingPdfGenerator::class),
|
||||||
'[email protected]',
|
'[email protected]',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class AccommodationPriceCoverageTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testCoversOnlyDaysWithinPricePeriod(): void
|
public function testCoversOnlyDaysWithinPricePeriod(): void
|
||||||
{
|
{
|
||||||
$coverage = new AccommodationPriceCoverage($this->createMock(AccommodationPriceRepository::class));
|
$coverage = new AccommodationPriceCoverage($this->createStub(AccommodationPriceRepository::class));
|
||||||
|
|
||||||
$covered = $coverage->coveredDatesFor(
|
$covered = $coverage->coveredDatesFor(
|
||||||
[$this->price('2026-06-01', '2026-06-09')],
|
[$this->price('2026-06-01', '2026-06-09')],
|
||||||
@@ -30,7 +30,7 @@ class AccommodationPriceCoverageTest extends TestCase
|
|||||||
|
|
||||||
public function testGapBetweenPricePeriodsStaysUncovered(): void
|
public function testGapBetweenPricePeriodsStaysUncovered(): void
|
||||||
{
|
{
|
||||||
$coverage = new AccommodationPriceCoverage($this->createMock(AccommodationPriceRepository::class));
|
$coverage = new AccommodationPriceCoverage($this->createStub(AccommodationPriceRepository::class));
|
||||||
|
|
||||||
$covered = $coverage->coveredDatesFor(
|
$covered = $coverage->coveredDatesFor(
|
||||||
[$this->price('2026-06-01', '2026-06-02'), $this->price('2026-06-05', '2026-06-06')],
|
[$this->price('2026-06-01', '2026-06-02'), $this->price('2026-06-05', '2026-06-06')],
|
||||||
@@ -46,7 +46,7 @@ class AccommodationPriceCoverageTest extends TestCase
|
|||||||
|
|
||||||
public function testNoPricesMeansNoCoverage(): void
|
public function testNoPricesMeansNoCoverage(): void
|
||||||
{
|
{
|
||||||
$coverage = new AccommodationPriceCoverage($this->createMock(AccommodationPriceRepository::class));
|
$coverage = new AccommodationPriceCoverage($this->createStub(AccommodationPriceRepository::class));
|
||||||
|
|
||||||
$covered = $coverage->coveredDatesFor(
|
$covered = $coverage->coveredDatesFor(
|
||||||
[],
|
[],
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ class ApplicantInsuranceCascadeTest extends TestCase
|
|||||||
|
|
||||||
$cascade = new ApplicantInsuranceCascade(
|
$cascade = new ApplicantInsuranceCascade(
|
||||||
$insuranceService,
|
$insuranceService,
|
||||||
$this->createMock(BookingPriceCalculator::class)
|
$this->createStub(BookingPriceCalculator::class)
|
||||||
);
|
);
|
||||||
|
|
||||||
$cascade->apply($bookingDto);
|
$cascade->apply($bookingDto);
|
||||||
@@ -201,11 +201,11 @@ class ApplicantInsuranceCascadeTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
private function createCascade(array $assignments, array $selectable): ApplicantInsuranceCascade
|
private function createCascade(array $assignments, array $selectable): ApplicantInsuranceCascade
|
||||||
{
|
{
|
||||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
$insuranceService = $this->createStub(InsuranceManager::class);
|
||||||
$insuranceService->method('getSelectableInsurances')->willReturn($selectable);
|
$insuranceService->method('getSelectableInsurances')->willReturn($selectable);
|
||||||
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn($assignments);
|
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn($assignments);
|
||||||
|
|
||||||
$priceCalculator = $this->createMock(BookingPriceCalculator::class);
|
$priceCalculator = $this->createStub(BookingPriceCalculator::class);
|
||||||
$priceCalculator->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
$priceCalculator->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
||||||
|
|
||||||
return new ApplicantInsuranceCascade($insuranceService, $priceCalculator);
|
return new ApplicantInsuranceCascade($insuranceService, $priceCalculator);
|
||||||
|
|||||||
@@ -19,23 +19,25 @@ use PHPUnit\Framework\TestCase;
|
|||||||
|
|
||||||
class BookingConfiguratorBabyTest extends TestCase
|
class BookingConfiguratorBabyTest extends TestCase
|
||||||
{
|
{
|
||||||
private BookingConfigurator $bookingService;
|
private ?BookingConfigurator $bookingService = null;
|
||||||
private ParticipantEligibilityChecker $participantEligibilityService;
|
private ParticipantEligibilityChecker $participantEligibilityService;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$travelDataService = $this->createMock(TravelDataProvider::class);
|
$this->participantEligibilityService = $this->createStub(ParticipantEligibilityChecker::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 BookingConfigurator(
|
private function bookingService(): BookingConfigurator
|
||||||
$this->createMock(BookingSessionManager::class),
|
{
|
||||||
$travelDataService,
|
$bookingStatusRuleRegistry = $this->createStub(BookingStatusRuleRegistry::class);
|
||||||
|
$bookingStatusRuleRegistry->method('evaluateStatus')->willReturn('F');
|
||||||
|
|
||||||
|
return $this->bookingService ??= new BookingConfigurator(
|
||||||
|
$this->createStub(BookingSessionManager::class),
|
||||||
|
$this->createStub(TravelDataProvider::class),
|
||||||
$this->participantEligibilityService,
|
$this->participantEligibilityService,
|
||||||
$bookingStatusRuleRegistry,
|
$bookingStatusRuleRegistry,
|
||||||
$agencyLoader,
|
$this->createStub(AgencyLoader::class),
|
||||||
'F' // default booking status
|
'F' // default booking status
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -52,7 +54,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
$participant->additionalServices = [];
|
$participant->additionalServices = [];
|
||||||
$bookingDto->participants[0] = $participant;
|
$bookingDto->participants[0] = $participant;
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertEmpty($participant->additionalServices, 'Mandatory services should not be preselected for baby participants');
|
$this->assertEmpty($participant->additionalServices, 'Mandatory services should not be preselected for baby participants');
|
||||||
}
|
}
|
||||||
@@ -69,7 +71,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
$participant->additionalServices = [];
|
$participant->additionalServices = [];
|
||||||
$bookingDto->participants[0] = $participant;
|
$bookingDto->participants[0] = $participant;
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertEmpty($participant->additionalServices, 'Mandatory services should not be preselected for participants at BABY_MAX_AGE');
|
$this->assertEmpty($participant->additionalServices, 'Mandatory services should not be preselected for participants at BABY_MAX_AGE');
|
||||||
}
|
}
|
||||||
@@ -91,7 +93,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
->method('isParticipantEligible')
|
->method('isParticipantEligible')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertNotEmpty($participant->additionalServices, 'Mandatory services should be preselected for non-baby participants');
|
$this->assertNotEmpty($participant->additionalServices, 'Mandatory services should be preselected for non-baby participants');
|
||||||
$this->assertCount(1, $participant->additionalServices);
|
$this->assertCount(1, $participant->additionalServices);
|
||||||
@@ -115,7 +117,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
->method('isParticipantEligible')
|
->method('isParticipantEligible')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertNotEmpty($participant->additionalServices, 'Mandatory services should be preselected for adult participants');
|
$this->assertNotEmpty($participant->additionalServices, 'Mandatory services should be preselected for adult participants');
|
||||||
$this->assertCount(1, $participant->additionalServices);
|
$this->assertCount(1, $participant->additionalServices);
|
||||||
@@ -123,6 +125,8 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
|
|
||||||
public function testPreselectMandatoryServicesHandlesMixedParticipants(): void
|
public function testPreselectMandatoryServicesHandlesMixedParticipants(): void
|
||||||
{
|
{
|
||||||
|
$this->participantEligibilityService = $this->createMock(ParticipantEligibilityChecker::class);
|
||||||
|
|
||||||
$travel = $this->createTravelWithMandatoryServices();
|
$travel = $this->createTravelWithMandatoryServices();
|
||||||
$bookingDto = new BookingDto($travel, 1);
|
$bookingDto = new BookingDto($travel, 1);
|
||||||
|
|
||||||
@@ -146,7 +150,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
->with($bookingDto, 1) // Only called for adult
|
->with($bookingDto, 1) // Only called for adult
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertEmpty($babyParticipant->additionalServices, 'Baby should not have mandatory services preselected');
|
$this->assertEmpty($babyParticipant->additionalServices, 'Baby should not have mandatory services preselected');
|
||||||
$this->assertNotEmpty($adultParticipant->additionalServices, 'Adult should have mandatory services preselected');
|
$this->assertNotEmpty($adultParticipant->additionalServices, 'Adult should have mandatory services preselected');
|
||||||
@@ -164,7 +168,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
$participant->additionalServices = [];
|
$participant->additionalServices = [];
|
||||||
$bookingDto->participants[0] = $participant;
|
$bookingDto->participants[0] = $participant;
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertEmpty($participant->additionalServices, 'Mandatory services should not be preselected for newborn babies');
|
$this->assertEmpty($participant->additionalServices, 'Mandatory services should not be preselected for newborn babies');
|
||||||
}
|
}
|
||||||
@@ -186,7 +190,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
$participant->additionalServices = [];
|
$participant->additionalServices = [];
|
||||||
$bookingDto->participants[0] = $participant;
|
$bookingDto->participants[0] = $participant;
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
// At age 1, participant is a baby and should be skipped
|
// At age 1, participant is a baby and should be skipped
|
||||||
$this->assertEmpty($participant->additionalServices, 'Age should be calculated at travel date, not current date');
|
$this->assertEmpty($participant->additionalServices, 'Age should be calculated at travel date, not current date');
|
||||||
@@ -207,7 +211,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
->method('isParticipantEligible')
|
->method('isParticipantEligible')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertCount(1, $participant->additionalServices);
|
$this->assertCount(1, $participant->additionalServices);
|
||||||
$this->assertSame('Auto Book Service', $participant->additionalServices[0]->label);
|
$this->assertSame('Auto Book Service', $participant->additionalServices[0]->label);
|
||||||
@@ -229,7 +233,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
->method('isParticipantEligible')
|
->method('isParticipantEligible')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertEmpty($participant->additionalServices);
|
$this->assertEmpty($participant->additionalServices);
|
||||||
}
|
}
|
||||||
@@ -250,7 +254,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
->method('isParticipantEligible')
|
->method('isParticipantEligible')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertCount(1, $participant->additionalServices);
|
$this->assertCount(1, $participant->additionalServices);
|
||||||
$this->assertSame('Mandatory And Auto Book Service', $participant->additionalServices[0]->label);
|
$this->assertSame('Mandatory And Auto Book Service', $participant->additionalServices[0]->label);
|
||||||
@@ -270,7 +274,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
->method('isParticipantEligible')
|
->method('isParticipantEligible')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertNotNull($participant->skiPass);
|
$this->assertNotNull($participant->skiPass);
|
||||||
$this->assertSame('Auto Book Ski Pass', $participant->skiPass?->label);
|
$this->assertSame('Auto Book Ski Pass', $participant->skiPass?->label);
|
||||||
@@ -291,7 +295,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
->method('isParticipantEligible')
|
->method('isParticipantEligible')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertNull($participant->skiPass);
|
$this->assertNull($participant->skiPass);
|
||||||
}
|
}
|
||||||
@@ -311,7 +315,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
->method('isParticipantEligible')
|
->method('isParticipantEligible')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertNotNull($participant->skiPass);
|
$this->assertNotNull($participant->skiPass);
|
||||||
$this->assertSame('Mandatory And Auto Book Ski Pass', $participant->skiPass?->label);
|
$this->assertSame('Mandatory And Auto Book Ski Pass', $participant->skiPass?->label);
|
||||||
@@ -331,7 +335,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
->method('isParticipantEligible')
|
->method('isParticipantEligible')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertCount(1, $participant->board);
|
$this->assertCount(1, $participant->board);
|
||||||
$this->assertSame('Auto Book Board', $participant->board[0]->label);
|
$this->assertSame('Auto Book Board', $participant->board[0]->label);
|
||||||
@@ -352,7 +356,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
->method('isParticipantEligible')
|
->method('isParticipantEligible')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertSame([], $participant->board);
|
$this->assertSame([], $participant->board);
|
||||||
}
|
}
|
||||||
@@ -372,7 +376,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
->method('isParticipantEligible')
|
->method('isParticipantEligible')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertCount(1, $participant->board);
|
$this->assertCount(1, $participant->board);
|
||||||
$this->assertSame('Mandatory And Auto Book Board', $participant->board[0]->label);
|
$this->assertSame('Mandatory And Auto Book Board', $participant->board[0]->label);
|
||||||
@@ -393,7 +397,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
->method('isParticipantEligible')
|
->method('isParticipantEligible')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertCount(1, $participant->rentals);
|
$this->assertCount(1, $participant->rentals);
|
||||||
$this->assertSame('Auto Book Rental', $participant->rentals[0]->label);
|
$this->assertSame('Auto Book Rental', $participant->rentals[0]->label);
|
||||||
@@ -415,7 +419,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
->method('isParticipantEligible')
|
->method('isParticipantEligible')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertSame([], $participant->rentals);
|
$this->assertSame([], $participant->rentals);
|
||||||
}
|
}
|
||||||
@@ -436,7 +440,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
->method('isParticipantEligible')
|
->method('isParticipantEligible')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertCount(1, $participant->rentals);
|
$this->assertCount(1, $participant->rentals);
|
||||||
$this->assertSame('Mandatory And Auto Book Rental', $participant->rentals[0]->label);
|
$this->assertSame('Mandatory And Auto Book Rental', $participant->rentals[0]->label);
|
||||||
@@ -456,7 +460,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
->method('isParticipantEligible')
|
->method('isParticipantEligible')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertSame([], $participant->rentals);
|
$this->assertSame([], $participant->rentals);
|
||||||
}
|
}
|
||||||
@@ -480,7 +484,7 @@ class BookingConfiguratorBabyTest extends TestCase
|
|||||||
->method('isParticipantEligible')
|
->method('isParticipantEligible')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$this->bookingService->preselectDefaultServices($bookingDto);
|
$this->bookingService()->preselectDefaultServices($bookingDto);
|
||||||
|
|
||||||
$this->assertSame([], $participant->rentals);
|
$this->assertSame([], $participant->rentals);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Tests\Service;
|
namespace App\Tests\Service;
|
||||||
|
|
||||||
use App\Form\Model\BookingDto;
|
use App\BusProNet\Constants;
|
||||||
use App\Form\Model\ParticipantDto;
|
|
||||||
use App\BusProNet\Model\CrmSelection;
|
use App\BusProNet\Model\CrmSelection;
|
||||||
use App\BusProNet\Model\CrmSelectionGroup;
|
use App\BusProNet\Model\CrmSelectionGroup;
|
||||||
use App\BusProNet\Constants;
|
|
||||||
use App\BusProNet\Model\Room;
|
use App\BusProNet\Model\Room;
|
||||||
use App\BusProNet\Model\Service;
|
use App\BusProNet\Model\Service;
|
||||||
use App\BusProNet\Model\Travel;
|
use App\BusProNet\Model\Travel;
|
||||||
@@ -16,6 +14,8 @@ use App\BusProNet\Service\BookingStatusRuleRegistry;
|
|||||||
use App\BusProNet\Service\StatusRule\Selection1473StatusRule;
|
use App\BusProNet\Service\StatusRule\Selection1473StatusRule;
|
||||||
use App\BusProNet\XmlLoader\AgencyLoader;
|
use App\BusProNet\XmlLoader\AgencyLoader;
|
||||||
use App\Exception\NoRoomsAvailableException;
|
use App\Exception\NoRoomsAvailableException;
|
||||||
|
use App\Form\Model\BookingDto;
|
||||||
|
use App\Form\Model\ParticipantDto;
|
||||||
use App\Service\BookingConfigurator;
|
use App\Service\BookingConfigurator;
|
||||||
use App\Service\BookingSessionManager;
|
use App\Service\BookingSessionManager;
|
||||||
use App\Service\ParticipantEligibilityChecker;
|
use App\Service\ParticipantEligibilityChecker;
|
||||||
@@ -32,12 +32,12 @@ class BookingConfiguratorStatusTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$bookingSessionService = $this->createMock(BookingSessionManager::class);
|
$bookingSessionService = $this->createStub(BookingSessionManager::class);
|
||||||
$this->travelDataService = $this->createMock(TravelDataProvider::class);
|
$this->travelDataService = $this->createStub(TravelDataProvider::class);
|
||||||
$participantEligibility = $this->createMock(ParticipantEligibilityChecker::class);
|
$participantEligibility = $this->createStub(ParticipantEligibilityChecker::class);
|
||||||
$bookingStatusRuleRegistry = $this->createMock(BookingStatusRuleRegistry::class);
|
$bookingStatusRuleRegistry = $this->createStub(BookingStatusRuleRegistry::class);
|
||||||
$bookingStatusRuleRegistry->method('evaluateStatus')->willReturn('F');
|
$bookingStatusRuleRegistry->method('evaluateStatus')->willReturn('F');
|
||||||
$agencyLoader = $this->createMock(AgencyLoader::class);
|
$agencyLoader = $this->createStub(AgencyLoader::class);
|
||||||
|
|
||||||
$this->bookingService = new BookingConfigurator(
|
$this->bookingService = new BookingConfigurator(
|
||||||
$bookingSessionService,
|
$bookingSessionService,
|
||||||
@@ -180,13 +180,13 @@ class BookingConfiguratorStatusTest extends TestCase
|
|||||||
public function testStartFreshBookingWithSelection1473UsesOptionStatus(): void
|
public function testStartFreshBookingWithSelection1473UsesOptionStatus(): void
|
||||||
{
|
{
|
||||||
$bookingService = new BookingConfigurator(
|
$bookingService = new BookingConfigurator(
|
||||||
$this->createMock(BookingSessionManager::class),
|
$this->createStub(BookingSessionManager::class),
|
||||||
$this->travelDataService,
|
$this->travelDataService,
|
||||||
$this->createMock(ParticipantEligibilityChecker::class),
|
$this->createStub(ParticipantEligibilityChecker::class),
|
||||||
new BookingStatusRuleRegistry([
|
new BookingStatusRuleRegistry([
|
||||||
new Selection1473StatusRule(),
|
new Selection1473StatusRule(),
|
||||||
]),
|
]),
|
||||||
$this->createMock(AgencyLoader::class),
|
$this->createStub(AgencyLoader::class),
|
||||||
'F'
|
'F'
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -230,15 +230,15 @@ class BookingConfiguratorStatusTest extends TestCase
|
|||||||
|
|
||||||
public function testApplyCreateBookingStatusRulesSetsOptionFromRegistry(): void
|
public function testApplyCreateBookingStatusRulesSetsOptionFromRegistry(): void
|
||||||
{
|
{
|
||||||
$bookingStatusRuleRegistry = $this->createMock(BookingStatusRuleRegistry::class);
|
$bookingStatusRuleRegistry = $this->createStub(BookingStatusRuleRegistry::class);
|
||||||
$bookingStatusRuleRegistry->method('evaluateStatus')->willReturn('O');
|
$bookingStatusRuleRegistry->method('evaluateStatus')->willReturn('O');
|
||||||
|
|
||||||
$bookingService = new BookingConfigurator(
|
$bookingService = new BookingConfigurator(
|
||||||
$this->createMock(BookingSessionManager::class),
|
$this->createStub(BookingSessionManager::class),
|
||||||
$this->travelDataService,
|
$this->travelDataService,
|
||||||
$this->createMock(ParticipantEligibilityChecker::class),
|
$this->createStub(ParticipantEligibilityChecker::class),
|
||||||
$bookingStatusRuleRegistry,
|
$bookingStatusRuleRegistry,
|
||||||
$this->createMock(AgencyLoader::class),
|
$this->createStub(AgencyLoader::class),
|
||||||
'F'
|
'F'
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -265,11 +265,11 @@ class BookingConfiguratorStatusTest extends TestCase
|
|||||||
$bookingStatusRuleRegistry->expects($this->never())->method('evaluateStatus');
|
$bookingStatusRuleRegistry->expects($this->never())->method('evaluateStatus');
|
||||||
|
|
||||||
$bookingService = new BookingConfigurator(
|
$bookingService = new BookingConfigurator(
|
||||||
$this->createMock(BookingSessionManager::class),
|
$this->createStub(BookingSessionManager::class),
|
||||||
$this->travelDataService,
|
$this->travelDataService,
|
||||||
$this->createMock(ParticipantEligibilityChecker::class),
|
$this->createStub(ParticipantEligibilityChecker::class),
|
||||||
$bookingStatusRuleRegistry,
|
$bookingStatusRuleRegistry,
|
||||||
$this->createMock(AgencyLoader::class),
|
$this->createStub(AgencyLoader::class),
|
||||||
'F'
|
'F'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class BookingCreateContextFactoryTest extends TestCase
|
|||||||
$travel->rooms = [$roomByRoom, $roomByPax];
|
$travel->rooms = [$roomByRoom, $roomByPax];
|
||||||
|
|
||||||
$bookingDto = new BookingDto($travel, 157047);
|
$bookingDto = new BookingDto($travel, 157047);
|
||||||
$summaryData = $this->createMock(BookingSummaryDto::class);
|
$summaryData = $this->createStub(BookingSummaryDto::class);
|
||||||
|
|
||||||
$summaryDataService = $this->createMock(BookingSummaryAssembler::class);
|
$summaryDataService = $this->createMock(BookingSummaryAssembler::class);
|
||||||
$summaryDataService->expects($this->once())
|
$summaryDataService->expects($this->once())
|
||||||
@@ -63,7 +63,7 @@ class BookingCreateContextFactoryTest extends TestCase
|
|||||||
$priceCalculator->expects($this->never())
|
$priceCalculator->expects($this->never())
|
||||||
->method('calculateAllParticipantIndividualPrices');
|
->method('calculateAllParticipantIndividualPrices');
|
||||||
|
|
||||||
$familyInsuranceService = $this->createMock(FamilyInsuranceAvailabilityChecker::class);
|
$familyInsuranceService = $this->createStub(FamilyInsuranceAvailabilityChecker::class);
|
||||||
$familyInsuranceService->method('isFamilyInsuranceUpgradeAvailable')->willReturn(true);
|
$familyInsuranceService->method('isFamilyInsuranceUpgradeAvailable')->willReturn(true);
|
||||||
|
|
||||||
$service = new BookingCreateContextFactory(
|
$service = new BookingCreateContextFactory(
|
||||||
@@ -101,7 +101,7 @@ class BookingCreateContextFactoryTest extends TestCase
|
|||||||
$travel->rooms = [$room];
|
$travel->rooms = [$room];
|
||||||
|
|
||||||
$bookingDto = new BookingDto($travel, 157047);
|
$bookingDto = new BookingDto($travel, 157047);
|
||||||
$summaryData = $this->createMock(BookingSummaryDto::class);
|
$summaryData = $this->createStub(BookingSummaryDto::class);
|
||||||
$cardData = new ParticipantCardDataDto(
|
$cardData = new ParticipantCardDataDto(
|
||||||
name: 'Max Mustermann',
|
name: 'Max Mustermann',
|
||||||
email: '[email protected]',
|
email: '[email protected]',
|
||||||
@@ -126,7 +126,7 @@ class BookingCreateContextFactoryTest extends TestCase
|
|||||||
$priceCalculator->expects($this->never())
|
$priceCalculator->expects($this->never())
|
||||||
->method('calculateAllParticipantIndividualPrices');
|
->method('calculateAllParticipantIndividualPrices');
|
||||||
|
|
||||||
$familyInsuranceService = $this->createMock(FamilyInsuranceAvailabilityChecker::class);
|
$familyInsuranceService = $this->createStub(FamilyInsuranceAvailabilityChecker::class);
|
||||||
$familyInsuranceService->method('isFamilyInsuranceUpgradeAvailable')->willReturn(true);
|
$familyInsuranceService->method('isFamilyInsuranceUpgradeAvailable')->willReturn(true);
|
||||||
|
|
||||||
$service = new BookingCreateContextFactory(
|
$service = new BookingCreateContextFactory(
|
||||||
@@ -162,7 +162,7 @@ class BookingCreateContextFactoryTest extends TestCase
|
|||||||
$travel->rooms = [$room];
|
$travel->rooms = [$room];
|
||||||
|
|
||||||
$bookingDto = new BookingDto($travel, 157047);
|
$bookingDto = new BookingDto($travel, 157047);
|
||||||
$summaryData = $this->createMock(BookingSummaryDto::class);
|
$summaryData = $this->createStub(BookingSummaryDto::class);
|
||||||
|
|
||||||
$summaryDataService = $this->createMock(BookingSummaryAssembler::class);
|
$summaryDataService = $this->createMock(BookingSummaryAssembler::class);
|
||||||
$summaryDataService->expects($this->once())
|
$summaryDataService->expects($this->once())
|
||||||
@@ -180,7 +180,7 @@ class BookingCreateContextFactoryTest extends TestCase
|
|||||||
->with($bookingDto)
|
->with($bookingDto)
|
||||||
->willReturn([123.45]);
|
->willReturn([123.45]);
|
||||||
|
|
||||||
$familyInsuranceService = $this->createMock(FamilyInsuranceAvailabilityChecker::class);
|
$familyInsuranceService = $this->createStub(FamilyInsuranceAvailabilityChecker::class);
|
||||||
$familyInsuranceService->method('isFamilyInsuranceUpgradeAvailable')->willReturn(true);
|
$familyInsuranceService->method('isFamilyInsuranceUpgradeAvailable')->willReturn(true);
|
||||||
|
|
||||||
$service = new BookingCreateContextFactory(
|
$service = new BookingCreateContextFactory(
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class BookingEditContextFactoryTest extends TestCase
|
|||||||
$bookingData = new Booking();
|
$bookingData = new Booking();
|
||||||
$bookingData->dateId = 123;
|
$bookingData->dateId = 123;
|
||||||
|
|
||||||
$summaryData = $this->createMock(BookingSummaryDto::class);
|
$summaryData = $this->createStub(BookingSummaryDto::class);
|
||||||
|
|
||||||
$participantCardAssembler = $this->createMock(ParticipantCardAssembler::class);
|
$participantCardAssembler = $this->createMock(ParticipantCardAssembler::class);
|
||||||
$participantCardAssembler->expects($this->once())
|
$participantCardAssembler->expects($this->once())
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ class BookingEditDraftManagerMutabilityTest extends TestCase
|
|||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->service = new BookingEditDraftManager(
|
$this->service = new BookingEditDraftManager(
|
||||||
$this->createMock(BookingEditDraftRepository::class),
|
$this->createStub(BookingEditDraftRepository::class),
|
||||||
$this->createMock(EntityManagerInterface::class),
|
$this->createStub(EntityManagerInterface::class),
|
||||||
$this->createMock(BookingChangeTracker::class),
|
$this->createStub(BookingChangeTracker::class),
|
||||||
new BookingEditDraftMerger(),
|
new BookingEditDraftMerger(),
|
||||||
new NullLogger(),
|
new NullLogger(),
|
||||||
);
|
);
|
||||||
@@ -544,7 +544,7 @@ class BookingEditDraftManagerMutabilityTest extends TestCase
|
|||||||
|
|
||||||
private function createDraft(array $formData): BookingEditDraft
|
private function createDraft(array $formData): BookingEditDraft
|
||||||
{
|
{
|
||||||
$user = $this->createMock(User::class);
|
$user = $this->createStub(User::class);
|
||||||
|
|
||||||
return new BookingEditDraft($user, 123, new \DateTimeImmutable(), $formData);
|
return new BookingEditDraft($user, 123, new \DateTimeImmutable(), $formData);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,20 +4,20 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Tests\Service;
|
namespace App\Tests\Service;
|
||||||
|
|
||||||
use App\BusProNet\Model\CrmSelection;
|
|
||||||
use App\BusProNet\Model\CrmSelectionGroup;
|
|
||||||
use App\BusProNet\Model\Address;
|
use App\BusProNet\Model\Address;
|
||||||
use App\BusProNet\Model\Booking;
|
use App\BusProNet\Model\Booking;
|
||||||
|
use App\BusProNet\Model\CrmSelection;
|
||||||
|
use App\BusProNet\Model\CrmSelectionGroup;
|
||||||
use App\BusProNet\Model\Service;
|
use App\BusProNet\Model\Service;
|
||||||
use App\BusProNet\Model\Travel;
|
use App\BusProNet\Model\Travel;
|
||||||
use App\BusProNet\XmlLoader\AgencyLoader;
|
use App\BusProNet\XmlLoader\AgencyLoader;
|
||||||
use App\Form\Model\BookingDto;
|
use App\Form\Model\BookingDto;
|
||||||
use App\Form\Model\ParticipantDto;
|
use App\Form\Model\ParticipantDto;
|
||||||
|
use App\Form\Service\ServiceAgeEvaluator;
|
||||||
use App\Service\BookingEditPreFlightChecker;
|
use App\Service\BookingEditPreFlightChecker;
|
||||||
use App\Service\BookingPriceCalculator;
|
use App\Service\BookingPriceCalculator;
|
||||||
use App\Service\ParticipantEligibilityChecker;
|
use App\Service\ParticipantEligibilityChecker;
|
||||||
use App\Service\VoucherValidator;
|
use App\Service\VoucherValidator;
|
||||||
use App\Form\Service\ServiceAgeEvaluator;
|
|
||||||
use App\Validator\Constraints\MandatoryAdditionalServicesSelectedValidator;
|
use App\Validator\Constraints\MandatoryAdditionalServicesSelectedValidator;
|
||||||
use App\Validator\Constraints\PromoVoucherValidator;
|
use App\Validator\Constraints\PromoVoucherValidator;
|
||||||
use App\Validator\Constraints\PurchaseVoucherValidator;
|
use App\Validator\Constraints\PurchaseVoucherValidator;
|
||||||
@@ -248,19 +248,14 @@ class BookingEditPreFlightCheckerTest extends TestCase
|
|||||||
|
|
||||||
private function createValidator(): ValidatorInterface
|
private function createValidator(): ValidatorInterface
|
||||||
{
|
{
|
||||||
$voucherValidator = $this->createMock(VoucherValidator::class);
|
$voucherValidator = $this->createStub(VoucherValidator::class);
|
||||||
$bookingPriceCalculator = $this->createMock(BookingPriceCalculator::class);
|
$bookingPriceCalculator = $this->createStub(BookingPriceCalculator::class);
|
||||||
$participantEligibilityChecker = $this->createMock(ParticipantEligibilityChecker::class);
|
$participantEligibilityChecker = $this->createStub(ParticipantEligibilityChecker::class);
|
||||||
$participantEligibilityChecker
|
$participantEligibilityChecker
|
||||||
->method('isParticipantEligible')
|
->method('isParticipantEligible')
|
||||||
->willReturn(false);
|
->willReturn(false);
|
||||||
|
|
||||||
$validatorFactory = new class(
|
$validatorFactory = new class($voucherValidator, $bookingPriceCalculator, $participantEligibilityChecker, new ServiceAgeEvaluator()) implements ConstraintValidatorFactoryInterface {
|
||||||
$voucherValidator,
|
|
||||||
$bookingPriceCalculator,
|
|
||||||
$participantEligibilityChecker,
|
|
||||||
new ServiceAgeEvaluator(),
|
|
||||||
) implements ConstraintValidatorFactoryInterface {
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly VoucherValidator $voucherValidator,
|
private readonly VoucherValidator $voucherValidator,
|
||||||
private readonly BookingPriceCalculator $bookingPriceCalculator,
|
private readonly BookingPriceCalculator $bookingPriceCalculator,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ use App\Service\BookingEditSubmitGuard;
|
|||||||
use App\Service\BookingEditSubmitter;
|
use App\Service\BookingEditSubmitter;
|
||||||
use App\Service\BookingSessionManager;
|
use App\Service\BookingSessionManager;
|
||||||
use App\Service\TravelDataProvider;
|
use App\Service\TravelDataProvider;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@@ -53,9 +54,7 @@ class BookingEditSubmitterTest extends TestCase
|
|||||||
$this->assertFalse($result->immutableChangesReverted);
|
$this->assertFalse($result->immutableChangesReverted);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('updateFailureProvider')]
|
||||||
* @dataProvider updateFailureProvider
|
|
||||||
*/
|
|
||||||
public function testHandleSubmissionReturnsRedirectWhenUpdateThrows(
|
public function testHandleSubmissionReturnsRedirectWhenUpdateThrows(
|
||||||
\Throwable $exception,
|
\Throwable $exception,
|
||||||
string $expectedStatus,
|
string $expectedStatus,
|
||||||
@@ -437,13 +436,13 @@ class BookingEditSubmitterTest extends TestCase
|
|||||||
?BookingSessionManager $bookingSessionService = null,
|
?BookingSessionManager $bookingSessionService = null,
|
||||||
): BookingEditSubmitter {
|
): BookingEditSubmitter {
|
||||||
return new BookingEditSubmitter(
|
return new BookingEditSubmitter(
|
||||||
$apiClient ?? $this->createMock(\App\BusProNet\ApiClient::class),
|
$apiClient ?? $this->createStub(\App\BusProNet\ApiClient::class),
|
||||||
$dataLoader ?? $this->createMock(BookingEditDataLoader::class),
|
$dataLoader ?? $this->createStub(BookingEditDataLoader::class),
|
||||||
$draftService ?? $this->createMock(BookingEditDraftManager::class),
|
$draftService ?? $this->createStub(BookingEditDraftManager::class),
|
||||||
$travelDataService ?? $this->createMock(TravelDataProvider::class),
|
$travelDataService ?? $this->createStub(TravelDataProvider::class),
|
||||||
$submitGuard ?? $this->createMock(BookingEditSubmitGuard::class),
|
$submitGuard ?? $this->createStub(BookingEditSubmitGuard::class),
|
||||||
$bookingSessionService ?? $this->createMock(BookingSessionManager::class),
|
$bookingSessionService ?? $this->createStub(BookingSessionManager::class),
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,5 +474,4 @@ class BookingEditSubmitterTest extends TestCase
|
|||||||
|
|
||||||
return $request;
|
return $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class BookingPriceCalculatorTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$eligibilityChecker = $this->createMock(ParticipantEligibilityChecker::class);
|
$eligibilityChecker = $this->createStub(ParticipantEligibilityChecker::class);
|
||||||
$eligibilityChecker->method('isParticipantEligible')->willReturn(true);
|
$eligibilityChecker->method('isParticipantEligible')->willReturn(true);
|
||||||
|
|
||||||
$this->roomPricingCalculator = new RoomPricingCalculator();
|
$this->roomPricingCalculator = new RoomPricingCalculator();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class BookingPriceMismatchAnalyzerTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testBuildDiagnosticsProvidesDeltaBreakdown(): void
|
public function testBuildDiagnosticsProvidesDeltaBreakdown(): void
|
||||||
{
|
{
|
||||||
$pricingAssembler = $this->createMock(BookingPricingAssembler::class);
|
$pricingAssembler = $this->createStub(BookingPricingAssembler::class);
|
||||||
$pricingAssembler->method('getPricingBreakdown')->willReturn([
|
$pricingAssembler->method('getPricingBreakdown')->willReturn([
|
||||||
'rooms' => [
|
'rooms' => [
|
||||||
['roomId' => 74, 'totalPrice' => 444.0],
|
['roomId' => 74, 'totalPrice' => 444.0],
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class BookingPricingAssemblerTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->eligibilityChecker = $this->createMock(ParticipantEligibilityChecker::class);
|
$this->eligibilityChecker = $this->createStub(ParticipantEligibilityChecker::class);
|
||||||
$this->eligibilityChecker->method('isParticipantEligible')->willReturn(true);
|
$this->eligibilityChecker->method('isParticipantEligible')->willReturn(true);
|
||||||
|
|
||||||
$this->assembler = $this->createAssembler($this->eligibilityChecker);
|
$this->assembler = $this->createAssembler($this->eligibilityChecker);
|
||||||
@@ -176,7 +176,7 @@ class BookingPricingAssemblerTest extends TestCase
|
|||||||
$bookingDto = new BookingDto($travel, 2);
|
$bookingDto = new BookingDto($travel, 2);
|
||||||
$bookingDto->participants = [$participant1, $participant2];
|
$bookingDto->participants = [$participant1, $participant2];
|
||||||
|
|
||||||
$eligibilityChecker = $this->createMock(ParticipantEligibilityChecker::class);
|
$eligibilityChecker = $this->createStub(ParticipantEligibilityChecker::class);
|
||||||
$eligibilityChecker->method('isParticipantEligible')
|
$eligibilityChecker->method('isParticipantEligible')
|
||||||
->willReturnCallback(fn ($booking, int $index): bool => 0 === $index);
|
->willReturnCallback(fn ($booking, int $index): bool => 0 === $index);
|
||||||
|
|
||||||
|
|||||||
@@ -19,12 +19,16 @@ use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
|||||||
class BookingSessionManagerTest extends TestCase
|
class BookingSessionManagerTest extends TestCase
|
||||||
{
|
{
|
||||||
private TravelDataProvider $travelDataService;
|
private TravelDataProvider $travelDataService;
|
||||||
private BookingSessionManager $service;
|
private ?BookingSessionManager $service = null;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->travelDataService = $this->createMock(TravelDataProvider::class);
|
$this->travelDataService = $this->createStub(TravelDataProvider::class);
|
||||||
$this->service = new BookingSessionManager($this->travelDataService);
|
}
|
||||||
|
|
||||||
|
private function service(): BookingSessionManager
|
||||||
|
{
|
||||||
|
return $this->service ??= new BookingSessionManager($this->travelDataService);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetOrCreateBookingCreateDtoThrowsWhenSessionMissing(): void
|
public function testGetOrCreateBookingCreateDtoThrowsWhenSessionMissing(): void
|
||||||
@@ -33,11 +37,13 @@ class BookingSessionManagerTest extends TestCase
|
|||||||
|
|
||||||
$this->expectException(BookingSessionNotFoundException::class);
|
$this->expectException(BookingSessionNotFoundException::class);
|
||||||
|
|
||||||
$this->service->getOrCreateBookingCreateDto($request);
|
$this->service()->getOrCreateBookingCreateDto($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSaveAndLoadBookingDtoHydratesTravel(): void
|
public function testSaveAndLoadBookingDtoHydratesTravel(): void
|
||||||
{
|
{
|
||||||
|
$this->travelDataService = $this->createMock(TravelDataProvider::class);
|
||||||
|
|
||||||
$request = $this->createRequestWithSession();
|
$request = $this->createRequestWithSession();
|
||||||
|
|
||||||
$storedTravel = new Travel();
|
$storedTravel = new Travel();
|
||||||
@@ -59,8 +65,8 @@ class BookingSessionManagerTest extends TestCase
|
|||||||
->with(12, 34)
|
->with(12, 34)
|
||||||
->willReturn($hydratedTravel);
|
->willReturn($hydratedTravel);
|
||||||
|
|
||||||
$this->service->saveBookingDto($request, $bookingDto, BookingDto::MODE_CREATE);
|
$this->service()->saveBookingDto($request, $bookingDto, BookingDto::MODE_CREATE);
|
||||||
$loadedDto = $this->service->getBookingDto($request, BookingDto::MODE_CREATE);
|
$loadedDto = $this->service()->getBookingDto($request, BookingDto::MODE_CREATE);
|
||||||
|
|
||||||
$this->assertNotNull($loadedDto);
|
$this->assertNotNull($loadedDto);
|
||||||
$this->assertSame($hydratedTravel, $loadedDto?->travel);
|
$this->assertSame($hydratedTravel, $loadedDto?->travel);
|
||||||
@@ -76,11 +82,11 @@ class BookingSessionManagerTest extends TestCase
|
|||||||
$selection->quantity = 2;
|
$selection->quantity = 2;
|
||||||
$bookingDto->roomSelections = [$selection];
|
$bookingDto->roomSelections = [$selection];
|
||||||
|
|
||||||
$first = $this->service->getOrCreateBaselineSnapshot($request, $bookingDto);
|
$first = $this->service()->getOrCreateBaselineSnapshot($request, $bookingDto);
|
||||||
$this->assertSame([[1, 2]], $first);
|
$this->assertSame([[1, 2]], $first);
|
||||||
|
|
||||||
$selection->quantity = 5;
|
$selection->quantity = 5;
|
||||||
$second = $this->service->getOrCreateBaselineSnapshot($request, $bookingDto);
|
$second = $this->service()->getOrCreateBaselineSnapshot($request, $bookingDto);
|
||||||
|
|
||||||
$this->assertSame($first, $second);
|
$this->assertSame($first, $second);
|
||||||
$this->assertSame([[1, 2]], $second);
|
$this->assertSame([[1, 2]], $second);
|
||||||
@@ -90,19 +96,19 @@ class BookingSessionManagerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$request = $this->createRequestWithSession();
|
$request = $this->createRequestWithSession();
|
||||||
|
|
||||||
$this->service->storeReturnUrl($request, 'javascript:alert(1)');
|
$this->service()->storeReturnUrl($request, 'javascript:alert(1)');
|
||||||
|
|
||||||
$this->assertSame(BookingSessionManager::DEFAULT_RETURN_URL, $this->service->getReturnUrl($request));
|
$this->assertSame(BookingSessionManager::DEFAULT_RETURN_URL, $this->service()->getReturnUrl($request));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testClearBookingSessionPreservesReturnUrl(): void
|
public function testClearBookingSessionPreservesReturnUrl(): void
|
||||||
{
|
{
|
||||||
$request = $this->createRequestWithSession();
|
$request = $this->createRequestWithSession();
|
||||||
|
|
||||||
$this->service->storeReturnUrl($request, 'https://example.test/after-booking');
|
$this->service()->storeReturnUrl($request, 'https://example.test/after-booking');
|
||||||
$this->service->clearBookingSession($request);
|
$this->service()->clearBookingSession($request);
|
||||||
|
|
||||||
$this->assertSame('https://example.test/after-booking', $this->service->getReturnUrl($request));
|
$this->assertSame('https://example.test/after-booking', $this->service()->getReturnUrl($request));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createRequestWithSession(): Request
|
private function createRequestWithSession(): Request
|
||||||
|
|||||||
@@ -72,10 +72,10 @@ class BookingSummaryAssemblerTest extends TestCase
|
|||||||
|
|
||||||
private function createService(): BookingSummaryAssembler
|
private function createService(): BookingSummaryAssembler
|
||||||
{
|
{
|
||||||
$priceCalculator = $this->createMock(BookingPriceCalculator::class);
|
$priceCalculator = $this->createStub(BookingPriceCalculator::class);
|
||||||
$priceCalculator->method('calculateAllParticipantIndividualPrices')->willReturn([]);
|
$priceCalculator->method('calculateAllParticipantIndividualPrices')->willReturn([]);
|
||||||
|
|
||||||
$pricingAssembler = $this->createMock(BookingPricingAssembler::class);
|
$pricingAssembler = $this->createStub(BookingPricingAssembler::class);
|
||||||
$pricingAssembler->method('getPricingBreakdown')->willReturn([
|
$pricingAssembler->method('getPricingBreakdown')->willReturn([
|
||||||
'rooms' => [],
|
'rooms' => [],
|
||||||
'services' => [],
|
'services' => [],
|
||||||
@@ -86,10 +86,10 @@ class BookingSummaryAssemblerTest extends TestCase
|
|||||||
return new BookingSummaryAssembler(
|
return new BookingSummaryAssembler(
|
||||||
$priceCalculator,
|
$priceCalculator,
|
||||||
$pricingAssembler,
|
$pricingAssembler,
|
||||||
$this->createMock(CmsDataProvider::class),
|
$this->createStub(CmsDataProvider::class),
|
||||||
$this->createMock(HotelLoader::class),
|
$this->createStub(HotelLoader::class),
|
||||||
$this->createMock(CountryDataProvider::class),
|
$this->createStub(CountryDataProvider::class),
|
||||||
$this->createMock(CacheInterface::class),
|
$this->createStub(CacheInterface::class),
|
||||||
new NullLogger(),
|
new NullLogger(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,27 +17,29 @@ use App\Repository\Groups\ContingentDayRepository;
|
|||||||
use App\Repository\Groups\ContingentSyncStateRepository;
|
use App\Repository\Groups\ContingentSyncStateRepository;
|
||||||
use App\Service\ContingentSnapshotManager;
|
use App\Service\ContingentSnapshotManager;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\Stub;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class ContingentSnapshotManagerTest extends TestCase
|
class ContingentSnapshotManagerTest extends TestCase
|
||||||
{
|
{
|
||||||
private ContingentsClient&MockObject $client;
|
private ContingentsClient&Stub $client;
|
||||||
private ContingentDayRepository&MockObject $dayRepository;
|
private ContingentDayRepository&Stub $dayRepository;
|
||||||
private ContingentSyncStateRepository&MockObject $syncStateRepository;
|
private ContingentSyncStateRepository&Stub $syncStateRepository;
|
||||||
private EntityManagerInterface&MockObject $entityManager;
|
private EntityManagerInterface&Stub $entityManager;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->client = $this->createMock(ContingentsClient::class);
|
$this->client = $this->createStub(ContingentsClient::class);
|
||||||
$this->dayRepository = $this->createMock(ContingentDayRepository::class);
|
$this->dayRepository = $this->createStub(ContingentDayRepository::class);
|
||||||
$this->syncStateRepository = $this->createMock(ContingentSyncStateRepository::class);
|
$this->syncStateRepository = $this->createStub(ContingentSyncStateRepository::class);
|
||||||
$this->entityManager = $this->createMock(EntityManagerInterface::class);
|
$this->entityManager = $this->createStub(EntityManagerInterface::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddsMissingDaysAndMarksSnapshotChanged(): void
|
public function testAddsMissingDaysAndMarksSnapshotChanged(): void
|
||||||
{
|
{
|
||||||
|
$this->entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
|
|
||||||
$this->dayRepository->method('findByAccommodationAndDateRange')->willReturn([]);
|
$this->dayRepository->method('findByAccommodationAndDateRange')->willReturn([]);
|
||||||
$this->dayRepository->method('findStatusFingerprintParts')->willReturn(['2026-07-01:OK', '2026-07-02:BLOCKED']);
|
$this->dayRepository->method('findStatusFingerprintParts')->willReturn(['2026-07-01:OK', '2026-07-02:BLOCKED']);
|
||||||
$this->client->method('getContingentCalendar')->willReturn($this->response([
|
$this->client->method('getContingentCalendar')->willReturn($this->response([
|
||||||
@@ -58,6 +60,8 @@ class ContingentSnapshotManagerTest extends TestCase
|
|||||||
|
|
||||||
public function testUpdatesChangedStatusAndRemovesVanishedDays(): void
|
public function testUpdatesChangedStatusAndRemovesVanishedDays(): void
|
||||||
{
|
{
|
||||||
|
$this->entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
|
|
||||||
$existing = [
|
$existing = [
|
||||||
'2026-07-01' => $this->day('2026-07-01', ContingentStatus::Ok),
|
'2026-07-01' => $this->day('2026-07-01', ContingentStatus::Ok),
|
||||||
'2026-07-02' => $this->day('2026-07-02', ContingentStatus::Ok),
|
'2026-07-02' => $this->day('2026-07-02', ContingentStatus::Ok),
|
||||||
@@ -104,6 +108,9 @@ class ContingentSnapshotManagerTest extends TestCase
|
|||||||
|
|
||||||
public function testUpstreamFailureKeepsSnapshotAndRecordsError(): void
|
public function testUpstreamFailureKeepsSnapshotAndRecordsError(): void
|
||||||
{
|
{
|
||||||
|
$this->dayRepository = $this->createMock(ContingentDayRepository::class);
|
||||||
|
$this->entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
|
|
||||||
$state = new ContingentSyncState($this->accommodation());
|
$state = new ContingentSyncState($this->accommodation());
|
||||||
$this->syncStateRepository->method('findOneByAccommodation')->willReturn($state);
|
$this->syncStateRepository->method('findOneByAccommodation')->willReturn($state);
|
||||||
$this->client->method('getContingentCalendar')->willThrowException(new BpnConnectException('upstream down'));
|
$this->client->method('getContingentCalendar')->willThrowException(new BpnConnectException('upstream down'));
|
||||||
@@ -121,6 +128,8 @@ class ContingentSnapshotManagerTest extends TestCase
|
|||||||
|
|
||||||
public function testEmptyUpstreamResponseDoesNotWipeAPopulatedRange(): void
|
public function testEmptyUpstreamResponseDoesNotWipeAPopulatedRange(): void
|
||||||
{
|
{
|
||||||
|
$this->entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
|
|
||||||
$state = new ContingentSyncState($this->accommodation());
|
$state = new ContingentSyncState($this->accommodation());
|
||||||
$this->syncStateRepository->method('findOneByAccommodation')->willReturn($state);
|
$this->syncStateRepository->method('findOneByAccommodation')->willReturn($state);
|
||||||
$this->dayRepository->method('findByAccommodationAndDateRange')->willReturn([
|
$this->dayRepository->method('findByAccommodationAndDateRange')->willReturn([
|
||||||
@@ -193,7 +202,7 @@ class ContingentSnapshotManagerTest extends TestCase
|
|||||||
$this->dayRepository,
|
$this->dayRepository,
|
||||||
$this->syncStateRepository,
|
$this->syncStateRepository,
|
||||||
$this->entityManager,
|
$this->entityManager,
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
return $manager->sync(
|
return $manager->sync(
|
||||||
|
|||||||
@@ -12,23 +12,25 @@ use App\Repository\Groups\ContingentDayRepository;
|
|||||||
use App\Repository\Groups\ContingentSyncStateRepository;
|
use App\Repository\Groups\ContingentSyncStateRepository;
|
||||||
use App\Service\ContingentSnapshotReader;
|
use App\Service\ContingentSnapshotReader;
|
||||||
use Carbon\CarbonImmutable;
|
use Carbon\CarbonImmutable;
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\Stub;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
class ContingentSnapshotReaderTest extends TestCase
|
class ContingentSnapshotReaderTest extends TestCase
|
||||||
{
|
{
|
||||||
private ContingentDayRepository&MockObject $dayRepository;
|
private ContingentDayRepository&Stub $dayRepository;
|
||||||
private ContingentSyncStateRepository&MockObject $syncStateRepository;
|
private ContingentSyncStateRepository&Stub $syncStateRepository;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->dayRepository = $this->createMock(ContingentDayRepository::class);
|
$this->dayRepository = $this->createStub(ContingentDayRepository::class);
|
||||||
$this->syncStateRepository = $this->createMock(ContingentSyncStateRepository::class);
|
$this->syncStateRepository = $this->createStub(ContingentSyncStateRepository::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testReturnsNullWhenNothingHasEverSynced(): void
|
public function testReturnsNullWhenNothingHasEverSynced(): void
|
||||||
{
|
{
|
||||||
|
$this->dayRepository = $this->createMock(ContingentDayRepository::class);
|
||||||
|
|
||||||
$this->syncStateRepository->method('findOneByAccommodation')->willReturn(null);
|
$this->syncStateRepository->method('findOneByAccommodation')->willReturn(null);
|
||||||
$this->dayRepository->expects(self::never())->method('findByHotelCodeAndDateRange');
|
$this->dayRepository->expects(self::never())->method('findByHotelCodeAndDateRange');
|
||||||
|
|
||||||
@@ -37,6 +39,8 @@ class ContingentSnapshotReaderTest extends TestCase
|
|||||||
|
|
||||||
public function testReturnsNullWhenTheSnapshotIsStale(): void
|
public function testReturnsNullWhenTheSnapshotIsStale(): void
|
||||||
{
|
{
|
||||||
|
$this->dayRepository = $this->createMock(ContingentDayRepository::class);
|
||||||
|
|
||||||
$this->syncStateRepository->method('findOneByAccommodation')->willReturn($this->state('-7 hours'));
|
$this->syncStateRepository->method('findOneByAccommodation')->willReturn($this->state('-7 hours'));
|
||||||
$this->dayRepository->expects(self::never())->method('findByHotelCodeAndDateRange');
|
$this->dayRepository->expects(self::never())->method('findByHotelCodeAndDateRange');
|
||||||
|
|
||||||
@@ -67,6 +71,8 @@ class ContingentSnapshotReaderTest extends TestCase
|
|||||||
|
|
||||||
public function testReturnsNullForAnAccommodationWithoutACalendarCode(): void
|
public function testReturnsNullForAnAccommodationWithoutACalendarCode(): void
|
||||||
{
|
{
|
||||||
|
$this->syncStateRepository = $this->createMock(ContingentSyncStateRepository::class);
|
||||||
|
|
||||||
$this->syncStateRepository->expects(self::never())->method('findOneByAccommodation');
|
$this->syncStateRepository->expects(self::never())->method('findOneByAccommodation');
|
||||||
|
|
||||||
self::assertNull($this->read(new Accommodation()));
|
self::assertNull($this->read(new Accommodation()));
|
||||||
@@ -80,7 +86,7 @@ class ContingentSnapshotReaderTest extends TestCase
|
|||||||
$reader = new ContingentSnapshotReader(
|
$reader = new ContingentSnapshotReader(
|
||||||
$this->dayRepository,
|
$this->dayRepository,
|
||||||
$this->syncStateRepository,
|
$this->syncStateRepository,
|
||||||
$this->createMock(LoggerInterface::class),
|
$this->createStub(LoggerInterface::class),
|
||||||
);
|
);
|
||||||
|
|
||||||
return $reader->statusesFor(
|
return $reader->statusesFor(
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class DatabaseAnonymizerTest extends TestCase
|
|||||||
public function testAnonymizeEntityMethodsReuseSharedIdentityAndPreserveDraftTimestamps(): void
|
public function testAnonymizeEntityMethodsReuseSharedIdentityAndPreserveDraftTimestamps(): void
|
||||||
{
|
{
|
||||||
$service = new DatabaseAnonymizer(
|
$service = new DatabaseAnonymizer(
|
||||||
$this->createMock(EntityManagerInterface::class),
|
$this->createStub(EntityManagerInterface::class),
|
||||||
new NullLogger(),
|
new NullLogger(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ class FamilyInsuranceAvailabilityCheckerTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->insuranceService = $this->createMock(InsuranceManager::class);
|
$this->insuranceService = $this->createStub(InsuranceManager::class);
|
||||||
$this->priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
$this->priceCalculatorService = $this->createStub(BookingPriceCalculator::class);
|
||||||
|
|
||||||
$this->insuranceService->method('getSelectableInsurances')
|
$this->insuranceService->method('getSelectableInsurances')
|
||||||
->willReturnCallback(fn (Travel $travel) => $travel->insurances ?? []);
|
->willReturnCallback(fn (Travel $travel) => $travel->insurances ?? []);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use App\Repository\NewsletterConsentRepository;
|
|||||||
use App\Repository\NewsletterOptInRequestRepository;
|
use App\Repository\NewsletterOptInRequestRepository;
|
||||||
use App\Service\NewsletterManager;
|
use App\Service\NewsletterManager;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Psr\Log\NullLogger;
|
use Psr\Log\NullLogger;
|
||||||
@@ -152,10 +153,13 @@ class NewsletterManagerTest extends TestCase
|
|||||||
|
|
||||||
$mailjet->expects(self::never())->method('isSubscribed');
|
$mailjet->expects(self::never())->method('isSubscribed');
|
||||||
$mailjet->expects(self::once())->method('upsertContact')->with('[email protected]', 'Mia', 'Muster');
|
$mailjet->expects(self::once())->method('upsertContact')->with('[email protected]', 'Mia', 'Muster');
|
||||||
|
$ensureSubscribedCalls = [];
|
||||||
$mailjet
|
$mailjet
|
||||||
->expects(self::exactly(2))
|
->expects(self::exactly(2))
|
||||||
->method('ensureSubscribed')
|
->method('ensureSubscribed')
|
||||||
->withConsecutive(['[email protected]', 1], ['[email protected]', 2]);
|
->willReturnCallback(static function (string $email, ?int $listId) use (&$ensureSubscribedCalls): void {
|
||||||
|
$ensureSubscribedCalls[] = [$email, $listId];
|
||||||
|
});
|
||||||
$consents->method('findActiveByEmail')->with('[email protected]')->willReturn($existingConsent);
|
$consents->method('findActiveByEmail')->with('[email protected]')->willReturn($existingConsent);
|
||||||
$consents
|
$consents
|
||||||
->method('findOneByEmailAndListId')
|
->method('findOneByEmailAndListId')
|
||||||
@@ -184,6 +188,7 @@ class NewsletterManagerTest extends TestCase
|
|||||||
1 => NewsletterSubscriptionRequestResult::LIST_STATE_ALREADY_REGISTERED,
|
1 => NewsletterSubscriptionRequestResult::LIST_STATE_ALREADY_REGISTERED,
|
||||||
2 => NewsletterSubscriptionRequestResult::LIST_STATE_ALREADY_REGISTERED,
|
2 => NewsletterSubscriptionRequestResult::LIST_STATE_ALREADY_REGISTERED,
|
||||||
], $result->listStates);
|
], $result->listStates);
|
||||||
|
self::assertSame([['[email protected]', 1], ['[email protected]', 2]], $ensureSubscribedCalls);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testApiRequestRejectsUnknownListIdsBeforeSideEffects(): void
|
public function testApiRequestRejectsUnknownListIdsBeforeSideEffects(): void
|
||||||
@@ -192,7 +197,7 @@ class NewsletterManagerTest extends TestCase
|
|||||||
$consents = $this->createMock(NewsletterConsentRepository::class);
|
$consents = $this->createMock(NewsletterConsentRepository::class);
|
||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
$mailjet = $this->createMock(ApiClient::class);
|
$mailjet = $this->createMock(ApiClient::class);
|
||||||
$mailer = $this->createMock(Mailer::class);
|
$mailer = $this->createStub(Mailer::class);
|
||||||
|
|
||||||
$mailjet->expects(self::never())->method('isSubscribed');
|
$mailjet->expects(self::never())->method('isSubscribed');
|
||||||
$mailjet->expects(self::never())->method('ensureSubscribed');
|
$mailjet->expects(self::never())->method('ensureSubscribed');
|
||||||
@@ -252,7 +257,7 @@ class NewsletterManagerTest extends TestCase
|
|||||||
$consents = $this->createMock(NewsletterConsentRepository::class);
|
$consents = $this->createMock(NewsletterConsentRepository::class);
|
||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
$mailjet = $this->createMock(ApiClient::class);
|
$mailjet = $this->createMock(ApiClient::class);
|
||||||
$mailer = $this->createMock(Mailer::class);
|
$mailer = $this->createStub(Mailer::class);
|
||||||
|
|
||||||
$mailjet->expects(self::never())->method('isSubscribed');
|
$mailjet->expects(self::never())->method('isSubscribed');
|
||||||
$mailjet->expects(self::once())->method('upsertContact')->with('[email protected]', 'Mia', 'Muster');
|
$mailjet->expects(self::once())->method('upsertContact')->with('[email protected]', 'Mia', 'Muster');
|
||||||
@@ -274,7 +279,7 @@ class NewsletterManagerTest extends TestCase
|
|||||||
public function testDefaultRequestCreatesDefaultListPendingConfirmation(): void
|
public function testDefaultRequestCreatesDefaultListPendingConfirmation(): void
|
||||||
{
|
{
|
||||||
$repository = $this->createMock(NewsletterOptInRequestRepository::class);
|
$repository = $this->createMock(NewsletterOptInRequestRepository::class);
|
||||||
$consents = $this->createMock(NewsletterConsentRepository::class);
|
$consents = $this->createStub(NewsletterConsentRepository::class);
|
||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
$mailjet = $this->createMock(ApiClient::class);
|
$mailjet = $this->createMock(ApiClient::class);
|
||||||
$mailer = $this->createMock(Mailer::class);
|
$mailer = $this->createMock(Mailer::class);
|
||||||
@@ -301,7 +306,7 @@ class NewsletterManagerTest extends TestCase
|
|||||||
public function testRequestConfirmationTruncatesNamesBeforePersisting(): void
|
public function testRequestConfirmationTruncatesNamesBeforePersisting(): void
|
||||||
{
|
{
|
||||||
$repository = $this->createMock(NewsletterOptInRequestRepository::class);
|
$repository = $this->createMock(NewsletterOptInRequestRepository::class);
|
||||||
$consents = $this->createMock(NewsletterConsentRepository::class);
|
$consents = $this->createStub(NewsletterConsentRepository::class);
|
||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
$mailjet = $this->createMock(ApiClient::class);
|
$mailjet = $this->createMock(ApiClient::class);
|
||||||
$mailer = $this->createMock(Mailer::class);
|
$mailer = $this->createMock(Mailer::class);
|
||||||
@@ -340,7 +345,7 @@ class NewsletterManagerTest extends TestCase
|
|||||||
$consents = $this->createMock(NewsletterConsentRepository::class);
|
$consents = $this->createMock(NewsletterConsentRepository::class);
|
||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
$mailjet = $this->createMock(ApiClient::class);
|
$mailjet = $this->createMock(ApiClient::class);
|
||||||
$mailer = $this->createMock(Mailer::class);
|
$mailer = $this->createStub(Mailer::class);
|
||||||
|
|
||||||
$repository->expects(self::once())->method('findByTokenHash')->with(hash('sha256', $token))->willReturn($confirmation);
|
$repository->expects(self::once())->method('findByTokenHash')->with(hash('sha256', $token))->willReturn($confirmation);
|
||||||
$repository->expects(self::never())->method('deletePendingByEmail');
|
$repository->expects(self::never())->method('deletePendingByEmail');
|
||||||
@@ -371,16 +376,19 @@ class NewsletterManagerTest extends TestCase
|
|||||||
$consents = $this->createMock(NewsletterConsentRepository::class);
|
$consents = $this->createMock(NewsletterConsentRepository::class);
|
||||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
$mailjet = $this->createMock(ApiClient::class);
|
$mailjet = $this->createMock(ApiClient::class);
|
||||||
$mailer = $this->createMock(Mailer::class);
|
$mailer = $this->createStub(Mailer::class);
|
||||||
|
|
||||||
$repository->expects(self::once())->method('findByTokenHash')->with(hash('sha256', $token))->willReturn($confirmation);
|
$repository->expects(self::once())->method('findByTokenHash')->with(hash('sha256', $token))->willReturn($confirmation);
|
||||||
$repository->expects(self::never())->method('deletePendingByEmail');
|
$repository->expects(self::never())->method('deletePendingByEmail');
|
||||||
$consents->method('findOneByEmailAndListId')->willReturn(null);
|
$consents->method('findOneByEmailAndListId')->willReturn(null);
|
||||||
$consents->method('findByEmailAndListIds')->with('[email protected]', [1, 2])->willReturn([]);
|
$consents->method('findByEmailAndListIds')->with('[email protected]', [1, 2])->willReturn([]);
|
||||||
|
$ensureSubscribedCalls = [];
|
||||||
$mailjet
|
$mailjet
|
||||||
->expects(self::exactly(2))
|
->expects(self::exactly(2))
|
||||||
->method('ensureSubscribed')
|
->method('ensureSubscribed')
|
||||||
->withConsecutive(['[email protected]', 1], ['[email protected]', 2]);
|
->willReturnCallback(static function (string $email, ?int $listId) use (&$ensureSubscribedCalls): void {
|
||||||
|
$ensureSubscribedCalls[] = [$email, $listId];
|
||||||
|
});
|
||||||
$entityManager->expects(self::exactly(2))->method('persist')->with(self::isInstanceOf(NewsletterConsent::class));
|
$entityManager->expects(self::exactly(2))->method('persist')->with(self::isInstanceOf(NewsletterConsent::class));
|
||||||
$entityManager->expects(self::once())->method('remove')->with($confirmation);
|
$entityManager->expects(self::once())->method('remove')->with($confirmation);
|
||||||
$entityManager->expects(self::once())->method('flush');
|
$entityManager->expects(self::once())->method('flush');
|
||||||
@@ -389,6 +397,7 @@ class NewsletterManagerTest extends TestCase
|
|||||||
->confirmToken($token);
|
->confirmToken($token);
|
||||||
|
|
||||||
self::assertSame(NewsletterConfirmationResult::STATUS_CONFIRMED, $result->status);
|
self::assertSame(NewsletterConfirmationResult::STATUS_CONFIRMED, $result->status);
|
||||||
|
self::assertSame([['[email protected]', 1], ['[email protected]', 2]], $ensureSubscribedCalls);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConfirmationEntityNormalizesMailjetListIds(): void
|
public function testConfirmationEntityNormalizesMailjetListIds(): void
|
||||||
@@ -403,9 +412,7 @@ class NewsletterManagerTest extends TestCase
|
|||||||
self::assertSame([1, 2], $confirmation->getMailjetListIds());
|
self::assertSame([1, 2], $confirmation->getMailjetListIds());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[DataProvider('invalidEntityMailjetListIdProvider')]
|
||||||
* @dataProvider invalidEntityMailjetListIdProvider
|
|
||||||
*/
|
|
||||||
public function testConfirmationEntityRejectsInvalidMailjetListIds(mixed $mailjetListId): void
|
public function testConfirmationEntityRejectsInvalidMailjetListIds(mixed $mailjetListId): void
|
||||||
{
|
{
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Tests\Service;
|
namespace App\Tests\Service;
|
||||||
|
|
||||||
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
|
||||||
use Symfony\Component\Validator\ConstraintViolationInterface;
|
|
||||||
use Symfony\Component\Validator\ConstraintViolationList;
|
|
||||||
use App\BusProNet\Model\Booking;
|
use App\BusProNet\Model\Booking;
|
||||||
use App\BusProNet\Model\Room;
|
use App\BusProNet\Model\Room;
|
||||||
use App\BusProNet\Model\Surcharge;
|
use App\BusProNet\Model\Surcharge;
|
||||||
@@ -18,19 +15,26 @@ use App\Form\Model\ParticipantEditDto;
|
|||||||
use App\Service\BookingPriceCalculator;
|
use App\Service\BookingPriceCalculator;
|
||||||
use App\Service\ParticipantCardAssembler;
|
use App\Service\ParticipantCardAssembler;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\Validator\ConstraintViolationInterface;
|
||||||
|
use Symfony\Component\Validator\ConstraintViolationList;
|
||||||
|
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
|
|
||||||
class ParticipantCardAssemblerTest extends TestCase
|
class ParticipantCardAssemblerTest extends TestCase
|
||||||
{
|
{
|
||||||
private ParticipantCardAssembler $service;
|
private ?ParticipantCardAssembler $service = null;
|
||||||
private BookingPriceCalculator $priceCalculator;
|
private BookingPriceCalculator $priceCalculator;
|
||||||
private ValidatorInterface $validator;
|
private ValidatorInterface $validator;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->priceCalculator = $this->createMock(BookingPriceCalculator::class);
|
$this->priceCalculator = $this->createStub(BookingPriceCalculator::class);
|
||||||
$this->validator = $this->createMock(ValidatorInterface::class);
|
$this->validator = $this->createStub(ValidatorInterface::class);
|
||||||
$this->service = new ParticipantCardAssembler(
|
}
|
||||||
|
|
||||||
|
private function service(): ParticipantCardAssembler
|
||||||
|
{
|
||||||
|
return $this->service ??= new ParticipantCardAssembler(
|
||||||
$this->priceCalculator,
|
$this->priceCalculator,
|
||||||
$this->validator
|
$this->validator
|
||||||
);
|
);
|
||||||
@@ -38,6 +42,8 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
|
|
||||||
public function testGetCardDataWithFullParticipantData(): void
|
public function testGetCardDataWithFullParticipantData(): void
|
||||||
{
|
{
|
||||||
|
$this->priceCalculator = $this->createMock(BookingPriceCalculator::class);
|
||||||
|
|
||||||
// Create test room
|
// Create test room
|
||||||
$room = new Room();
|
$room = new Room();
|
||||||
$room->id = 1;
|
$room->id = 1;
|
||||||
@@ -63,7 +69,7 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
->with($bookingDto)
|
->with($bookingDto)
|
||||||
->willReturn([450.50]);
|
->willReturn([450.50]);
|
||||||
|
|
||||||
$result = $this->service->getCardData($bookingDto, 0);
|
$result = $this->service()->getCardData($bookingDto, 0);
|
||||||
|
|
||||||
$this->assertSame('Max Mustermann', $result->name);
|
$this->assertSame('Max Mustermann', $result->name);
|
||||||
$this->assertSame('Doppelzimmer', $result->roomName);
|
$this->assertSame('Doppelzimmer', $result->roomName);
|
||||||
@@ -88,7 +94,7 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
->method('calculateAllParticipantIndividualPrices')
|
->method('calculateAllParticipantIndividualPrices')
|
||||||
->willReturn([0.0]);
|
->willReturn([0.0]);
|
||||||
|
|
||||||
$result = $this->service->getCardData($bookingDto, 0);
|
$result = $this->service()->getCardData($bookingDto, 0);
|
||||||
|
|
||||||
$this->assertSame('Max', $result->name);
|
$this->assertSame('Max', $result->name);
|
||||||
}
|
}
|
||||||
@@ -110,7 +116,7 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
->method('calculateAllParticipantIndividualPrices')
|
->method('calculateAllParticipantIndividualPrices')
|
||||||
->willReturn([0.0]);
|
->willReturn([0.0]);
|
||||||
|
|
||||||
$result = $this->service->getCardData($bookingDto, 0);
|
$result = $this->service()->getCardData($bookingDto, 0);
|
||||||
|
|
||||||
$this->assertSame('Anmelder:in', $result->name);
|
$this->assertSame('Anmelder:in', $result->name);
|
||||||
}
|
}
|
||||||
@@ -132,7 +138,7 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
->method('calculateAllParticipantIndividualPrices')
|
->method('calculateAllParticipantIndividualPrices')
|
||||||
->willReturn([0.0]);
|
->willReturn([0.0]);
|
||||||
|
|
||||||
$result = $this->service->getCardData($bookingDto, 0);
|
$result = $this->service()->getCardData($bookingDto, 0);
|
||||||
|
|
||||||
$this->assertSame('Anmelder:in', $result->name);
|
$this->assertSame('Anmelder:in', $result->name);
|
||||||
}
|
}
|
||||||
@@ -154,7 +160,7 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
->method('calculateAllParticipantIndividualPrices')
|
->method('calculateAllParticipantIndividualPrices')
|
||||||
->willReturn([0.0]);
|
->willReturn([0.0]);
|
||||||
|
|
||||||
$result = $this->service->getCardData($bookingDto, 0);
|
$result = $this->service()->getCardData($bookingDto, 0);
|
||||||
|
|
||||||
$this->assertSame('Kein Zimmer zugewiesen', $result->roomName);
|
$this->assertSame('Kein Zimmer zugewiesen', $result->roomName);
|
||||||
}
|
}
|
||||||
@@ -176,7 +182,7 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
->method('calculateAllParticipantIndividualPrices')
|
->method('calculateAllParticipantIndividualPrices')
|
||||||
->willReturn([0.0]);
|
->willReturn([0.0]);
|
||||||
|
|
||||||
$result = $this->service->getCardData($bookingDto, 0);
|
$result = $this->service()->getCardData($bookingDto, 0);
|
||||||
|
|
||||||
$this->assertSame('Unbekanntes Zimmer', $result->roomName);
|
$this->assertSame('Unbekanntes Zimmer', $result->roomName);
|
||||||
}
|
}
|
||||||
@@ -198,7 +204,7 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
->method('calculateAllParticipantIndividualPrices')
|
->method('calculateAllParticipantIndividualPrices')
|
||||||
->willReturn([0.0]);
|
->willReturn([0.0]);
|
||||||
|
|
||||||
$result = $this->service->getCardData($bookingDto, 0);
|
$result = $this->service()->getCardData($bookingDto, 0);
|
||||||
|
|
||||||
// When no room assigned and price is zero, display dash (incomplete configuration)
|
// When no room assigned and price is zero, display dash (incomplete configuration)
|
||||||
$this->assertNull($result->price->amount);
|
$this->assertNull($result->price->amount);
|
||||||
@@ -228,7 +234,7 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
->method('calculateAllParticipantIndividualPrices')
|
->method('calculateAllParticipantIndividualPrices')
|
||||||
->willReturn([0.0]);
|
->willReturn([0.0]);
|
||||||
|
|
||||||
$result = $this->service->getCardData($bookingDto, 0);
|
$result = $this->service()->getCardData($bookingDto, 0);
|
||||||
|
|
||||||
// When room is assigned but price is zero, display formatted zero price
|
// When room is assigned but price is zero, display formatted zero price
|
||||||
$this->assertSame(0.0, $result->price->amount);
|
$this->assertSame(0.0, $result->price->amount);
|
||||||
@@ -244,11 +250,13 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
$this->expectException(\InvalidArgumentException::class);
|
$this->expectException(\InvalidArgumentException::class);
|
||||||
$this->expectExceptionMessage('Participant at index 0 does not exist');
|
$this->expectExceptionMessage('Participant at index 0 does not exist');
|
||||||
|
|
||||||
$this->service->getCardData($bookingDto, 0);
|
$this->service()->getCardData($bookingDto, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetAllCardsDataWithMultipleParticipants(): void
|
public function testGetAllCardsDataWithMultipleParticipants(): void
|
||||||
{
|
{
|
||||||
|
$this->priceCalculator = $this->createMock(BookingPriceCalculator::class);
|
||||||
|
|
||||||
// Create test rooms
|
// Create test rooms
|
||||||
$room1 = new Room();
|
$room1 = new Room();
|
||||||
$room1->id = 1;
|
$room1->id = 1;
|
||||||
@@ -287,7 +295,7 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
->with($bookingDto)
|
->with($bookingDto)
|
||||||
->willReturn([450.0, 500.0, 480.0]);
|
->willReturn([450.0, 500.0, 480.0]);
|
||||||
|
|
||||||
$result = $this->service->getAllCardsData($bookingDto);
|
$result = $this->service()->getAllCardsData($bookingDto);
|
||||||
|
|
||||||
$this->assertCount(3, $result);
|
$this->assertCount(3, $result);
|
||||||
|
|
||||||
@@ -312,6 +320,8 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
|
|
||||||
public function testGetAllCardsDataUsesCanceledSurchargesBeforePrecomputedActivePrices(): void
|
public function testGetAllCardsDataUsesCanceledSurchargesBeforePrecomputedActivePrices(): void
|
||||||
{
|
{
|
||||||
|
$this->priceCalculator = $this->createMock(BookingPriceCalculator::class);
|
||||||
|
|
||||||
$room = new Room();
|
$room = new Room();
|
||||||
$room->id = 1;
|
$room->id = 1;
|
||||||
$room->label = 'Doppelzimmer';
|
$room->label = 'Doppelzimmer';
|
||||||
@@ -347,7 +357,7 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
->with($bookingDto)
|
->with($bookingDto)
|
||||||
->willReturn([0 => 450.0, 1 => 999.0]);
|
->willReturn([0 => 450.0, 1 => 999.0]);
|
||||||
|
|
||||||
$result = $this->service->getAllCardsData($bookingDto);
|
$result = $this->service()->getAllCardsData($bookingDto);
|
||||||
|
|
||||||
$this->assertSame(450.0, $result[0]->price->amount);
|
$this->assertSame(450.0, $result[0]->price->amount);
|
||||||
$this->assertSame(75.0, $result[1]->price->amount);
|
$this->assertSame(75.0, $result[1]->price->amount);
|
||||||
@@ -360,7 +370,7 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
$bookingDto = new BookingDto($travel, 1);
|
$bookingDto = new BookingDto($travel, 1);
|
||||||
$bookingDto->participants = [];
|
$bookingDto->participants = [];
|
||||||
|
|
||||||
$result = $this->service->getAllCardsData($bookingDto);
|
$result = $this->service()->getAllCardsData($bookingDto);
|
||||||
|
|
||||||
$this->assertEmpty($result);
|
$this->assertEmpty($result);
|
||||||
}
|
}
|
||||||
@@ -381,7 +391,7 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
->method('calculateAllParticipantIndividualPrices')
|
->method('calculateAllParticipantIndividualPrices')
|
||||||
->willReturn([1234.56]);
|
->willReturn([1234.56]);
|
||||||
|
|
||||||
$result = $this->service->getCardData($bookingDto, 0);
|
$result = $this->service()->getCardData($bookingDto, 0);
|
||||||
|
|
||||||
$this->assertSame(1234.56, $result->price->amount);
|
$this->assertSame(1234.56, $result->price->amount);
|
||||||
$this->assertFalse($result->price->showDash);
|
$this->assertFalse($result->price->showDash);
|
||||||
@@ -403,9 +413,9 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
->method('calculateAllParticipantIndividualPrices')
|
->method('calculateAllParticipantIndividualPrices')
|
||||||
->willReturn([0.0, 0.0, 0.0]);
|
->willReturn([0.0, 0.0, 0.0]);
|
||||||
|
|
||||||
$result1 = $this->service->getCardData($bookingDto, 0);
|
$result1 = $this->service()->getCardData($bookingDto, 0);
|
||||||
$result2 = $this->service->getCardData($bookingDto, 1);
|
$result2 = $this->service()->getCardData($bookingDto, 1);
|
||||||
$result3 = $this->service->getCardData($bookingDto, 2);
|
$result3 = $this->service()->getCardData($bookingDto, 2);
|
||||||
|
|
||||||
$this->assertSame('Anmelder:in', $result1->name);
|
$this->assertSame('Anmelder:in', $result1->name);
|
||||||
$this->assertSame('Teilnehmer:in', $result2->name);
|
$this->assertSame('Teilnehmer:in', $result2->name);
|
||||||
@@ -414,6 +424,8 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
|
|
||||||
public function testGetCardDataWithValidationReturnsValidCard(): void
|
public function testGetCardDataWithValidationReturnsValidCard(): void
|
||||||
{
|
{
|
||||||
|
$this->validator = $this->createMock(ValidatorInterface::class);
|
||||||
|
|
||||||
$room = new Room();
|
$room = new Room();
|
||||||
$room->id = 1;
|
$room->id = 1;
|
||||||
$room->label = 'Doppelzimmer';
|
$room->label = 'Doppelzimmer';
|
||||||
@@ -445,7 +457,7 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
->method('validate')
|
->method('validate')
|
||||||
->willReturn($violations);
|
->willReturn($violations);
|
||||||
|
|
||||||
$result = $this->service->getCardDataWithValidation($bookingDto, 0);
|
$result = $this->service()->getCardDataWithValidation($bookingDto, 0);
|
||||||
|
|
||||||
$this->assertSame('Max Mustermann', $result->name);
|
$this->assertSame('Max Mustermann', $result->name);
|
||||||
$this->assertSame('Doppelzimmer', $result->roomName);
|
$this->assertSame('Doppelzimmer', $result->roomName);
|
||||||
@@ -457,6 +469,8 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
|
|
||||||
public function testGetCardDataWithValidationReturnsInvalidCard(): void
|
public function testGetCardDataWithValidationReturnsInvalidCard(): void
|
||||||
{
|
{
|
||||||
|
$this->validator = $this->createMock(ValidatorInterface::class);
|
||||||
|
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
$travel->rooms = [];
|
$travel->rooms = [];
|
||||||
|
|
||||||
@@ -486,7 +500,7 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
->method('validate')
|
->method('validate')
|
||||||
->willReturn($violations);
|
->willReturn($violations);
|
||||||
|
|
||||||
$result = $this->service->getCardDataWithValidation($bookingDto, 0);
|
$result = $this->service()->getCardDataWithValidation($bookingDto, 0);
|
||||||
|
|
||||||
$this->assertSame('Max Mustermann', $result->name);
|
$this->assertSame('Max Mustermann', $result->name);
|
||||||
$this->assertFalse($result->isValid);
|
$this->assertFalse($result->isValid);
|
||||||
@@ -496,6 +510,9 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
|
|
||||||
public function testGetAllCardsDataWithValidationReturnsAllCards(): void
|
public function testGetAllCardsDataWithValidationReturnsAllCards(): void
|
||||||
{
|
{
|
||||||
|
$this->priceCalculator = $this->createMock(BookingPriceCalculator::class);
|
||||||
|
$this->validator = $this->createMock(ValidatorInterface::class);
|
||||||
|
|
||||||
$room = new Room();
|
$room = new Room();
|
||||||
$room->id = 1;
|
$room->id = 1;
|
||||||
$room->label = 'Doppelzimmer';
|
$room->label = 'Doppelzimmer';
|
||||||
@@ -534,7 +551,7 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
->method('validate')
|
->method('validate')
|
||||||
->willReturn($violations);
|
->willReturn($violations);
|
||||||
|
|
||||||
$result = $this->service->getAllCardsDataWithValidation($bookingDto);
|
$result = $this->service()->getAllCardsDataWithValidation($bookingDto);
|
||||||
|
|
||||||
$this->assertCount(2, $result);
|
$this->assertCount(2, $result);
|
||||||
$this->assertTrue($result[0]->isValid);
|
$this->assertTrue($result[0]->isValid);
|
||||||
@@ -545,6 +562,8 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
|
|
||||||
public function testGetCardDataWithValidationCanForceStrictRequiredInEditMode(): void
|
public function testGetCardDataWithValidationCanForceStrictRequiredInEditMode(): void
|
||||||
{
|
{
|
||||||
|
$this->validator = $this->createMock(ValidatorInterface::class);
|
||||||
|
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
$travel->rooms = [];
|
$travel->rooms = [];
|
||||||
|
|
||||||
@@ -556,7 +575,7 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
|
|
||||||
$bookingDto = new BookingDto($travel, 1);
|
$bookingDto = new BookingDto($travel, 1);
|
||||||
$bookingDto->agencyCode = AgencyLoader::INTERNAL_AGENCY_CODE;
|
$bookingDto->agencyCode = AgencyLoader::INTERNAL_AGENCY_CODE;
|
||||||
$bookingDto->booking = new \App\BusProNet\Model\Booking();
|
$bookingDto->booking = new Booking();
|
||||||
$bookingDto->participants = [$participant];
|
$bookingDto->participants = [$participant];
|
||||||
|
|
||||||
$this->priceCalculator
|
$this->priceCalculator
|
||||||
@@ -574,16 +593,15 @@ class ParticipantCardAssemblerTest extends TestCase
|
|||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('validate')
|
->method('validate')
|
||||||
->with(
|
->with(
|
||||||
$this->isInstanceOf(\App\Form\Model\ParticipantEditDto::class),
|
$this->isInstanceOf(ParticipantEditDto::class),
|
||||||
null,
|
null,
|
||||||
['booking_edit', 'strict_required']
|
['booking_edit', 'strict_required']
|
||||||
)
|
)
|
||||||
->willReturn($violations);
|
->willReturn($violations);
|
||||||
|
|
||||||
$result = $this->service->getCardDataWithValidation($bookingDto, 0, true);
|
$result = $this->service()->getCardDataWithValidation($bookingDto, 0, true);
|
||||||
|
|
||||||
$this->assertFalse($result->isValid);
|
$this->assertFalse($result->isValid);
|
||||||
$this->assertSame(['Bitte angeben'], $result->errorMessages);
|
$this->assertSame(['Bitte angeben'], $result->errorMessages);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,15 +23,18 @@ class ParticipantDataPrefillerTest extends TestCase
|
|||||||
private ApiClient $apiClient;
|
private ApiClient $apiClient;
|
||||||
private Crypt $crypt;
|
private Crypt $crypt;
|
||||||
private LoggerInterface $logger;
|
private LoggerInterface $logger;
|
||||||
private ParticipantDataPrefiller $service;
|
private ?ParticipantDataPrefiller $service = null;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->apiClient = $this->createMock(ApiClient::class);
|
$this->apiClient = $this->createStub(ApiClient::class);
|
||||||
$this->crypt = $this->createMock(Crypt::class);
|
$this->crypt = $this->createStub(Crypt::class);
|
||||||
$this->logger = $this->createMock(LoggerInterface::class);
|
$this->logger = $this->createStub(LoggerInterface::class);
|
||||||
|
}
|
||||||
|
|
||||||
$this->service = new ParticipantDataPrefiller(
|
private function service(): ParticipantDataPrefiller
|
||||||
|
{
|
||||||
|
return $this->service ??= new ParticipantDataPrefiller(
|
||||||
$this->apiClient,
|
$this->apiClient,
|
||||||
$this->crypt,
|
$this->crypt,
|
||||||
$this->logger
|
$this->logger
|
||||||
@@ -40,6 +43,9 @@ class ParticipantDataPrefillerTest extends TestCase
|
|||||||
|
|
||||||
public function testPrepopulateApplicantWithCompletePersonalData(): void
|
public function testPrepopulateApplicantWithCompletePersonalData(): void
|
||||||
{
|
{
|
||||||
|
$this->apiClient = $this->createMock(ApiClient::class);
|
||||||
|
$this->crypt = $this->createMock(Crypt::class);
|
||||||
|
|
||||||
$user = $this->createUser('[email protected]', 'encrypted_password');
|
$user = $this->createUser('[email protected]', 'encrypted_password');
|
||||||
$applicant = new ParticipantDto();
|
$applicant = new ParticipantDto();
|
||||||
$applicant->index = 0;
|
$applicant->index = 0;
|
||||||
@@ -56,7 +62,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
|||||||
->with('[email protected]', 'decrypted_password')
|
->with('[email protected]', 'decrypted_password')
|
||||||
->willReturn($personalData);
|
->willReturn($personalData);
|
||||||
|
|
||||||
$result = $this->service->prefillApplicantFromUser($user, $applicant);
|
$result = $this->service()->prefillApplicantFromUser($user, $applicant);
|
||||||
|
|
||||||
// BPN API IDs for linking to existing records
|
// BPN API IDs for linking to existing records
|
||||||
$this->assertSame(12345, $result->addressId);
|
$this->assertSame(12345, $result->addressId);
|
||||||
@@ -88,6 +94,9 @@ class ParticipantDataPrefillerTest extends TestCase
|
|||||||
|
|
||||||
public function testPrepopulateApplicantWithPartialPersonalData(): void
|
public function testPrepopulateApplicantWithPartialPersonalData(): void
|
||||||
{
|
{
|
||||||
|
$this->apiClient = $this->createMock(ApiClient::class);
|
||||||
|
$this->crypt = $this->createMock(Crypt::class);
|
||||||
|
|
||||||
$user = $this->createUser('[email protected]', 'encrypted_password');
|
$user = $this->createUser('[email protected]', 'encrypted_password');
|
||||||
$applicant = new ParticipantDto();
|
$applicant = new ParticipantDto();
|
||||||
$applicant->index = 0;
|
$applicant->index = 0;
|
||||||
@@ -102,7 +111,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
|||||||
->method('getPersonalData')
|
->method('getPersonalData')
|
||||||
->willReturn($personalData);
|
->willReturn($personalData);
|
||||||
|
|
||||||
$result = $this->service->prefillApplicantFromUser($user, $applicant);
|
$result = $this->service()->prefillApplicantFromUser($user, $applicant);
|
||||||
|
|
||||||
// Required fields should be populated
|
// Required fields should be populated
|
||||||
$this->assertSame('Jane', $result->firstName);
|
$this->assertSame('Jane', $result->firstName);
|
||||||
@@ -123,6 +132,10 @@ class ParticipantDataPrefillerTest extends TestCase
|
|||||||
|
|
||||||
public function testPrepopulateApplicantWithApiNotificationError(): void
|
public function testPrepopulateApplicantWithApiNotificationError(): void
|
||||||
{
|
{
|
||||||
|
$this->apiClient = $this->createMock(ApiClient::class);
|
||||||
|
$this->crypt = $this->createMock(Crypt::class);
|
||||||
|
$this->logger = $this->createMock(LoggerInterface::class);
|
||||||
|
|
||||||
$user = $this->createUser('[email protected]', 'encrypted_password');
|
$user = $this->createUser('[email protected]', 'encrypted_password');
|
||||||
$applicant = new ParticipantDto();
|
$applicant = new ParticipantDto();
|
||||||
$applicant->index = 0;
|
$applicant->index = 0;
|
||||||
@@ -148,7 +161,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
|||||||
$this->logger->expects($this->never())
|
$this->logger->expects($this->never())
|
||||||
->method('info');
|
->method('info');
|
||||||
|
|
||||||
$result = $this->service->prefillApplicantFromUser($user, $applicant);
|
$result = $this->service()->prefillApplicantFromUser($user, $applicant);
|
||||||
|
|
||||||
// Should return unchanged applicant
|
// Should return unchanged applicant
|
||||||
$this->assertNull($result->firstName);
|
$this->assertNull($result->firstName);
|
||||||
@@ -158,6 +171,10 @@ class ParticipantDataPrefillerTest extends TestCase
|
|||||||
|
|
||||||
public function testPrepopulateApplicantWithDecryptionException(): void
|
public function testPrepopulateApplicantWithDecryptionException(): void
|
||||||
{
|
{
|
||||||
|
$this->apiClient = $this->createMock(ApiClient::class);
|
||||||
|
$this->crypt = $this->createMock(Crypt::class);
|
||||||
|
$this->logger = $this->createMock(LoggerInterface::class);
|
||||||
|
|
||||||
$user = $this->createUser('[email protected]', 'encrypted_password');
|
$user = $this->createUser('[email protected]', 'encrypted_password');
|
||||||
$applicant = new ParticipantDto();
|
$applicant = new ParticipantDto();
|
||||||
$applicant->index = 0;
|
$applicant->index = 0;
|
||||||
@@ -176,7 +193,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
|||||||
'email' => '[email protected]',
|
'email' => '[email protected]',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$result = $this->service->prefillApplicantFromUser($user, $applicant);
|
$result = $this->service()->prefillApplicantFromUser($user, $applicant);
|
||||||
|
|
||||||
// Should return unchanged applicant
|
// Should return unchanged applicant
|
||||||
$this->assertNull($result->firstName);
|
$this->assertNull($result->firstName);
|
||||||
@@ -186,6 +203,10 @@ class ParticipantDataPrefillerTest extends TestCase
|
|||||||
|
|
||||||
public function testPrepopulateApplicantWithApiException(): void
|
public function testPrepopulateApplicantWithApiException(): void
|
||||||
{
|
{
|
||||||
|
$this->apiClient = $this->createMock(ApiClient::class);
|
||||||
|
$this->crypt = $this->createMock(Crypt::class);
|
||||||
|
$this->logger = $this->createMock(LoggerInterface::class);
|
||||||
|
|
||||||
$user = $this->createUser('[email protected]', 'encrypted_password');
|
$user = $this->createUser('[email protected]', 'encrypted_password');
|
||||||
$applicant = new ParticipantDto();
|
$applicant = new ParticipantDto();
|
||||||
$applicant->index = 0;
|
$applicant->index = 0;
|
||||||
@@ -205,7 +226,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
|||||||
'email' => '[email protected]',
|
'email' => '[email protected]',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$result = $this->service->prefillApplicantFromUser($user, $applicant);
|
$result = $this->service()->prefillApplicantFromUser($user, $applicant);
|
||||||
|
|
||||||
// Should return unchanged applicant
|
// Should return unchanged applicant
|
||||||
$this->assertNull($result->firstName);
|
$this->assertNull($result->firstName);
|
||||||
@@ -215,6 +236,9 @@ class ParticipantDataPrefillerTest extends TestCase
|
|||||||
|
|
||||||
public function testPrepopulatePreservesBookingSpecificFields(): void
|
public function testPrepopulatePreservesBookingSpecificFields(): void
|
||||||
{
|
{
|
||||||
|
$this->apiClient = $this->createMock(ApiClient::class);
|
||||||
|
$this->crypt = $this->createMock(Crypt::class);
|
||||||
|
|
||||||
$user = $this->createUser('[email protected]', 'encrypted_password');
|
$user = $this->createUser('[email protected]', 'encrypted_password');
|
||||||
$applicant = new ParticipantDto();
|
$applicant = new ParticipantDto();
|
||||||
$applicant->index = 0;
|
$applicant->index = 0;
|
||||||
@@ -231,7 +255,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
|||||||
->method('getPersonalData')
|
->method('getPersonalData')
|
||||||
->willReturn($personalData);
|
->willReturn($personalData);
|
||||||
|
|
||||||
$result = $this->service->prefillApplicantFromUser($user, $applicant);
|
$result = $this->service()->prefillApplicantFromUser($user, $applicant);
|
||||||
|
|
||||||
// Personal data should be updated
|
// Personal data should be updated
|
||||||
$this->assertSame('John', $result->firstName);
|
$this->assertSame('John', $result->firstName);
|
||||||
@@ -250,8 +274,8 @@ class ParticipantDataPrefillerTest extends TestCase
|
|||||||
$filled = new ParticipantDto();
|
$filled = new ParticipantDto();
|
||||||
$filled->firstName = 'Already set';
|
$filled->firstName = 'Already set';
|
||||||
|
|
||||||
$this->assertTrue($this->service->shouldPrefillApplicant($fresh));
|
$this->assertTrue($this->service()->shouldPrefillApplicant($fresh));
|
||||||
$this->assertFalse($this->service->shouldPrefillApplicant($filled));
|
$this->assertFalse($this->service()->shouldPrefillApplicant($filled));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDummyTokenMatchesInCreateAndEditModes(): void
|
public function testDummyTokenMatchesInCreateAndEditModes(): void
|
||||||
@@ -259,8 +283,8 @@ class ParticipantDataPrefillerTest extends TestCase
|
|||||||
$participant = new ParticipantDto();
|
$participant = new ParticipantDto();
|
||||||
$participant->lastName = ParticipantDataPrefiller::TOKEN;
|
$participant->lastName = ParticipantDataPrefiller::TOKEN;
|
||||||
|
|
||||||
$this->assertTrue($this->service->isDummyDataFillRequested($participant, BookingDto::MODE_CREATE));
|
$this->assertTrue($this->service()->isDummyDataFillRequested($participant, BookingDto::MODE_CREATE));
|
||||||
$this->assertTrue($this->service->isDummyDataFillRequested($participant, BookingDto::MODE_EDIT));
|
$this->assertTrue($this->service()->isDummyDataFillRequested($participant, BookingDto::MODE_EDIT));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFillDummyParticipantSetsGeneratedData(): void
|
public function testFillDummyParticipantSetsGeneratedData(): void
|
||||||
@@ -268,7 +292,7 @@ class ParticipantDataPrefillerTest extends TestCase
|
|||||||
CarbonImmutable::setTestNow(CarbonImmutable::create(2026, 1, 15, 14, 30));
|
CarbonImmutable::setTestNow(CarbonImmutable::create(2026, 1, 15, 14, 30));
|
||||||
|
|
||||||
$participant = new ParticipantDto();
|
$participant = new ParticipantDto();
|
||||||
$this->service->fillDummyParticipant($participant, 0);
|
$this->service()->fillDummyParticipant($participant, 0);
|
||||||
|
|
||||||
$this->assertSame('Vorname 1', $participant->firstName);
|
$this->assertSame('Vorname 1', $participant->firstName);
|
||||||
$this->assertSame('Muster 1 14:30', $participant->lastName);
|
$this->assertSame('Muster 1 14:30', $participant->lastName);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use App\Form\Model\BookingDto;
|
|||||||
use App\Form\Model\ParticipantDto;
|
use App\Form\Model\ParticipantDto;
|
||||||
use App\Form\Model\RoomSelectionDto;
|
use App\Form\Model\RoomSelectionDto;
|
||||||
use App\Service\RoomAssigner;
|
use App\Service\RoomAssigner;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,9 +26,7 @@ class RoomAssignerTest extends TestCase
|
|||||||
$this->service = new RoomAssigner();
|
$this->service = new RoomAssigner();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function shouldAutoAssignRoomsReturnsTrueForSingleRoomType(): void
|
public function shouldAutoAssignRoomsReturnsTrueForSingleRoomType(): void
|
||||||
{
|
{
|
||||||
$bookingDto = $this->createBookingDtoWithRoomSelections([
|
$bookingDto = $this->createBookingDtoWithRoomSelections([
|
||||||
@@ -39,9 +38,7 @@ class RoomAssignerTest extends TestCase
|
|||||||
self::assertTrue($result, 'Should auto-assign when exactly one room type is selected');
|
self::assertTrue($result, 'Should auto-assign when exactly one room type is selected');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function shouldAutoAssignRoomsReturnsFalseForMultipleRoomTypes(): void
|
public function shouldAutoAssignRoomsReturnsFalseForMultipleRoomTypes(): void
|
||||||
{
|
{
|
||||||
$bookingDto = $this->createBookingDtoWithRoomSelections([
|
$bookingDto = $this->createBookingDtoWithRoomSelections([
|
||||||
@@ -54,9 +51,7 @@ class RoomAssignerTest extends TestCase
|
|||||||
self::assertFalse($result, 'Should not auto-assign when multiple room types are selected');
|
self::assertFalse($result, 'Should not auto-assign when multiple room types are selected');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function shouldAutoAssignRoomsReturnsFalseForNoRoomSelections(): void
|
public function shouldAutoAssignRoomsReturnsFalseForNoRoomSelections(): void
|
||||||
{
|
{
|
||||||
$bookingDto = $this->createBookingDtoWithRoomSelections([]);
|
$bookingDto = $this->createBookingDtoWithRoomSelections([]);
|
||||||
@@ -66,9 +61,7 @@ class RoomAssignerTest extends TestCase
|
|||||||
self::assertFalse($result, 'Should not auto-assign when no rooms are selected');
|
self::assertFalse($result, 'Should not auto-assign when no rooms are selected');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function shouldAutoAssignRoomsIgnoresZeroQuantityRooms(): void
|
public function shouldAutoAssignRoomsIgnoresZeroQuantityRooms(): void
|
||||||
{
|
{
|
||||||
$bookingDto = $this->createBookingDtoWithRoomSelections([
|
$bookingDto = $this->createBookingDtoWithRoomSelections([
|
||||||
@@ -82,9 +75,7 @@ class RoomAssignerTest extends TestCase
|
|||||||
self::assertTrue($result, 'Should treat zero/null quantity as not selected');
|
self::assertTrue($result, 'Should treat zero/null quantity as not selected');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function assignParticipantsToRoomsWorksWithSingleRoomType(): void
|
public function assignParticipantsToRoomsWorksWithSingleRoomType(): void
|
||||||
{
|
{
|
||||||
$bookingDto = $this->createBookingDtoWithRoomSelections([
|
$bookingDto = $this->createBookingDtoWithRoomSelections([
|
||||||
@@ -117,9 +108,7 @@ class RoomAssignerTest extends TestCase
|
|||||||
self::assertSame(100, $bookingDto->participants[3]->assignedRoomId);
|
self::assertSame(100, $bookingDto->participants[3]->assignedRoomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function assignParticipantsToRoomsSkipsAssignmentWithMultipleRoomTypes(): void
|
public function assignParticipantsToRoomsSkipsAssignmentWithMultipleRoomTypes(): void
|
||||||
{
|
{
|
||||||
$bookingDto = $this->createBookingDtoWithRoomSelections([
|
$bookingDto = $this->createBookingDtoWithRoomSelections([
|
||||||
@@ -159,9 +148,7 @@ class RoomAssignerTest extends TestCase
|
|||||||
self::assertNull($bookingDto->participants[3]->assignedRoomId);
|
self::assertNull($bookingDto->participants[3]->assignedRoomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function assignParticipantsToRoomsHandlesMixedRoomCapacities(): void
|
public function assignParticipantsToRoomsHandlesMixedRoomCapacities(): void
|
||||||
{
|
{
|
||||||
$bookingDto = $this->createBookingDtoWithRoomSelections([
|
$bookingDto = $this->createBookingDtoWithRoomSelections([
|
||||||
@@ -190,9 +177,7 @@ class RoomAssignerTest extends TestCase
|
|||||||
self::assertSame(100, $bookingDto->participants[1]->assignedRoomId);
|
self::assertSame(100, $bookingDto->participants[1]->assignedRoomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function validateAndResetInvalidAssignmentsResetsOrphanedAssignments(): void
|
public function validateAndResetInvalidAssignmentsResetsOrphanedAssignments(): void
|
||||||
{
|
{
|
||||||
// Create DTO with only room 100 selected
|
// Create DTO with only room 100 selected
|
||||||
@@ -221,9 +206,7 @@ class RoomAssignerTest extends TestCase
|
|||||||
self::assertNull($bookingDto->participants[3]->assignedRoomId, 'Invalid assignment should be reset to null');
|
self::assertNull($bookingDto->participants[3]->assignedRoomId, 'Invalid assignment should be reset to null');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function validateAndResetInvalidAssignmentsReturnsFalseWhenAllValid(): void
|
public function validateAndResetInvalidAssignmentsReturnsFalseWhenAllValid(): void
|
||||||
{
|
{
|
||||||
$bookingDto = $this->createBookingDtoWithRoomSelections([
|
$bookingDto = $this->createBookingDtoWithRoomSelections([
|
||||||
@@ -245,9 +228,7 @@ class RoomAssignerTest extends TestCase
|
|||||||
self::assertSame(100, $bookingDto->participants[1]->assignedRoomId);
|
self::assertSame(100, $bookingDto->participants[1]->assignedRoomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function validateAndResetInvalidAssignmentsHandlesNullAssignments(): void
|
public function validateAndResetInvalidAssignmentsHandlesNullAssignments(): void
|
||||||
{
|
{
|
||||||
$bookingDto = $this->createBookingDtoWithRoomSelections([
|
$bookingDto = $this->createBookingDtoWithRoomSelections([
|
||||||
@@ -267,9 +248,7 @@ class RoomAssignerTest extends TestCase
|
|||||||
self::assertFalse($result, 'Should return false when only null assignments exist');
|
self::assertFalse($result, 'Should return false when only null assignments exist');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[Test]
|
||||||
* @test
|
|
||||||
*/
|
|
||||||
public function validateAndResetInvalidAssignmentsHandlesEmptySelectedRooms(): void
|
public function validateAndResetInvalidAssignmentsHandlesEmptySelectedRooms(): void
|
||||||
{
|
{
|
||||||
// All rooms have quantity 0 (none selected)
|
// All rooms have quantity 0 (none selected)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use Symfony\Contracts\Cache\CacheInterface;
|
|||||||
|
|
||||||
class TravelDataProviderTest extends TestCase
|
class TravelDataProviderTest extends TestCase
|
||||||
{
|
{
|
||||||
private TravelDataProvider $service;
|
private ?TravelDataProvider $service = null;
|
||||||
private TravelLoader $travelLoader;
|
private TravelLoader $travelLoader;
|
||||||
private ApiClient $apiClient;
|
private ApiClient $apiClient;
|
||||||
private CacheInterface $cache;
|
private CacheInterface $cache;
|
||||||
@@ -29,15 +29,18 @@ class TravelDataProviderTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->travelLoader = $this->createMock(TravelLoader::class);
|
$this->travelLoader = $this->createStub(TravelLoader::class);
|
||||||
$this->apiClient = $this->createMock(ApiClient::class);
|
$this->apiClient = $this->createStub(ApiClient::class);
|
||||||
$this->cache = $this->createMock(CacheInterface::class);
|
$this->cache = $this->createStub(CacheInterface::class);
|
||||||
$this->logger = $this->createMock(LoggerInterface::class);
|
$this->logger = $this->createStub(LoggerInterface::class);
|
||||||
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
$this->travelSnapshotService = $this->createStub(TravelSnapshotManager::class);
|
||||||
$this->travelLookupService = $this->createMock(TravelIndex::class);
|
$this->travelLookupService = $this->createStub(TravelIndex::class);
|
||||||
$this->travelEnrichmentService = $this->createMock(TravelEnricher::class);
|
$this->travelEnrichmentService = $this->createStub(TravelEnricher::class);
|
||||||
|
}
|
||||||
|
|
||||||
$this->service = new TravelDataProvider(
|
private function service(): TravelDataProvider
|
||||||
|
{
|
||||||
|
return $this->service ??= new TravelDataProvider(
|
||||||
$this->travelLoader,
|
$this->travelLoader,
|
||||||
$this->apiClient,
|
$this->apiClient,
|
||||||
$this->cache,
|
$this->cache,
|
||||||
@@ -52,6 +55,10 @@ class TravelDataProviderTest extends TestCase
|
|||||||
|
|
||||||
public function testGetTravelDataFromXmlSuccess(): void
|
public function testGetTravelDataFromXmlSuccess(): void
|
||||||
{
|
{
|
||||||
|
$this->travelLoader = $this->createMock(TravelLoader::class);
|
||||||
|
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
||||||
|
$this->travelEnrichmentService = $this->createMock(TravelEnricher::class);
|
||||||
|
|
||||||
$dateId = 12345;
|
$dateId = 12345;
|
||||||
$hotelId = 67890;
|
$hotelId = 67890;
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
@@ -75,13 +82,17 @@ class TravelDataProviderTest extends TestCase
|
|||||||
->method('upsertFromTravel')
|
->method('upsertFromTravel')
|
||||||
->with($travel);
|
->with($travel);
|
||||||
|
|
||||||
$result = $this->service->getTravelDataFromXml($dateId, $hotelId);
|
$result = $this->service()->getTravelDataFromXml($dateId, $hotelId);
|
||||||
|
|
||||||
$this->assertSame($travel, $result);
|
$this->assertSame($travel, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetTravelDataFromXmlSkipsSnapshotWhenEnrichmentFails(): void
|
public function testGetTravelDataFromXmlSkipsSnapshotWhenEnrichmentFails(): void
|
||||||
{
|
{
|
||||||
|
$this->travelLoader = $this->createMock(TravelLoader::class);
|
||||||
|
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
||||||
|
$this->travelEnrichmentService = $this->createMock(TravelEnricher::class);
|
||||||
|
|
||||||
$dateId = 12345;
|
$dateId = 12345;
|
||||||
$hotelId = 67890;
|
$hotelId = 67890;
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
@@ -104,13 +115,16 @@ class TravelDataProviderTest extends TestCase
|
|||||||
->expects($this->never())
|
->expects($this->never())
|
||||||
->method('upsertFromTravel');
|
->method('upsertFromTravel');
|
||||||
|
|
||||||
$result = $this->service->getTravelDataFromXml($dateId, $hotelId);
|
$result = $this->service()->getTravelDataFromXml($dateId, $hotelId);
|
||||||
|
|
||||||
$this->assertSame($travel, $result);
|
$this->assertSame($travel, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetTravelDataFromXmlNotFound(): void
|
public function testGetTravelDataFromXmlNotFound(): void
|
||||||
{
|
{
|
||||||
|
$this->travelLoader = $this->createMock(TravelLoader::class);
|
||||||
|
$this->travelEnrichmentService = $this->createMock(TravelEnricher::class);
|
||||||
|
|
||||||
$dateId = 12345;
|
$dateId = 12345;
|
||||||
$hotelId = 67890;
|
$hotelId = 67890;
|
||||||
|
|
||||||
@@ -125,11 +139,16 @@ class TravelDataProviderTest extends TestCase
|
|||||||
->method('enrichFromXml');
|
->method('enrichFromXml');
|
||||||
|
|
||||||
$this->expectException(TravelNotFoundException::class);
|
$this->expectException(TravelNotFoundException::class);
|
||||||
$this->service->getTravelDataFromXml($dateId, $hotelId);
|
$this->service()->getTravelDataFromXml($dateId, $hotelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetTravelDataFromApiSuccess(): void
|
public function testGetTravelDataFromApiSuccess(): void
|
||||||
{
|
{
|
||||||
|
$this->apiClient = $this->createMock(ApiClient::class);
|
||||||
|
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
||||||
|
$this->travelLookupService = $this->createMock(TravelIndex::class);
|
||||||
|
$this->travelEnrichmentService = $this->createMock(TravelEnricher::class);
|
||||||
|
|
||||||
$dateId = 12345;
|
$dateId = 12345;
|
||||||
$hotelId = 67890;
|
$hotelId = 67890;
|
||||||
$productId = 555;
|
$productId = 555;
|
||||||
@@ -159,13 +178,16 @@ class TravelDataProviderTest extends TestCase
|
|||||||
->method('upsertFromTravel')
|
->method('upsertFromTravel')
|
||||||
->with($travel);
|
->with($travel);
|
||||||
|
|
||||||
$result = $this->service->getTravelDataFromApi($dateId, $hotelId);
|
$result = $this->service()->getTravelDataFromApi($dateId, $hotelId);
|
||||||
|
|
||||||
$this->assertSame($travel, $result);
|
$this->assertSame($travel, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetTravelDataFromApiSnapshotFailureDoesNotDiscardApiTravel(): void
|
public function testGetTravelDataFromApiSnapshotFailureDoesNotDiscardApiTravel(): void
|
||||||
{
|
{
|
||||||
|
$this->logger = $this->createMock(LoggerInterface::class);
|
||||||
|
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
||||||
|
|
||||||
$dateId = 12345;
|
$dateId = 12345;
|
||||||
$hotelId = 67890;
|
$hotelId = 67890;
|
||||||
$productId = 555;
|
$productId = 555;
|
||||||
@@ -191,7 +213,7 @@ class TravelDataProviderTest extends TestCase
|
|||||||
->method('warning')
|
->method('warning')
|
||||||
->with('Failed to persist travel snapshot after API load', $this->arrayHasKey('dateId'));
|
->with('Failed to persist travel snapshot after API load', $this->arrayHasKey('dateId'));
|
||||||
|
|
||||||
$result = $this->service->getTravelDataFromApi($dateId, $hotelId);
|
$result = $this->service()->getTravelDataFromApi($dateId, $hotelId);
|
||||||
|
|
||||||
$this->assertNotNull($result);
|
$this->assertNotNull($result);
|
||||||
$this->assertSame($travel, $result);
|
$this->assertSame($travel, $result);
|
||||||
@@ -199,6 +221,9 @@ class TravelDataProviderTest extends TestCase
|
|||||||
|
|
||||||
public function testGetTravelDataFromApiCannotMapDateId(): void
|
public function testGetTravelDataFromApiCannotMapDateId(): void
|
||||||
{
|
{
|
||||||
|
$this->apiClient = $this->createMock(ApiClient::class);
|
||||||
|
$this->travelLookupService = $this->createMock(TravelIndex::class);
|
||||||
|
|
||||||
$dateId = 12345;
|
$dateId = 12345;
|
||||||
$hotelId = 67890;
|
$hotelId = 67890;
|
||||||
|
|
||||||
@@ -212,13 +237,15 @@ class TravelDataProviderTest extends TestCase
|
|||||||
->expects($this->never())
|
->expects($this->never())
|
||||||
->method('getTravelData');
|
->method('getTravelData');
|
||||||
|
|
||||||
$result = $this->service->getTravelDataFromApi($dateId, $hotelId);
|
$result = $this->service()->getTravelDataFromApi($dateId, $hotelId);
|
||||||
|
|
||||||
$this->assertNull($result);
|
$this->assertNull($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExistsLocallyDelegatesToLookupService(): void
|
public function testExistsLocallyDelegatesToLookupService(): void
|
||||||
{
|
{
|
||||||
|
$this->travelLookupService = $this->createMock(TravelIndex::class);
|
||||||
|
|
||||||
$dateId = 12345;
|
$dateId = 12345;
|
||||||
$hotelId = 67890;
|
$hotelId = 67890;
|
||||||
|
|
||||||
@@ -228,11 +255,13 @@ class TravelDataProviderTest extends TestCase
|
|||||||
->with($dateId, $hotelId)
|
->with($dateId, $hotelId)
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
$this->assertTrue($this->service->existsLocally($dateId, $hotelId));
|
$this->assertTrue($this->service()->existsLocally($dateId, $hotelId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetAvailableSourcesDelegatesToLookupService(): void
|
public function testGetAvailableSourcesDelegatesToLookupService(): void
|
||||||
{
|
{
|
||||||
|
$this->travelLookupService = $this->createMock(TravelIndex::class);
|
||||||
|
|
||||||
$dateId = 12345;
|
$dateId = 12345;
|
||||||
$hotelId = 67890;
|
$hotelId = 67890;
|
||||||
$expected = ['local' => true, 'remote' => true];
|
$expected = ['local' => true, 'remote' => true];
|
||||||
@@ -243,11 +272,13 @@ class TravelDataProviderTest extends TestCase
|
|||||||
->with($dateId, $hotelId)
|
->with($dateId, $hotelId)
|
||||||
->willReturn($expected);
|
->willReturn($expected);
|
||||||
|
|
||||||
$this->assertSame($expected, $this->service->getAvailableSources($dateId, $hotelId));
|
$this->assertSame($expected, $this->service()->getAvailableSources($dateId, $hotelId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGenerateFilesMapDelegatesToLookupService(): void
|
public function testGenerateFilesMapDelegatesToLookupService(): void
|
||||||
{
|
{
|
||||||
|
$this->travelLookupService = $this->createMock(TravelIndex::class);
|
||||||
|
|
||||||
$mapping = [12345 => ['id' => 12345, 'hotels' => []]];
|
$mapping = [12345 => ['id' => 12345, 'hotels' => []]];
|
||||||
|
|
||||||
$this->travelLookupService
|
$this->travelLookupService
|
||||||
@@ -255,11 +286,15 @@ class TravelDataProviderTest extends TestCase
|
|||||||
->method('generateFilesMap')
|
->method('generateFilesMap')
|
||||||
->willReturn($mapping);
|
->willReturn($mapping);
|
||||||
|
|
||||||
$this->assertSame($mapping, $this->service->generateFilesMap());
|
$this->assertSame($mapping, $this->service()->generateFilesMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetTravelDataFromLocalPrefersSnapshot(): void
|
public function testGetTravelDataFromLocalPrefersSnapshot(): void
|
||||||
{
|
{
|
||||||
|
$this->travelLoader = $this->createMock(TravelLoader::class);
|
||||||
|
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
||||||
|
$this->travelEnrichmentService = $this->createMock(TravelEnricher::class);
|
||||||
|
|
||||||
$dateId = 12345;
|
$dateId = 12345;
|
||||||
$hotelId = 67890;
|
$hotelId = 67890;
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
@@ -281,13 +316,17 @@ class TravelDataProviderTest extends TestCase
|
|||||||
->method('patchInsurances')
|
->method('patchInsurances')
|
||||||
->with($travel);
|
->with($travel);
|
||||||
|
|
||||||
$result = $this->service->getTravelDataFromLocal($dateId, $hotelId);
|
$result = $this->service()->getTravelDataFromLocal($dateId, $hotelId);
|
||||||
|
|
||||||
$this->assertSame($travel, $result);
|
$this->assertSame($travel, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetTravelDataFromLocalFallsBackToXmlWhenSnapshotMissing(): void
|
public function testGetTravelDataFromLocalFallsBackToXmlWhenSnapshotMissing(): void
|
||||||
{
|
{
|
||||||
|
$this->travelLoader = $this->createMock(TravelLoader::class);
|
||||||
|
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
||||||
|
$this->travelEnrichmentService = $this->createMock(TravelEnricher::class);
|
||||||
|
|
||||||
$dateId = 12345;
|
$dateId = 12345;
|
||||||
$hotelId = 67890;
|
$hotelId = 67890;
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
@@ -322,13 +361,16 @@ class TravelDataProviderTest extends TestCase
|
|||||||
->method('patchInsurances')
|
->method('patchInsurances')
|
||||||
->with($travel);
|
->with($travel);
|
||||||
|
|
||||||
$result = $this->service->getTravelDataFromLocal($dateId, $hotelId);
|
$result = $this->service()->getTravelDataFromLocal($dateId, $hotelId);
|
||||||
|
|
||||||
$this->assertSame($travel, $result);
|
$this->assertSame($travel, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetTravelDataFromLocalPropagatesTravelNotFoundFromXmlFallback(): void
|
public function testGetTravelDataFromLocalPropagatesTravelNotFoundFromXmlFallback(): void
|
||||||
{
|
{
|
||||||
|
$this->travelLoader = $this->createMock(TravelLoader::class);
|
||||||
|
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
||||||
|
|
||||||
$dateId = 12345;
|
$dateId = 12345;
|
||||||
$hotelId = 67890;
|
$hotelId = 67890;
|
||||||
|
|
||||||
@@ -345,11 +387,15 @@ class TravelDataProviderTest extends TestCase
|
|||||||
->willThrowException(new TravelNotFoundException($dateId));
|
->willThrowException(new TravelNotFoundException($dateId));
|
||||||
|
|
||||||
$this->expectException(TravelNotFoundException::class);
|
$this->expectException(TravelNotFoundException::class);
|
||||||
$this->service->getTravelDataFromLocal($dateId, $hotelId);
|
$this->service()->getTravelDataFromLocal($dateId, $hotelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSnapshotLoadFailureFallsBackToXml(): void
|
public function testSnapshotLoadFailureFallsBackToXml(): void
|
||||||
{
|
{
|
||||||
|
$this->travelLoader = $this->createMock(TravelLoader::class);
|
||||||
|
$this->logger = $this->createMock(LoggerInterface::class);
|
||||||
|
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
||||||
|
|
||||||
$dateId = 12345;
|
$dateId = 12345;
|
||||||
$hotelId = 67890;
|
$hotelId = 67890;
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
@@ -373,13 +419,17 @@ class TravelDataProviderTest extends TestCase
|
|||||||
->with($dateId, $hotelId)
|
->with($dateId, $hotelId)
|
||||||
->willReturn($travel);
|
->willReturn($travel);
|
||||||
|
|
||||||
$result = $this->service->getTravelDataFromLocal($dateId, $hotelId);
|
$result = $this->service()->getTravelDataFromLocal($dateId, $hotelId);
|
||||||
|
|
||||||
$this->assertSame($travel, $result);
|
$this->assertSame($travel, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSnapshotPersistenceFailureDoesNotDiscardXmlTravel(): void
|
public function testSnapshotPersistenceFailureDoesNotDiscardXmlTravel(): void
|
||||||
{
|
{
|
||||||
|
$this->travelLoader = $this->createMock(TravelLoader::class);
|
||||||
|
$this->logger = $this->createMock(LoggerInterface::class);
|
||||||
|
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
||||||
|
|
||||||
$dateId = 12345;
|
$dateId = 12345;
|
||||||
$hotelId = 67890;
|
$hotelId = 67890;
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
@@ -406,7 +456,7 @@ class TravelDataProviderTest extends TestCase
|
|||||||
->method('warning')
|
->method('warning')
|
||||||
->with('Failed to persist travel snapshot after XML load', $this->arrayHasKey('dateId'));
|
->with('Failed to persist travel snapshot after XML load', $this->arrayHasKey('dateId'));
|
||||||
|
|
||||||
$result = $this->service->getTravelDataFromXml($dateId, $hotelId);
|
$result = $this->service()->getTravelDataFromXml($dateId, $hotelId);
|
||||||
|
|
||||||
$this->assertNotNull($result);
|
$this->assertNotNull($result);
|
||||||
$this->assertSame($travel, $result);
|
$this->assertSame($travel, $result);
|
||||||
@@ -414,6 +464,10 @@ class TravelDataProviderTest extends TestCase
|
|||||||
|
|
||||||
public function testGetTravelDataDelegatesToLoadUncached(): void
|
public function testGetTravelDataDelegatesToLoadUncached(): void
|
||||||
{
|
{
|
||||||
|
$this->travelLoader = $this->createMock(TravelLoader::class);
|
||||||
|
$this->cache = $this->createMock(CacheInterface::class);
|
||||||
|
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
||||||
|
|
||||||
$dateId = 12345;
|
$dateId = 12345;
|
||||||
$hotelId = 67890;
|
$hotelId = 67890;
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
@@ -436,7 +490,7 @@ class TravelDataProviderTest extends TestCase
|
|||||||
->with($dateId, $hotelId)
|
->with($dateId, $hotelId)
|
||||||
->willReturn($travel);
|
->willReturn($travel);
|
||||||
|
|
||||||
$result = $this->service->getTravelData($dateId, $hotelId, false);
|
$result = $this->service()->getTravelData($dateId, $hotelId, false);
|
||||||
|
|
||||||
$this->assertSame($travel, $result);
|
$this->assertSame($travel, $result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ use Psr\Log\LoggerInterface;
|
|||||||
|
|
||||||
class TravelEnricherTest extends TestCase
|
class TravelEnricherTest extends TestCase
|
||||||
{
|
{
|
||||||
private TravelEnricher $service;
|
private ?TravelEnricher $service = null;
|
||||||
private PickupLoader $pickupLoader;
|
private PickupLoader $pickupLoader;
|
||||||
private HotelLoader $hotelLoader;
|
private HotelLoader $hotelLoader;
|
||||||
private InsuranceLoader $insuranceLoader;
|
private InsuranceLoader $insuranceLoader;
|
||||||
@@ -23,12 +23,15 @@ class TravelEnricherTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->pickupLoader = $this->createMock(PickupLoader::class);
|
$this->pickupLoader = $this->createStub(PickupLoader::class);
|
||||||
$this->hotelLoader = $this->createMock(HotelLoader::class);
|
$this->hotelLoader = $this->createStub(HotelLoader::class);
|
||||||
$this->insuranceLoader = $this->createMock(InsuranceLoader::class);
|
$this->insuranceLoader = $this->createStub(InsuranceLoader::class);
|
||||||
$this->logger = $this->createMock(LoggerInterface::class);
|
$this->logger = $this->createStub(LoggerInterface::class);
|
||||||
|
}
|
||||||
|
|
||||||
$this->service = new TravelEnricher(
|
private function service(): TravelEnricher
|
||||||
|
{
|
||||||
|
return $this->service ??= new TravelEnricher(
|
||||||
$this->pickupLoader,
|
$this->pickupLoader,
|
||||||
$this->hotelLoader,
|
$this->hotelLoader,
|
||||||
$this->insuranceLoader,
|
$this->insuranceLoader,
|
||||||
@@ -42,6 +45,9 @@ class TravelEnricherTest extends TestCase
|
|||||||
|
|
||||||
public function testEnrichFromXmlReturnsTrueOnSuccess(): void
|
public function testEnrichFromXmlReturnsTrueOnSuccess(): void
|
||||||
{
|
{
|
||||||
|
$this->pickupLoader = $this->createMock(PickupLoader::class);
|
||||||
|
$this->hotelLoader = $this->createMock(HotelLoader::class);
|
||||||
|
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
$travel->id = 100;
|
$travel->id = 100;
|
||||||
|
|
||||||
@@ -55,11 +61,13 @@ class TravelEnricherTest extends TestCase
|
|||||||
->method('patchHotelDetails')
|
->method('patchHotelDetails')
|
||||||
->with($travel);
|
->with($travel);
|
||||||
|
|
||||||
$this->assertTrue($this->service->enrichFromXml($travel));
|
$this->assertTrue($this->service()->enrichFromXml($travel));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEnrichFromXmlReturnsFalseAndLogsWarningOnFailure(): void
|
public function testEnrichFromXmlReturnsFalseAndLogsWarningOnFailure(): void
|
||||||
{
|
{
|
||||||
|
$this->logger = $this->createMock(LoggerInterface::class);
|
||||||
|
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
$travel->id = 100;
|
$travel->id = 100;
|
||||||
|
|
||||||
@@ -72,7 +80,7 @@ class TravelEnricherTest extends TestCase
|
|||||||
->method('warning')
|
->method('warning')
|
||||||
->with('Failed to enrich travel data', $this->arrayHasKey('travelId'));
|
->with('Failed to enrich travel data', $this->arrayHasKey('travelId'));
|
||||||
|
|
||||||
$this->assertFalse($this->service->enrichFromXml($travel));
|
$this->assertFalse($this->service()->enrichFromXml($travel));
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
@@ -81,6 +89,8 @@ class TravelEnricherTest extends TestCase
|
|||||||
|
|
||||||
public function testPatchInsurancesReplacesExistingInsurances(): void
|
public function testPatchInsurancesReplacesExistingInsurances(): void
|
||||||
{
|
{
|
||||||
|
$this->insuranceLoader = $this->createMock(InsuranceLoader::class);
|
||||||
|
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
$travel->id = 100;
|
$travel->id = 100;
|
||||||
|
|
||||||
@@ -104,7 +114,7 @@ class TravelEnricherTest extends TestCase
|
|||||||
->method('loadAll')
|
->method('loadAll')
|
||||||
->willReturn([$individual, $package]);
|
->willReturn([$individual, $package]);
|
||||||
|
|
||||||
$this->service->patchInsurances($travel);
|
$this->service()->patchInsurances($travel);
|
||||||
|
|
||||||
$this->assertSame([$individual, $package], $travel->insurances);
|
$this->assertSame([$individual, $package], $travel->insurances);
|
||||||
}
|
}
|
||||||
@@ -126,7 +136,7 @@ class TravelEnricherTest extends TestCase
|
|||||||
|
|
||||||
$this->insuranceLoader->method('loadAll')->willReturn([$individual, $package]);
|
$this->insuranceLoader->method('loadAll')->willReturn([$individual, $package]);
|
||||||
|
|
||||||
$this->service->patchInsurances($travel);
|
$this->service()->patchInsurances($travel);
|
||||||
|
|
||||||
$this->assertCount(1, $package->containedInsurances);
|
$this->assertCount(1, $package->containedInsurances);
|
||||||
$this->assertSame($individual, $package->containedInsurances[0]);
|
$this->assertSame($individual, $package->containedInsurances[0]);
|
||||||
@@ -134,6 +144,8 @@ class TravelEnricherTest extends TestCase
|
|||||||
|
|
||||||
public function testPatchInsurancesLogsWarningOnFailureAndDoesNotThrow(): void
|
public function testPatchInsurancesLogsWarningOnFailureAndDoesNotThrow(): void
|
||||||
{
|
{
|
||||||
|
$this->logger = $this->createMock(LoggerInterface::class);
|
||||||
|
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
$travel->id = 100;
|
$travel->id = 100;
|
||||||
$original = [];
|
$original = [];
|
||||||
@@ -149,7 +161,7 @@ class TravelEnricherTest extends TestCase
|
|||||||
->with('Failed to load insurance data', $this->arrayHasKey('travelId'));
|
->with('Failed to load insurance data', $this->arrayHasKey('travelId'));
|
||||||
|
|
||||||
// Must not throw; insurances stay unchanged
|
// Must not throw; insurances stay unchanged
|
||||||
$this->service->patchInsurances($travel);
|
$this->service()->patchInsurances($travel);
|
||||||
|
|
||||||
$this->assertSame($original, $travel->insurances);
|
$this->assertSame($original, $travel->insurances);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use Psr\Log\LoggerInterface;
|
|||||||
|
|
||||||
class TravelIndexTest extends TestCase
|
class TravelIndexTest extends TestCase
|
||||||
{
|
{
|
||||||
private TravelIndex $service;
|
private ?TravelIndex $service = null;
|
||||||
private TravelLoader $travelLoader;
|
private TravelLoader $travelLoader;
|
||||||
private HotelLoader $hotelLoader;
|
private HotelLoader $hotelLoader;
|
||||||
private TravelSnapshotManager $travelSnapshotService;
|
private TravelSnapshotManager $travelSnapshotService;
|
||||||
@@ -21,12 +21,15 @@ class TravelIndexTest extends TestCase
|
|||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->travelLoader = $this->createMock(TravelLoader::class);
|
$this->travelLoader = $this->createStub(TravelLoader::class);
|
||||||
$this->hotelLoader = $this->createMock(HotelLoader::class);
|
$this->hotelLoader = $this->createStub(HotelLoader::class);
|
||||||
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
$this->travelSnapshotService = $this->createStub(TravelSnapshotManager::class);
|
||||||
$this->logger = $this->createMock(LoggerInterface::class);
|
$this->logger = $this->createStub(LoggerInterface::class);
|
||||||
|
}
|
||||||
|
|
||||||
$this->service = new TravelIndex(
|
private function service(): TravelIndex
|
||||||
|
{
|
||||||
|
return $this->service ??= new TravelIndex(
|
||||||
$this->travelLoader,
|
$this->travelLoader,
|
||||||
$this->hotelLoader,
|
$this->hotelLoader,
|
||||||
$this->travelSnapshotService,
|
$this->travelSnapshotService,
|
||||||
@@ -59,7 +62,7 @@ class TravelIndexTest extends TestCase
|
|||||||
$this->travelLoader->method('generateFilesMap')->willReturn($xmlMapping);
|
$this->travelLoader->method('generateFilesMap')->willReturn($xmlMapping);
|
||||||
$this->travelSnapshotService->method('generateMapping')->willReturn($snapshotMapping);
|
$this->travelSnapshotService->method('generateMapping')->willReturn($snapshotMapping);
|
||||||
|
|
||||||
$result = $this->service->generateFilesMap();
|
$result = $this->service()->generateFilesMap();
|
||||||
|
|
||||||
// XML entry is preserved
|
// XML entry is preserved
|
||||||
$this->assertArrayHasKey($dateId, $result);
|
$this->assertArrayHasKey($dateId, $result);
|
||||||
@@ -73,6 +76,9 @@ class TravelIndexTest extends TestCase
|
|||||||
|
|
||||||
public function testGenerateFilesMapIsMemoizedWithinRequest(): void
|
public function testGenerateFilesMapIsMemoizedWithinRequest(): void
|
||||||
{
|
{
|
||||||
|
$this->travelLoader = $this->createMock(TravelLoader::class);
|
||||||
|
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
||||||
|
|
||||||
$mapping = [100 => ['id' => 100, 'code' => 'A', 'hotels' => []]];
|
$mapping = [100 => ['id' => 100, 'code' => 'A', 'hotels' => []]];
|
||||||
|
|
||||||
$this->travelLoader
|
$this->travelLoader
|
||||||
@@ -86,14 +92,16 @@ class TravelIndexTest extends TestCase
|
|||||||
->willReturn([]);
|
->willReturn([]);
|
||||||
|
|
||||||
// Two calls — loaders invoked only once
|
// Two calls — loaders invoked only once
|
||||||
$this->service->generateFilesMap();
|
$this->service()->generateFilesMap();
|
||||||
$result = $this->service->generateFilesMap();
|
$result = $this->service()->generateFilesMap();
|
||||||
|
|
||||||
$this->assertSame($mapping, $result);
|
$this->assertSame($mapping, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGenerateFilesMapFallsBackToSnapshotsOnXmlFailure(): void
|
public function testGenerateFilesMapFallsBackToSnapshotsOnXmlFailure(): void
|
||||||
{
|
{
|
||||||
|
$this->logger = $this->createMock(LoggerInterface::class);
|
||||||
|
|
||||||
$snapshotMapping = [100 => ['id' => 100, 'code' => 'A', 'hotels' => []]];
|
$snapshotMapping = [100 => ['id' => 100, 'code' => 'A', 'hotels' => []]];
|
||||||
|
|
||||||
$this->travelLoader
|
$this->travelLoader
|
||||||
@@ -109,7 +117,7 @@ class TravelIndexTest extends TestCase
|
|||||||
->method('warning')
|
->method('warning')
|
||||||
->with('Failed to generate XML files mapping, fallback to snapshots only', $this->arrayHasKey('error'));
|
->with('Failed to generate XML files mapping, fallback to snapshots only', $this->arrayHasKey('error'));
|
||||||
|
|
||||||
$result = $this->service->generateFilesMap();
|
$result = $this->service()->generateFilesMap();
|
||||||
|
|
||||||
$this->assertSame($snapshotMapping, $result);
|
$this->assertSame($snapshotMapping, $result);
|
||||||
}
|
}
|
||||||
@@ -125,7 +133,7 @@ class TravelIndexTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
$this->travelSnapshotService->method('generateMapping')->willReturn([]);
|
$this->travelSnapshotService->method('generateMapping')->willReturn([]);
|
||||||
|
|
||||||
$result = $this->service->mapDateCodeToId('WI25');
|
$result = $this->service()->mapDateCodeToId('WI25');
|
||||||
|
|
||||||
$this->assertSame(42, $result);
|
$this->assertSame(42, $result);
|
||||||
}
|
}
|
||||||
@@ -135,7 +143,7 @@ class TravelIndexTest extends TestCase
|
|||||||
$this->travelLoader->method('generateFilesMap')->willReturn([]);
|
$this->travelLoader->method('generateFilesMap')->willReturn([]);
|
||||||
$this->travelSnapshotService->method('generateMapping')->willReturn([]);
|
$this->travelSnapshotService->method('generateMapping')->willReturn([]);
|
||||||
|
|
||||||
$result = $this->service->mapDateCodeToId('UNKNOWN');
|
$result = $this->service()->mapDateCodeToId('UNKNOWN');
|
||||||
|
|
||||||
$this->assertNull($result);
|
$this->assertNull($result);
|
||||||
}
|
}
|
||||||
@@ -146,13 +154,15 @@ class TravelIndexTest extends TestCase
|
|||||||
|
|
||||||
public function testMapHotelCodeToIdDelegatesToHotelLoader(): void
|
public function testMapHotelCodeToIdDelegatesToHotelLoader(): void
|
||||||
{
|
{
|
||||||
|
$this->hotelLoader = $this->createMock(HotelLoader::class);
|
||||||
|
|
||||||
$this->hotelLoader
|
$this->hotelLoader
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('mapCodeToId')
|
->method('mapCodeToId')
|
||||||
->with('HTL001')
|
->with('HTL001')
|
||||||
->willReturn(77);
|
->willReturn(77);
|
||||||
|
|
||||||
$result = $this->service->mapHotelCodeToId('HTL001');
|
$result = $this->service()->mapHotelCodeToId('HTL001');
|
||||||
|
|
||||||
$this->assertSame(77, $result);
|
$this->assertSame(77, $result);
|
||||||
}
|
}
|
||||||
@@ -163,7 +173,7 @@ class TravelIndexTest extends TestCase
|
|||||||
->method('mapCodeToId')
|
->method('mapCodeToId')
|
||||||
->willThrowException(new \RuntimeException('Not found'));
|
->willThrowException(new \RuntimeException('Not found'));
|
||||||
|
|
||||||
$result = $this->service->mapHotelCodeToId('MISSING');
|
$result = $this->service()->mapHotelCodeToId('MISSING');
|
||||||
|
|
||||||
$this->assertNull($result);
|
$this->assertNull($result);
|
||||||
}
|
}
|
||||||
@@ -174,6 +184,9 @@ class TravelIndexTest extends TestCase
|
|||||||
|
|
||||||
public function testMapDateIdToProductIdPrefersSnapshot(): void
|
public function testMapDateIdToProductIdPrefersSnapshot(): void
|
||||||
{
|
{
|
||||||
|
$this->travelLoader = $this->createMock(TravelLoader::class);
|
||||||
|
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
||||||
|
|
||||||
$this->travelSnapshotService
|
$this->travelSnapshotService
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('findProductIdByDateId')
|
->method('findProductIdByDateId')
|
||||||
@@ -184,13 +197,16 @@ class TravelIndexTest extends TestCase
|
|||||||
->expects($this->never())
|
->expects($this->never())
|
||||||
->method('mapDateIdToProductId');
|
->method('mapDateIdToProductId');
|
||||||
|
|
||||||
$result = $this->service->mapDateIdToProductId(100);
|
$result = $this->service()->mapDateIdToProductId(100);
|
||||||
|
|
||||||
$this->assertSame(999, $result);
|
$this->assertSame(999, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMapDateIdToProductIdFallsBackToLoaderWhenSnapshotReturnsNull(): void
|
public function testMapDateIdToProductIdFallsBackToLoaderWhenSnapshotReturnsNull(): void
|
||||||
{
|
{
|
||||||
|
$this->travelLoader = $this->createMock(TravelLoader::class);
|
||||||
|
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
||||||
|
|
||||||
$this->travelSnapshotService
|
$this->travelSnapshotService
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('findProductIdByDateId')
|
->method('findProductIdByDateId')
|
||||||
@@ -203,7 +219,7 @@ class TravelIndexTest extends TestCase
|
|||||||
->with(100)
|
->with(100)
|
||||||
->willReturn(42);
|
->willReturn(42);
|
||||||
|
|
||||||
$result = $this->service->mapDateIdToProductId(100);
|
$result = $this->service()->mapDateIdToProductId(100);
|
||||||
|
|
||||||
$this->assertSame(42, $result);
|
$this->assertSame(42, $result);
|
||||||
}
|
}
|
||||||
@@ -214,6 +230,9 @@ class TravelIndexTest extends TestCase
|
|||||||
|
|
||||||
public function testExistsLocallyTrueFromSnapshot(): void
|
public function testExistsLocallyTrueFromSnapshot(): void
|
||||||
{
|
{
|
||||||
|
$this->travelLoader = $this->createMock(TravelLoader::class);
|
||||||
|
$this->travelSnapshotService = $this->createMock(TravelSnapshotManager::class);
|
||||||
|
|
||||||
$dateId = 12345;
|
$dateId = 12345;
|
||||||
$hotelId = 67890;
|
$hotelId = 67890;
|
||||||
|
|
||||||
@@ -227,7 +246,7 @@ class TravelIndexTest extends TestCase
|
|||||||
->expects($this->never())
|
->expects($this->never())
|
||||||
->method('generateFilesMap');
|
->method('generateFilesMap');
|
||||||
|
|
||||||
$this->assertTrue($this->service->existsLocally($dateId, $hotelId));
|
$this->assertTrue($this->service()->existsLocally($dateId, $hotelId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExistsLocallyTrueFromXmlMap(): void
|
public function testExistsLocallyTrueFromXmlMap(): void
|
||||||
@@ -245,7 +264,7 @@ class TravelIndexTest extends TestCase
|
|||||||
$this->travelLoader->method('generateFilesMap')->willReturn($mapping);
|
$this->travelLoader->method('generateFilesMap')->willReturn($mapping);
|
||||||
$this->travelSnapshotService->method('generateMapping')->willReturn([]);
|
$this->travelSnapshotService->method('generateMapping')->willReturn([]);
|
||||||
|
|
||||||
$this->assertTrue($this->service->existsLocally($dateId, $hotelId));
|
$this->assertTrue($this->service()->existsLocally($dateId, $hotelId));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExistsLocallyFalseNoTravel(): void
|
public function testExistsLocallyFalseNoTravel(): void
|
||||||
@@ -254,7 +273,7 @@ class TravelIndexTest extends TestCase
|
|||||||
$this->travelLoader->method('generateFilesMap')->willReturn([]);
|
$this->travelLoader->method('generateFilesMap')->willReturn([]);
|
||||||
$this->travelSnapshotService->method('generateMapping')->willReturn([]);
|
$this->travelSnapshotService->method('generateMapping')->willReturn([]);
|
||||||
|
|
||||||
$this->assertFalse($this->service->existsLocally(12345, 67890));
|
$this->assertFalse($this->service()->existsLocally(12345, 67890));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExistsLocallyFalseNoHotel(): void
|
public function testExistsLocallyFalseNoHotel(): void
|
||||||
@@ -269,7 +288,7 @@ class TravelIndexTest extends TestCase
|
|||||||
$this->travelLoader->method('generateFilesMap')->willReturn($mapping);
|
$this->travelLoader->method('generateFilesMap')->willReturn($mapping);
|
||||||
$this->travelSnapshotService->method('generateMapping')->willReturn([]);
|
$this->travelSnapshotService->method('generateMapping')->willReturn([]);
|
||||||
|
|
||||||
$this->assertFalse($this->service->existsLocally($dateId, $hotelId));
|
$this->assertFalse($this->service()->existsLocally($dateId, $hotelId));
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
@@ -278,6 +297,8 @@ class TravelIndexTest extends TestCase
|
|||||||
|
|
||||||
public function testGetAvailableSourcesReturnsBothFlags(): void
|
public function testGetAvailableSourcesReturnsBothFlags(): void
|
||||||
{
|
{
|
||||||
|
$this->travelLoader = $this->createMock(TravelLoader::class);
|
||||||
|
|
||||||
$dateId = 12345;
|
$dateId = 12345;
|
||||||
$hotelId = 67890;
|
$hotelId = 67890;
|
||||||
$mapping = [
|
$mapping = [
|
||||||
@@ -290,7 +311,7 @@ class TravelIndexTest extends TestCase
|
|||||||
$this->travelLoader->method('generateFilesMap')->willReturn($mapping);
|
$this->travelLoader->method('generateFilesMap')->willReturn($mapping);
|
||||||
$this->travelLoader->method('mapDateIdToProductId')->with($dateId)->willReturn(555);
|
$this->travelLoader->method('mapDateIdToProductId')->with($dateId)->willReturn(555);
|
||||||
|
|
||||||
$result = $this->service->getAvailableSources($dateId, $hotelId);
|
$result = $this->service()->getAvailableSources($dateId, $hotelId);
|
||||||
|
|
||||||
$this->assertEquals(['local' => true, 'remote' => true], $result);
|
$this->assertEquals(['local' => true, 'remote' => true], $result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,17 +24,20 @@ class TravelSnapshotManagerTest extends TestCase
|
|||||||
private ApiClient $apiClient;
|
private ApiClient $apiClient;
|
||||||
private LoggerInterface $logger;
|
private LoggerInterface $logger;
|
||||||
private SerializerInterface $serializer;
|
private SerializerInterface $serializer;
|
||||||
private TravelSnapshotManager $service;
|
private ?TravelSnapshotManager $service = null;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
$this->snapshotRepository = $this->createStub(TravelSnapshotRepository::class);
|
||||||
$this->entityManager = $this->createMock(EntityManagerInterface::class);
|
$this->entityManager = $this->createStub(EntityManagerInterface::class);
|
||||||
$this->apiClient = $this->createMock(ApiClient::class);
|
$this->apiClient = $this->createStub(ApiClient::class);
|
||||||
$this->logger = $this->createMock(LoggerInterface::class);
|
$this->logger = $this->createStub(LoggerInterface::class);
|
||||||
$this->serializer = $this->createMock(SerializerInterface::class);
|
$this->serializer = $this->createStub(SerializerInterface::class);
|
||||||
|
}
|
||||||
|
|
||||||
$this->service = new TravelSnapshotManager(
|
private function service(): TravelSnapshotManager
|
||||||
|
{
|
||||||
|
return $this->service ??= new TravelSnapshotManager(
|
||||||
$this->snapshotRepository,
|
$this->snapshotRepository,
|
||||||
$this->entityManager,
|
$this->entityManager,
|
||||||
$this->apiClient,
|
$this->apiClient,
|
||||||
@@ -46,6 +49,10 @@ class TravelSnapshotManagerTest extends TestCase
|
|||||||
|
|
||||||
public function testUpsertCreatesNewSnapshot(): void
|
public function testUpsertCreatesNewSnapshot(): void
|
||||||
{
|
{
|
||||||
|
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||||
|
$this->entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
|
$this->serializer = $this->createMock(SerializerInterface::class);
|
||||||
|
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
$travel->id = 100;
|
$travel->id = 100;
|
||||||
$travel->hotelId = 200;
|
$travel->hotelId = 200;
|
||||||
@@ -71,11 +78,15 @@ class TravelSnapshotManagerTest extends TestCase
|
|||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('flush');
|
->method('flush');
|
||||||
|
|
||||||
$this->service->upsertFromTravel($travel);
|
$this->service()->upsertFromTravel($travel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUpsertSkipsWhenHashUnchanged(): void
|
public function testUpsertSkipsWhenHashUnchanged(): void
|
||||||
{
|
{
|
||||||
|
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||||
|
$this->entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
|
$this->serializer = $this->createMock(SerializerInterface::class);
|
||||||
|
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
$travel->id = 100;
|
$travel->id = 100;
|
||||||
$travel->hotelId = 200;
|
$travel->hotelId = 200;
|
||||||
@@ -100,11 +111,15 @@ class TravelSnapshotManagerTest extends TestCase
|
|||||||
->expects($this->never())
|
->expects($this->never())
|
||||||
->method('flush');
|
->method('flush');
|
||||||
|
|
||||||
$this->service->upsertFromTravel($travel);
|
$this->service()->upsertFromTravel($travel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUpsertUpdatesWhenHashChanged(): void
|
public function testUpsertUpdatesWhenHashChanged(): void
|
||||||
{
|
{
|
||||||
|
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||||
|
$this->entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
|
$this->serializer = $this->createMock(SerializerInterface::class);
|
||||||
|
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
$travel->id = 100;
|
$travel->id = 100;
|
||||||
$travel->hotelId = 200;
|
$travel->hotelId = 200;
|
||||||
@@ -131,24 +146,30 @@ class TravelSnapshotManagerTest extends TestCase
|
|||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('flush');
|
->method('flush');
|
||||||
|
|
||||||
$this->service->upsertFromTravel($travel);
|
$this->service()->upsertFromTravel($travel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLoadTravelReturnsNullWhenNoSnapshot(): void
|
public function testLoadTravelReturnsNullWhenNoSnapshot(): void
|
||||||
{
|
{
|
||||||
|
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||||
|
|
||||||
$this->snapshotRepository
|
$this->snapshotRepository
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('findByDateAndHotel')
|
->method('findByDateAndHotel')
|
||||||
->with(100, 200)
|
->with(100, 200)
|
||||||
->willReturn(null);
|
->willReturn(null);
|
||||||
|
|
||||||
$result = $this->service->loadTravel(100, 200);
|
$result = $this->service()->loadTravel(100, 200);
|
||||||
|
|
||||||
$this->assertNull($result);
|
$this->assertNull($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLoadTravelReturnsNullOnDeserializationError(): void
|
public function testLoadTravelReturnsNullOnDeserializationError(): void
|
||||||
{
|
{
|
||||||
|
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||||
|
$this->logger = $this->createMock(LoggerInterface::class);
|
||||||
|
$this->serializer = $this->createMock(SerializerInterface::class);
|
||||||
|
|
||||||
$snapshot = new TravelSnapshot(100, 200, 'invalid-json', hash('sha256', 'invalid-json'));
|
$snapshot = new TravelSnapshot(100, 200, 'invalid-json', hash('sha256', 'invalid-json'));
|
||||||
|
|
||||||
$this->snapshotRepository
|
$this->snapshotRepository
|
||||||
@@ -167,13 +188,15 @@ class TravelSnapshotManagerTest extends TestCase
|
|||||||
->method('warning')
|
->method('warning')
|
||||||
->with('Snapshot payload cannot be deserialized to Travel', $this->arrayHasKey('snapshotId'));
|
->with('Snapshot payload cannot be deserialized to Travel', $this->arrayHasKey('snapshotId'));
|
||||||
|
|
||||||
$result = $this->service->loadTravel(100, 200);
|
$result = $this->service()->loadTravel(100, 200);
|
||||||
|
|
||||||
$this->assertNull($result);
|
$this->assertNull($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExistsReturnsTrueWhenSnapshotFound(): void
|
public function testExistsReturnsTrueWhenSnapshotFound(): void
|
||||||
{
|
{
|
||||||
|
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||||
|
|
||||||
$snapshot = new TravelSnapshot(100, 200, '{}', hash('sha256', '{}'));
|
$snapshot = new TravelSnapshot(100, 200, '{}', hash('sha256', '{}'));
|
||||||
|
|
||||||
$this->snapshotRepository
|
$this->snapshotRepository
|
||||||
@@ -182,22 +205,27 @@ class TravelSnapshotManagerTest extends TestCase
|
|||||||
->with(100, 200)
|
->with(100, 200)
|
||||||
->willReturn($snapshot);
|
->willReturn($snapshot);
|
||||||
|
|
||||||
$this->assertTrue($this->service->exists(100, 200));
|
$this->assertTrue($this->service()->exists(100, 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExistsReturnsFalseWhenNoSnapshot(): void
|
public function testExistsReturnsFalseWhenNoSnapshot(): void
|
||||||
{
|
{
|
||||||
|
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||||
|
|
||||||
$this->snapshotRepository
|
$this->snapshotRepository
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('findByDateAndHotel')
|
->method('findByDateAndHotel')
|
||||||
->with(100, 200)
|
->with(100, 200)
|
||||||
->willReturn(null);
|
->willReturn(null);
|
||||||
|
|
||||||
$this->assertFalse($this->service->exists(100, 200));
|
$this->assertFalse($this->service()->exists(100, 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLoadTravelReturnsDeserializedTravel(): void
|
public function testLoadTravelReturnsDeserializedTravel(): void
|
||||||
{
|
{
|
||||||
|
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||||
|
$this->serializer = $this->createMock(SerializerInterface::class);
|
||||||
|
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
$travel->id = 100;
|
$travel->id = 100;
|
||||||
$travel->hotelId = 200;
|
$travel->hotelId = 200;
|
||||||
@@ -217,7 +245,7 @@ class TravelSnapshotManagerTest extends TestCase
|
|||||||
->with($payload, Travel::class, 'json')
|
->with($payload, Travel::class, 'json')
|
||||||
->willReturn($travel);
|
->willReturn($travel);
|
||||||
|
|
||||||
$result = $this->service->loadTravel(100, 200);
|
$result = $this->service()->loadTravel(100, 200);
|
||||||
|
|
||||||
$this->assertInstanceOf(Travel::class, $result);
|
$this->assertInstanceOf(Travel::class, $result);
|
||||||
$this->assertSame($travel, $result);
|
$this->assertSame($travel, $result);
|
||||||
@@ -225,6 +253,9 @@ class TravelSnapshotManagerTest extends TestCase
|
|||||||
|
|
||||||
public function testUpsertFromTravelSkipsWhenTravelIsIncomplete(): void
|
public function testUpsertFromTravelSkipsWhenTravelIsIncomplete(): void
|
||||||
{
|
{
|
||||||
|
$this->entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
|
$this->serializer = $this->createMock(SerializerInterface::class);
|
||||||
|
|
||||||
$travelNoId = new Travel();
|
$travelNoId = new Travel();
|
||||||
$travelNoId->id = null;
|
$travelNoId->id = null;
|
||||||
$travelNoId->hotelId = 200;
|
$travelNoId->hotelId = 200;
|
||||||
@@ -236,25 +267,29 @@ class TravelSnapshotManagerTest extends TestCase
|
|||||||
$this->serializer->expects($this->never())->method('serialize');
|
$this->serializer->expects($this->never())->method('serialize');
|
||||||
$this->entityManager->expects($this->never())->method('flush');
|
$this->entityManager->expects($this->never())->method('flush');
|
||||||
|
|
||||||
$this->service->upsertFromTravel($travelNoId);
|
$this->service()->upsertFromTravel($travelNoId);
|
||||||
$this->service->upsertFromTravel($travelNoHotel);
|
$this->service()->upsertFromTravel($travelNoHotel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFindProductIdByDateIdDelegatesToRepository(): void
|
public function testFindProductIdByDateIdDelegatesToRepository(): void
|
||||||
{
|
{
|
||||||
|
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||||
|
|
||||||
$this->snapshotRepository
|
$this->snapshotRepository
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('findProductIdByDateId')
|
->method('findProductIdByDateId')
|
||||||
->with(42)
|
->with(42)
|
||||||
->willReturn(365);
|
->willReturn(365);
|
||||||
|
|
||||||
$result = $this->service->findProductIdByDateId(42);
|
$result = $this->service()->findProductIdByDateId(42);
|
||||||
|
|
||||||
$this->assertSame(365, $result);
|
$this->assertSame(365, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPurgeExpiredSnapshotsDelegatesWithCorrectDate(): void
|
public function testPurgeExpiredSnapshotsDelegatesWithCorrectDate(): void
|
||||||
{
|
{
|
||||||
|
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||||
|
|
||||||
$this->snapshotRepository
|
$this->snapshotRepository
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('deleteExpiredSnapshots')
|
->method('deleteExpiredSnapshots')
|
||||||
@@ -265,13 +300,18 @@ class TravelSnapshotManagerTest extends TestCase
|
|||||||
}))
|
}))
|
||||||
->willReturn(7);
|
->willReturn(7);
|
||||||
|
|
||||||
$result = $this->service->purgeExpiredSnapshots();
|
$result = $this->service()->purgeExpiredSnapshots();
|
||||||
|
|
||||||
$this->assertSame(7, $result);
|
$this->assertSame(7, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRefreshExtendedSnapshotsSuccessPath(): void
|
public function testRefreshExtendedSnapshotsSuccessPath(): void
|
||||||
{
|
{
|
||||||
|
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||||
|
$this->entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
|
$this->apiClient = $this->createMock(ApiClient::class);
|
||||||
|
$this->serializer = $this->createMock(SerializerInterface::class);
|
||||||
|
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
$travel->id = 100;
|
$travel->id = 100;
|
||||||
$travel->hotelId = 200;
|
$travel->hotelId = 200;
|
||||||
@@ -310,13 +350,19 @@ class TravelSnapshotManagerTest extends TestCase
|
|||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('flush');
|
->method('flush');
|
||||||
|
|
||||||
$result = $this->service->refreshExtendedSnapshots(500, false, 360, []);
|
$result = $this->service()->refreshExtendedSnapshots(500, false, 360, []);
|
||||||
|
|
||||||
$this->assertSame(['processed' => 1, 'updated' => 1, 'failed' => 0], $result);
|
$this->assertSame(['processed' => 1, 'updated' => 1, 'failed' => 0], $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRefreshExtendedSnapshotsApiFailureIncrementsFailedCount(): void
|
public function testRefreshExtendedSnapshotsApiFailureIncrementsFailedCount(): void
|
||||||
{
|
{
|
||||||
|
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||||
|
$this->entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
|
$this->apiClient = $this->createMock(ApiClient::class);
|
||||||
|
$this->logger = $this->createMock(LoggerInterface::class);
|
||||||
|
$this->serializer = $this->createMock(SerializerInterface::class);
|
||||||
|
|
||||||
$travel = new Travel();
|
$travel = new Travel();
|
||||||
$travel->id = 100;
|
$travel->id = 100;
|
||||||
$travel->hotelId = 200;
|
$travel->hotelId = 200;
|
||||||
@@ -348,13 +394,18 @@ class TravelSnapshotManagerTest extends TestCase
|
|||||||
->expects($this->never())
|
->expects($this->never())
|
||||||
->method('flush');
|
->method('flush');
|
||||||
|
|
||||||
$result = $this->service->refreshExtendedSnapshots(500, false, 360, []);
|
$result = $this->service()->refreshExtendedSnapshots(500, false, 360, []);
|
||||||
|
|
||||||
$this->assertSame(['processed' => 1, 'updated' => 0, 'failed' => 1], $result);
|
$this->assertSame(['processed' => 1, 'updated' => 0, 'failed' => 1], $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRefreshExtendedSnapshotsDeserializationFailureIncrementsFailedCount(): void
|
public function testRefreshExtendedSnapshotsDeserializationFailureIncrementsFailedCount(): void
|
||||||
{
|
{
|
||||||
|
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||||
|
$this->entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
|
$this->logger = $this->createMock(LoggerInterface::class);
|
||||||
|
$this->serializer = $this->createMock(SerializerInterface::class);
|
||||||
|
|
||||||
$payload = '{"id":100}';
|
$payload = '{"id":100}';
|
||||||
$snapshot = new TravelSnapshot(100, 200, $payload, hash('sha256', $payload));
|
$snapshot = new TravelSnapshot(100, 200, $payload, hash('sha256', $payload));
|
||||||
|
|
||||||
@@ -377,13 +428,17 @@ class TravelSnapshotManagerTest extends TestCase
|
|||||||
->expects($this->never())
|
->expects($this->never())
|
||||||
->method('flush');
|
->method('flush');
|
||||||
|
|
||||||
$result = $this->service->refreshExtendedSnapshots(500, false, 360, []);
|
$result = $this->service()->refreshExtendedSnapshots(500, false, 360, []);
|
||||||
|
|
||||||
$this->assertSame(['processed' => 1, 'updated' => 0, 'failed' => 1], $result);
|
$this->assertSame(['processed' => 1, 'updated' => 0, 'failed' => 1], $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRefreshSkipsAllCandidatesWhenXmlDateIdsIsNull(): void
|
public function testRefreshSkipsAllCandidatesWhenXmlDateIdsIsNull(): void
|
||||||
{
|
{
|
||||||
|
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||||
|
$this->entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
|
$this->apiClient = $this->createMock(ApiClient::class);
|
||||||
|
|
||||||
$payload = '{"id":100}';
|
$payload = '{"id":100}';
|
||||||
$snapshot = new TravelSnapshot(100, 200, $payload, hash('sha256', $payload));
|
$snapshot = new TravelSnapshot(100, 200, $payload, hash('sha256', $payload));
|
||||||
|
|
||||||
@@ -400,13 +455,16 @@ class TravelSnapshotManagerTest extends TestCase
|
|||||||
->expects($this->never())
|
->expects($this->never())
|
||||||
->method('flush');
|
->method('flush');
|
||||||
|
|
||||||
$result = $this->service->refreshExtendedSnapshots(500, false, 360, null);
|
$result = $this->service()->refreshExtendedSnapshots(500, false, 360, null);
|
||||||
|
|
||||||
$this->assertSame(['processed' => 0, 'updated' => 0, 'failed' => 0], $result);
|
$this->assertSame(['processed' => 0, 'updated' => 0, 'failed' => 0], $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRefreshSkipsSnapshotsWithXmlAvailable(): void
|
public function testRefreshSkipsSnapshotsWithXmlAvailable(): void
|
||||||
{
|
{
|
||||||
|
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||||
|
$this->apiClient = $this->createMock(ApiClient::class);
|
||||||
|
|
||||||
$payload = '{"id":100}';
|
$payload = '{"id":100}';
|
||||||
$snapshot = new TravelSnapshot(100, 200, $payload, hash('sha256', $payload));
|
$snapshot = new TravelSnapshot(100, 200, $payload, hash('sha256', $payload));
|
||||||
|
|
||||||
@@ -419,26 +477,30 @@ class TravelSnapshotManagerTest extends TestCase
|
|||||||
->expects($this->never())
|
->expects($this->never())
|
||||||
->method('getAvailabilitiesExtended');
|
->method('getAvailabilitiesExtended');
|
||||||
|
|
||||||
$result = $this->service->refreshExtendedSnapshots(500, false, 360, [100]);
|
$result = $this->service()->refreshExtendedSnapshots(500, false, 360, [100]);
|
||||||
|
|
||||||
$this->assertSame(['processed' => 0, 'updated' => 0, 'failed' => 0], $result);
|
$this->assertSame(['processed' => 0, 'updated' => 0, 'failed' => 0], $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPurgeOrphanedFutureSnapshotsReturnsZeroForEmptyList(): void
|
public function testPurgeOrphanedFutureSnapshotsReturnsZeroForEmptyList(): void
|
||||||
{
|
{
|
||||||
|
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||||
|
|
||||||
$this->snapshotRepository
|
$this->snapshotRepository
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('deleteOrphanedFutureSnapshots')
|
->method('deleteOrphanedFutureSnapshots')
|
||||||
->with([], $this->isInstanceOf(\DateTimeImmutable::class))
|
->with([], $this->isInstanceOf(\DateTimeImmutable::class))
|
||||||
->willReturn(0);
|
->willReturn(0);
|
||||||
|
|
||||||
$result = $this->service->purgeOrphanedFutureSnapshots([]);
|
$result = $this->service()->purgeOrphanedFutureSnapshots([]);
|
||||||
|
|
||||||
$this->assertSame(0, $result);
|
$this->assertSame(0, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPurgeOrphanedFutureSnapshotsDelegatesWithCorrectArguments(): void
|
public function testPurgeOrphanedFutureSnapshotsDelegatesWithCorrectArguments(): void
|
||||||
{
|
{
|
||||||
|
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||||
|
|
||||||
$activeIds = [100, 200, 300];
|
$activeIds = [100, 200, 300];
|
||||||
|
|
||||||
$this->snapshotRepository
|
$this->snapshotRepository
|
||||||
@@ -454,13 +516,15 @@ class TravelSnapshotManagerTest extends TestCase
|
|||||||
)
|
)
|
||||||
->willReturn(3);
|
->willReturn(3);
|
||||||
|
|
||||||
$result = $this->service->purgeOrphanedFutureSnapshots($activeIds);
|
$result = $this->service()->purgeOrphanedFutureSnapshots($activeIds);
|
||||||
|
|
||||||
$this->assertSame(3, $result);
|
$this->assertSame(3, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGenerateMappingBuildsCorrectStructure(): void
|
public function testGenerateMappingBuildsCorrectStructure(): void
|
||||||
{
|
{
|
||||||
|
$this->snapshotRepository = $this->createMock(TravelSnapshotRepository::class);
|
||||||
|
|
||||||
$hotel = new Hotel();
|
$hotel = new Hotel();
|
||||||
$hotel->code = 'HTL1';
|
$hotel->code = 'HTL1';
|
||||||
$hotel->name = 'Hotel One';
|
$hotel->name = 'Hotel One';
|
||||||
@@ -498,7 +562,7 @@ class TravelSnapshotManagerTest extends TestCase
|
|||||||
->method('findAllForMapping')
|
->method('findAllForMapping')
|
||||||
->willReturn([$snapshot1, $snapshot2]);
|
->willReturn([$snapshot1, $snapshot2]);
|
||||||
|
|
||||||
$mapping = $this->service->generateMapping();
|
$mapping = $this->service()->generateMapping();
|
||||||
|
|
||||||
$this->assertArrayHasKey(10, $mapping);
|
$this->assertArrayHasKey(10, $mapping);
|
||||||
$this->assertSame('TRIP1', $mapping[10]['code']);
|
$this->assertSame('TRIP1', $mapping[10]['code']);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class MandatoryAdditionalServicesSelectedValidatorTest extends ConstraintValidat
|
|||||||
|
|
||||||
protected function createValidator(): MandatoryAdditionalServicesSelectedValidator
|
protected function createValidator(): MandatoryAdditionalServicesSelectedValidator
|
||||||
{
|
{
|
||||||
$this->participantEligibilityService = $this->createMock(ParticipantEligibilityChecker::class);
|
$this->participantEligibilityService = $this->createStub(ParticipantEligibilityChecker::class);
|
||||||
$this->participantEligibilityService
|
$this->participantEligibilityService
|
||||||
->method('isParticipantEligible')
|
->method('isParticipantEligible')
|
||||||
->willReturnCallback(fn (): bool => $this->participantEligible);
|
->willReturnCallback(fn (): bool => $this->participantEligible);
|
||||||
|
|||||||
Reference in New Issue
Block a user