feat: extensible participant status determination for booking creation
Adds a rule-based system to determine participant status in CREATE payloads. Participants selecting a 'Begleitperson' service now receive status 'O' (Option), all others default to 'F' (Final). - Add ParticipantStatusRuleInterface for defining status rules - Add ParticipantStatusRuleRegistry for priority-based rule evaluation - Add ChaperonServiceStatusRule for Begleitperson detection - Integrate status evaluation into BookingPayloadBuilder
This commit is contained in:
@@ -128,6 +128,15 @@ services:
|
|||||||
- '@App\Form\Service\ParticipantPurchaseVoucherFieldHandler'
|
- '@App\Form\Service\ParticipantPurchaseVoucherFieldHandler'
|
||||||
- '@App\Form\Service\ParticipantPromoVoucherFieldHandler'
|
- '@App\Form\Service\ParticipantPromoVoucherFieldHandler'
|
||||||
|
|
||||||
|
# Participant Status Rules
|
||||||
|
App\BusProNet\Service\StatusRule\ChaperonServiceStatusRule: ~
|
||||||
|
|
||||||
|
# Participant Status Rule Registry
|
||||||
|
App\BusProNet\Service\ParticipantStatusRuleRegistry:
|
||||||
|
arguments:
|
||||||
|
$rules:
|
||||||
|
- '@App\BusProNet\Service\StatusRule\ChaperonServiceStatusRule'
|
||||||
|
|
||||||
App\Service\CmsDataService:
|
App\Service\CmsDataService:
|
||||||
arguments:
|
arguments:
|
||||||
$httpClient: '@typo3.client'
|
$httpClient: '@typo3.client'
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace App\BusProNet\DataProcessor;
|
|||||||
|
|
||||||
use App\BusProNet\Constants;
|
use App\BusProNet\Constants;
|
||||||
use App\BusProNet\Model\Booking;
|
use App\BusProNet\Model\Booking;
|
||||||
|
use App\BusProNet\Service\ParticipantStatusRuleRegistry;
|
||||||
use App\Form\Model\BookingDto;
|
use App\Form\Model\BookingDto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,6 +19,7 @@ class BookingPayloadBuilder
|
|||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly ServiceMappingCollector $mappingCollector,
|
private readonly ServiceMappingCollector $mappingCollector,
|
||||||
|
private readonly ParticipantStatusRuleRegistry $statusRuleRegistry,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,6 +277,7 @@ class BookingPayloadBuilder
|
|||||||
foreach ($bookingDto->participants as $index => $participant) {
|
foreach ($bookingDto->participants as $index => $participant) {
|
||||||
$participantData = [
|
$participantData = [
|
||||||
'@id' => $index + 1,
|
'@id' => $index + 1,
|
||||||
|
'status' => $this->statusRuleRegistry->evaluateStatus($participant),
|
||||||
'name' => $participant->lastName,
|
'name' => $participant->lastName,
|
||||||
'vorname' => $participant->firstName,
|
'vorname' => $participant->firstName,
|
||||||
'geschlecht' => $participant->gender ?? '',
|
'geschlecht' => $participant->gender ?? '',
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\BusProNet\Service\Contract;
|
||||||
|
|
||||||
|
use App\Form\Model\ParticipantDto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the contract for participant status evaluation rules.
|
||||||
|
*
|
||||||
|
* Status rules are evaluated in priority order to determine the appropriate
|
||||||
|
* status code for a participant during booking creation. The first rule that
|
||||||
|
* matches (evaluate returns true) determines the participant's status.
|
||||||
|
*/
|
||||||
|
interface ParticipantStatusRuleInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Evaluates whether this rule applies to the given participant.
|
||||||
|
*
|
||||||
|
* @param ParticipantDto $participant The participant to evaluate
|
||||||
|
*
|
||||||
|
* @return bool True if this rule applies, false otherwise
|
||||||
|
*/
|
||||||
|
public function evaluate(ParticipantDto $participant): bool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the status code to assign when this rule matches.
|
||||||
|
*
|
||||||
|
* @return string The status code (e.g., 'O' for Option, 'F' for Final)
|
||||||
|
*/
|
||||||
|
public function getStatus(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the priority of this rule.
|
||||||
|
*
|
||||||
|
* Higher priority rules are evaluated first. Rules with the same priority
|
||||||
|
* are evaluated in registration order.
|
||||||
|
*
|
||||||
|
* @return int The priority value (higher = evaluated first)
|
||||||
|
*/
|
||||||
|
public function getPriority(): int;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a human-readable description of this rule.
|
||||||
|
*
|
||||||
|
* Used for debugging and logging purposes.
|
||||||
|
*
|
||||||
|
* @return string Description of what this rule checks
|
||||||
|
*/
|
||||||
|
public function getDescription(): string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\BusProNet\Service;
|
||||||
|
|
||||||
|
use App\BusProNet\Service\Contract\ParticipantStatusRuleInterface;
|
||||||
|
use App\Form\Model\ParticipantDto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registry for participant status evaluation rules.
|
||||||
|
*
|
||||||
|
* Manages a collection of status rules and evaluates them in priority order
|
||||||
|
* to determine the appropriate status code for a participant during booking
|
||||||
|
* creation. Returns a default status of 'F' (Final) when no rules match.
|
||||||
|
*/
|
||||||
|
class ParticipantStatusRuleRegistry
|
||||||
|
{
|
||||||
|
private const DEFAULT_STATUS = 'F';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ParticipantStatusRuleInterface[]
|
||||||
|
*/
|
||||||
|
private array $sortedRules;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ParticipantStatusRuleInterface[] $rules The rules to register
|
||||||
|
*/
|
||||||
|
public function __construct(array $rules)
|
||||||
|
{
|
||||||
|
$this->sortedRules = $this->sortRulesByPriority($rules);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Evaluates all rules to determine the participant's status.
|
||||||
|
*
|
||||||
|
* Rules are evaluated in priority order (highest first). The first rule
|
||||||
|
* that matches determines the status. Returns 'F' if no rules match.
|
||||||
|
*
|
||||||
|
* @param ParticipantDto $participant The participant to evaluate
|
||||||
|
*
|
||||||
|
* @return string The determined status code
|
||||||
|
*/
|
||||||
|
public function evaluateStatus(ParticipantDto $participant): string
|
||||||
|
{
|
||||||
|
foreach ($this->sortedRules as $rule) {
|
||||||
|
if (true === $rule->evaluate($participant)) {
|
||||||
|
return $rule->getStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::DEFAULT_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sorts rules by priority in descending order.
|
||||||
|
*
|
||||||
|
* @param ParticipantStatusRuleInterface[] $rules The rules to sort
|
||||||
|
*
|
||||||
|
* @return ParticipantStatusRuleInterface[] The sorted rules
|
||||||
|
*/
|
||||||
|
private function sortRulesByPriority(array $rules): array
|
||||||
|
{
|
||||||
|
usort($rules, static fn (
|
||||||
|
ParticipantStatusRuleInterface $a,
|
||||||
|
ParticipantStatusRuleInterface $b,
|
||||||
|
): int => $b->getPriority() <=> $a->getPriority());
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\BusProNet\Service\StatusRule;
|
||||||
|
|
||||||
|
use App\BusProNet\Model\Service;
|
||||||
|
use App\BusProNet\Service\Contract\ParticipantStatusRuleInterface;
|
||||||
|
use App\Form\Model\ParticipantDto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Status rule for participants with chaperon (Begleitperson) services.
|
||||||
|
*
|
||||||
|
* Assigns 'Option' status to participants who have selected any service
|
||||||
|
* containing 'Begleitperson' in its label. This applies to accompanying
|
||||||
|
* persons whose booking confirmation may depend on the main participant.
|
||||||
|
*/
|
||||||
|
class ChaperonServiceStatusRule implements ParticipantStatusRuleInterface
|
||||||
|
{
|
||||||
|
private const STATUS = 'O';
|
||||||
|
private const PRIORITY = 100;
|
||||||
|
private const SEARCH_TERM = 'begleitperson';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ParticipantStatusRuleInterface::evaluate()
|
||||||
|
*/
|
||||||
|
public function evaluate(ParticipantDto $participant): bool
|
||||||
|
{
|
||||||
|
// Check array services
|
||||||
|
$arrayServices = [
|
||||||
|
$participant->additionalServices,
|
||||||
|
$participant->courses,
|
||||||
|
$participant->board,
|
||||||
|
$participant->rentals,
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($arrayServices as $services) {
|
||||||
|
foreach ($services as $service) {
|
||||||
|
if ($service instanceof Service && true === $this->containsSearchTerm($service->label)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check single service properties
|
||||||
|
$singleServices = [
|
||||||
|
$participant->skiPass,
|
||||||
|
$participant->veg,
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($singleServices as $service) {
|
||||||
|
if ($service instanceof Service && true === $this->containsSearchTerm($service->label)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ParticipantStatusRuleInterface::getStatus()
|
||||||
|
*/
|
||||||
|
public function getStatus(): string
|
||||||
|
{
|
||||||
|
return self::STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ParticipantStatusRuleInterface::getPriority()
|
||||||
|
*/
|
||||||
|
public function getPriority(): int
|
||||||
|
{
|
||||||
|
return self::PRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ParticipantStatusRuleInterface::getDescription()
|
||||||
|
*/
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Assigns Option status when a Begleitperson service is selected';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the label contains the search term (case-insensitive).
|
||||||
|
*/
|
||||||
|
private function containsSearchTerm(?string $label): bool
|
||||||
|
{
|
||||||
|
if (null === $label) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false !== stripos($label, self::SEARCH_TERM);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -75,7 +75,7 @@ class Step3Controller extends AbstractController
|
|||||||
return $this->handleApiError(
|
return $this->handleApiError(
|
||||||
'Booking inquiry failed',
|
'Booking inquiry failed',
|
||||||
['message' => $inquiryResponse->message],
|
['message' => $inquiryResponse->message],
|
||||||
$inquiryResponse->message ?? 'Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut.',
|
$inquiryResponse->message ?? 'Ein Fehler ist aufgetreten. Bitte versuche es erneut.',
|
||||||
$bookingCreateDto,
|
$bookingCreateDto,
|
||||||
$form
|
$form
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -285,9 +285,9 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
|
|||||||
}
|
}
|
||||||
$priceLabel = (null === $service->price || 0.0 === $service->price)
|
$priceLabel = (null === $service->price || 0.0 === $service->price)
|
||||||
? 'inkl.'
|
? 'inkl.'
|
||||||
: number_format($service->price, 2, ',', '.') . ' €';
|
: number_format($service->price, 2, ',', '.').' €';
|
||||||
|
|
||||||
return $service->label . ' (' . $priceLabel . ')';
|
return $service->label.' ('.$priceLabel.')';
|
||||||
},
|
},
|
||||||
'choice_attr' => function (?Service $service) use ($bookingDto, $participantIndex) {
|
'choice_attr' => function (?Service $service) use ($bookingDto, $participantIndex) {
|
||||||
if (null === $service) {
|
if (null === $service) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ use App\BusProNet\Model\Pickup;
|
|||||||
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;
|
||||||
|
use App\BusProNet\Service\ParticipantStatusRuleRegistry;
|
||||||
use App\Form\Model\BookingDto;
|
use App\Form\Model\BookingDto;
|
||||||
use App\Form\Model\ParticipantDto;
|
use App\Form\Model\ParticipantDto;
|
||||||
use App\Service\BookingPriceCalculatorService;
|
use App\Service\BookingPriceCalculatorService;
|
||||||
@@ -52,7 +53,8 @@ class BookingDataProcessorTest extends TestCase
|
|||||||
// Create the new dependencies
|
// Create the new dependencies
|
||||||
$mappingCollector = new ServiceMappingCollector();
|
$mappingCollector = new ServiceMappingCollector();
|
||||||
$serviceProcessor = new ParticipantServiceProcessor(new NullLogger());
|
$serviceProcessor = new ParticipantServiceProcessor(new NullLogger());
|
||||||
$payloadBuilder = new BookingPayloadBuilder($mappingCollector);
|
$statusRuleRegistry = new ParticipantStatusRuleRegistry([]);
|
||||||
|
$payloadBuilder = new BookingPayloadBuilder($mappingCollector, $statusRuleRegistry);
|
||||||
$personalDataSynchronizer = new PersonalDataSynchronizer();
|
$personalDataSynchronizer = new PersonalDataSynchronizer();
|
||||||
|
|
||||||
$this->processor = new BookingDataProcessor(
|
$this->processor = new BookingDataProcessor(
|
||||||
|
|||||||
@@ -0,0 +1,129 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Tests\BusProNet\Service;
|
||||||
|
|
||||||
|
use App\BusProNet\Service\Contract\ParticipantStatusRuleInterface;
|
||||||
|
use App\BusProNet\Service\ParticipantStatusRuleRegistry;
|
||||||
|
use App\Form\Model\ParticipantDto;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class ParticipantStatusRuleRegistryTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testReturnsDefaultStatusWhenNoRulesMatch(): void
|
||||||
|
{
|
||||||
|
$rule = $this->createMock(ParticipantStatusRuleInterface::class);
|
||||||
|
$rule->method('evaluate')->willReturn(false);
|
||||||
|
$rule->method('getPriority')->willReturn(100);
|
||||||
|
|
||||||
|
$registry = new ParticipantStatusRuleRegistry([$rule]);
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
|
||||||
|
$this->assertSame('F', $registry->evaluateStatus($participant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testReturnsMatchingRuleStatus(): void
|
||||||
|
{
|
||||||
|
$rule = $this->createMock(ParticipantStatusRuleInterface::class);
|
||||||
|
$rule->method('evaluate')->willReturn(true);
|
||||||
|
$rule->method('getStatus')->willReturn('O');
|
||||||
|
$rule->method('getPriority')->willReturn(100);
|
||||||
|
|
||||||
|
$registry = new ParticipantStatusRuleRegistry([$rule]);
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
|
||||||
|
$this->assertSame('O', $registry->evaluateStatus($participant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testHigherPriorityRuleTakesPrecedence(): void
|
||||||
|
{
|
||||||
|
$lowPriorityRule = $this->createMock(ParticipantStatusRuleInterface::class);
|
||||||
|
$lowPriorityRule->method('evaluate')->willReturn(true);
|
||||||
|
$lowPriorityRule->method('getStatus')->willReturn('L');
|
||||||
|
$lowPriorityRule->method('getPriority')->willReturn(50);
|
||||||
|
|
||||||
|
$highPriorityRule = $this->createMock(ParticipantStatusRuleInterface::class);
|
||||||
|
$highPriorityRule->method('evaluate')->willReturn(true);
|
||||||
|
$highPriorityRule->method('getStatus')->willReturn('H');
|
||||||
|
$highPriorityRule->method('getPriority')->willReturn(100);
|
||||||
|
|
||||||
|
// Register low priority first, high priority second
|
||||||
|
$registry = new ParticipantStatusRuleRegistry([$lowPriorityRule, $highPriorityRule]);
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
|
||||||
|
// High priority rule should be evaluated first and match
|
||||||
|
$this->assertSame('H', $registry->evaluateStatus($participant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testEmptyRulesArrayReturnsDefaultStatus(): void
|
||||||
|
{
|
||||||
|
$registry = new ParticipantStatusRuleRegistry([]);
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
|
||||||
|
$this->assertSame('F', $registry->evaluateStatus($participant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFirstMatchingRuleWins(): void
|
||||||
|
{
|
||||||
|
$firstMatchingRule = $this->createMock(ParticipantStatusRuleInterface::class);
|
||||||
|
$firstMatchingRule->method('evaluate')->willReturn(true);
|
||||||
|
$firstMatchingRule->method('getStatus')->willReturn('A');
|
||||||
|
$firstMatchingRule->method('getPriority')->willReturn(100);
|
||||||
|
|
||||||
|
$secondMatchingRule = $this->createMock(ParticipantStatusRuleInterface::class);
|
||||||
|
$secondMatchingRule->method('evaluate')->willReturn(true);
|
||||||
|
$secondMatchingRule->method('getStatus')->willReturn('B');
|
||||||
|
$secondMatchingRule->method('getPriority')->willReturn(100);
|
||||||
|
|
||||||
|
$registry = new ParticipantStatusRuleRegistry([$firstMatchingRule, $secondMatchingRule]);
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
|
||||||
|
// First rule with same priority registered first should win
|
||||||
|
$this->assertSame('A', $registry->evaluateStatus($participant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNonMatchingHighPriorityRuleDoesNotBlockLowerPriority(): void
|
||||||
|
{
|
||||||
|
$highPriorityRule = $this->createMock(ParticipantStatusRuleInterface::class);
|
||||||
|
$highPriorityRule->method('evaluate')->willReturn(false);
|
||||||
|
$highPriorityRule->method('getStatus')->willReturn('H');
|
||||||
|
$highPriorityRule->method('getPriority')->willReturn(100);
|
||||||
|
|
||||||
|
$lowPriorityRule = $this->createMock(ParticipantStatusRuleInterface::class);
|
||||||
|
$lowPriorityRule->method('evaluate')->willReturn(true);
|
||||||
|
$lowPriorityRule->method('getStatus')->willReturn('L');
|
||||||
|
$lowPriorityRule->method('getPriority')->willReturn(50);
|
||||||
|
|
||||||
|
$registry = new ParticipantStatusRuleRegistry([$highPriorityRule, $lowPriorityRule]);
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
|
||||||
|
// High priority doesn't match, so low priority rule should be used
|
||||||
|
$this->assertSame('L', $registry->evaluateStatus($participant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMultipleRulesWithVariousPrioritiesAreSortedCorrectly(): void
|
||||||
|
{
|
||||||
|
$lowRule = $this->createMock(ParticipantStatusRuleInterface::class);
|
||||||
|
$lowRule->method('evaluate')->willReturn(true);
|
||||||
|
$lowRule->method('getStatus')->willReturn('LOW');
|
||||||
|
$lowRule->method('getPriority')->willReturn(10);
|
||||||
|
|
||||||
|
$mediumRule = $this->createMock(ParticipantStatusRuleInterface::class);
|
||||||
|
$mediumRule->method('evaluate')->willReturn(true);
|
||||||
|
$mediumRule->method('getStatus')->willReturn('MED');
|
||||||
|
$mediumRule->method('getPriority')->willReturn(50);
|
||||||
|
|
||||||
|
$highRule = $this->createMock(ParticipantStatusRuleInterface::class);
|
||||||
|
$highRule->method('evaluate')->willReturn(true);
|
||||||
|
$highRule->method('getStatus')->willReturn('HIGH');
|
||||||
|
$highRule->method('getPriority')->willReturn(100);
|
||||||
|
|
||||||
|
// Register in random order
|
||||||
|
$registry = new ParticipantStatusRuleRegistry([$mediumRule, $lowRule, $highRule]);
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
|
||||||
|
// Highest priority rule should match first
|
||||||
|
$this->assertSame('HIGH', $registry->evaluateStatus($participant));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Tests\BusProNet\Service\StatusRule;
|
||||||
|
|
||||||
|
use App\BusProNet\Model\Service;
|
||||||
|
use App\BusProNet\Service\StatusRule\ChaperonServiceStatusRule;
|
||||||
|
use App\Form\Model\ParticipantDto;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class ChaperonServiceStatusRuleTest extends TestCase
|
||||||
|
{
|
||||||
|
private ChaperonServiceStatusRule $rule;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
$this->rule = new ChaperonServiceStatusRule();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testReturnsTrueWhenBegleitpersonInAdditionalServices(): void
|
||||||
|
{
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
$service = new Service();
|
||||||
|
$service->label = 'Skibegleitperson Kurs';
|
||||||
|
$participant->additionalServices = [$service];
|
||||||
|
|
||||||
|
$this->assertTrue($this->rule->evaluate($participant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testReturnsTrueWhenBegleitpersonInCourses(): void
|
||||||
|
{
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
$service = new Service();
|
||||||
|
$service->label = 'Begleitperson Anfängerkurs';
|
||||||
|
$participant->courses = [$service];
|
||||||
|
|
||||||
|
$this->assertTrue($this->rule->evaluate($participant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testReturnsTrueWhenBegleitpersonInBoard(): void
|
||||||
|
{
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
$service = new Service();
|
||||||
|
$service->label = 'Halbpension Begleitperson';
|
||||||
|
$participant->board = [$service];
|
||||||
|
|
||||||
|
$this->assertTrue($this->rule->evaluate($participant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testReturnsTrueWhenBegleitpersonInRentals(): void
|
||||||
|
{
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
$service = new Service();
|
||||||
|
$service->label = 'Skiset Begleitperson';
|
||||||
|
$participant->rentals = [$service];
|
||||||
|
|
||||||
|
$this->assertTrue($this->rule->evaluate($participant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testReturnsTrueWhenBegleitpersonInSkiPass(): void
|
||||||
|
{
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
$service = new Service();
|
||||||
|
$service->label = 'Skipass Begleitperson 6 Tage';
|
||||||
|
$participant->skiPass = $service;
|
||||||
|
|
||||||
|
$this->assertTrue($this->rule->evaluate($participant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testReturnsTrueWhenBegleitpersonInVeg(): void
|
||||||
|
{
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
$service = new Service();
|
||||||
|
$service->label = 'Vegetarisch Begleitperson';
|
||||||
|
$participant->veg = $service;
|
||||||
|
|
||||||
|
$this->assertTrue($this->rule->evaluate($participant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testReturnsFalseWhenNoBegleitpersonService(): void
|
||||||
|
{
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
$service = new Service();
|
||||||
|
$service->label = 'Skipass 6 Tage Erwachsene';
|
||||||
|
$participant->skiPass = $service;
|
||||||
|
|
||||||
|
$this->assertFalse($this->rule->evaluate($participant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testReturnsFalseWithEmptyServices(): void
|
||||||
|
{
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
|
||||||
|
$this->assertFalse($this->rule->evaluate($participant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCaseInsensitiveMatch(): void
|
||||||
|
{
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
$service = new Service();
|
||||||
|
$service->label = 'BEGLEITPERSON Kurs';
|
||||||
|
$participant->additionalServices = [$service];
|
||||||
|
|
||||||
|
$this->assertTrue($this->rule->evaluate($participant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMixedCaseMatch(): void
|
||||||
|
{
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
$service = new Service();
|
||||||
|
$service->label = 'beGleitPerson Kurs';
|
||||||
|
$participant->courses = [$service];
|
||||||
|
|
||||||
|
$this->assertTrue($this->rule->evaluate($participant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testReturnsStatusO(): void
|
||||||
|
{
|
||||||
|
$this->assertSame('O', $this->rule->getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetPriorityReturns100(): void
|
||||||
|
{
|
||||||
|
$this->assertSame(100, $this->rule->getPriority());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetDescriptionReturnsNonEmptyString(): void
|
||||||
|
{
|
||||||
|
$description = $this->rule->getDescription();
|
||||||
|
|
||||||
|
$this->assertIsString($description);
|
||||||
|
$this->assertNotEmpty($description);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testHandlesNullLabel(): void
|
||||||
|
{
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
$service = new Service();
|
||||||
|
$service->label = null;
|
||||||
|
$participant->additionalServices = [$service];
|
||||||
|
|
||||||
|
$this->assertFalse($this->rule->evaluate($participant));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testMultipleServicesWithOneBegleitperson(): void
|
||||||
|
{
|
||||||
|
$participant = new ParticipantDto();
|
||||||
|
|
||||||
|
$normalService = new Service();
|
||||||
|
$normalService->label = 'Skipass 6 Tage';
|
||||||
|
|
||||||
|
$begleitpersonService = new Service();
|
||||||
|
$begleitpersonService->label = 'Skipass Begleitperson';
|
||||||
|
|
||||||
|
$participant->additionalServices = [$normalService, $begleitpersonService];
|
||||||
|
|
||||||
|
$this->assertTrue($this->rule->evaluate($participant));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user