81 lines
2.9 KiB
PHP
81 lines
2.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Service\Questionnaire;
|
|
|
|
use App\Config\QuestionnaireCatalog;
|
|
use App\Entity\Application;
|
|
use App\Entity\Assignment;
|
|
use App\Entity\Destination;
|
|
use App\Entity\Disposition;
|
|
use App\Entity\JobProfile;
|
|
use App\Entity\Teamer;
|
|
use App\Service\Questionnaire\DispositionContext;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class DispositionContextTest extends TestCase
|
|
{
|
|
public function testEscortDispositionIsSnapshotted(): void
|
|
{
|
|
$context = DispositionContext::build($this->disposition(pickup: 4711));
|
|
|
|
$this->assertSame([
|
|
'teamerName' => 'Kim Muster',
|
|
'jobProfileName' => 'Reiseleitung',
|
|
'jobProfileCategory' => JobProfile::CATEGORY_GUIDE,
|
|
'destinationProduct' => 'Davos Klosters - Schwendi',
|
|
'hotel' => 'Schwendi',
|
|
'hotelCode' => 'DKI',
|
|
'dateFrom' => '2026-01-10',
|
|
'dateTo' => '2026-01-17',
|
|
'escortPickup' => ['busProId' => 4711, 'city' => 'Stuttgart', 'street' => 'Busbahnhof', 'time' => '21:30'],
|
|
// the escort leaves the evening before arrival
|
|
'escortPickupDate' => '2026-01-09',
|
|
], $context);
|
|
}
|
|
|
|
public function testDispositionWithoutEscortHasNoPickup(): void
|
|
{
|
|
$context = DispositionContext::build($this->disposition(pickup: 0));
|
|
|
|
$this->assertNull($context['escortPickup']);
|
|
$this->assertNull($context['escortPickupDate']);
|
|
}
|
|
|
|
public function testEveryoneGetsTheTeamerFeedbackAndABusEscortTheBusFeedbackToo(): void
|
|
{
|
|
$this->assertSame(
|
|
[QuestionnaireCatalog::TEAMER_FEEDBACK, QuestionnaireCatalog::BUS_FEEDBACK],
|
|
DispositionContext::questionnaires($this->disposition(pickup: 4711)->getAssignment()),
|
|
);
|
|
$this->assertSame(
|
|
[QuestionnaireCatalog::TEAMER_FEEDBACK],
|
|
DispositionContext::questionnaires($this->disposition(pickup: 0)->getAssignment()),
|
|
);
|
|
}
|
|
|
|
private function disposition(int $pickup): Disposition
|
|
{
|
|
$destination = (new Destination())
|
|
->setProduct('Davos Klosters - Schwendi')
|
|
->setHotel('Schwendi')
|
|
->setHotelCode('DKI')
|
|
->setDateFrom(new \DateTimeImmutable('2026-01-10'))
|
|
->setDateTo(new \DateTimeImmutable('2026-01-17'))
|
|
->setPickups([
|
|
['busProId' => 4711, 'city' => 'Stuttgart', 'street' => 'Busbahnhof', 'time' => '21:30'],
|
|
['busProId' => 4712, 'city' => 'Ulm', 'street' => 'ZOB', 'time' => '22:45'],
|
|
])
|
|
;
|
|
$assignment = (new Assignment())
|
|
->setDestination($destination)
|
|
->setJobProfile((new JobProfile())->setName('Reiseleitung')->setCategory(JobProfile::CATEGORY_GUIDE))
|
|
->setPickup($pickup)
|
|
;
|
|
$teamer = (new Teamer())->setFirstName('Kim')->setLastName('Muster');
|
|
|
|
return new Disposition(new Application($assignment, $teamer));
|
|
}
|
|
}
|