72 lines
1.9 KiB
PHP
72 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Form\Service\Condition;
|
|
|
|
use App\BusProNet\Model\Travel;
|
|
use App\Form\Model\BookingDto;
|
|
use App\Form\Service\Condition\AccommodationMutabilityCondition;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class AccommodationMutabilityConditionTest extends TestCase
|
|
{
|
|
private AccommodationMutabilityCondition $condition;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->condition = new AccommodationMutabilityCondition();
|
|
}
|
|
|
|
public function testReturnsFalseWhenRoomsMutable(): void
|
|
{
|
|
$travel = new Travel();
|
|
$travel->roomsMutable = true;
|
|
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
$result = $this->condition->evaluate($bookingDto, 0, []);
|
|
|
|
$this->assertFalse($result, 'Should return false when rooms are mutable (field should be editable)');
|
|
}
|
|
|
|
public function testReturnsTrueWhenRoomsNotMutable(): void
|
|
{
|
|
$travel = new Travel();
|
|
$travel->roomsMutable = false;
|
|
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
$result = $this->condition->evaluate($bookingDto, 0, []);
|
|
|
|
$this->assertTrue($result, 'Should return true when rooms are not mutable (field should be static text)');
|
|
}
|
|
|
|
public function testDefaultTravelHasMutableRooms(): void
|
|
{
|
|
$travel = new Travel();
|
|
|
|
$bookingDto = new BookingDto($travel, 1);
|
|
|
|
$result = $this->condition->evaluate($bookingDto, 0, []);
|
|
|
|
$this->assertFalse($result, 'Default travel should have mutable rooms');
|
|
}
|
|
|
|
public function testGetDependentFieldsReturnsEmptyArray(): void
|
|
{
|
|
$result = $this->condition->getDependentFields();
|
|
|
|
$this->assertIsArray($result);
|
|
$this->assertEmpty($result);
|
|
}
|
|
|
|
public function testGetDescriptionReturnsString(): void
|
|
{
|
|
$result = $this->condition->getDescription();
|
|
|
|
$this->assertIsString($result);
|
|
$this->assertStringContainsString('not mutable', $result);
|
|
}
|
|
}
|