feat: groups price calculator admin crud, booking/offer flow and api
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Model;
|
||||
|
||||
use App\Model\ContingentCalendarQuery;
|
||||
use App\Model\ContingentPricesQuery;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Validator\Validation;
|
||||
|
||||
class ContingentQueryTest extends TestCase
|
||||
{
|
||||
public function testCalendarQueryAcceptsValidRange(): void
|
||||
{
|
||||
$query = new ContingentCalendarQuery('HOTEL_1', '2026-01-01', '2026-12-31');
|
||||
|
||||
self::assertCount(0, $this->validator()->validate($query));
|
||||
self::assertSame('2026-01-01', $query->dateFromDate()->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider invalidCalendarQueries
|
||||
*/
|
||||
public function testCalendarQueryRejectsInvalidInput(ContingentCalendarQuery $query): void
|
||||
{
|
||||
self::assertGreaterThan(0, $this->validator()->validate($query)->count());
|
||||
}
|
||||
|
||||
public function invalidCalendarQueries(): iterable
|
||||
{
|
||||
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 'range over 366 days' => [new ContingentCalendarQuery('HOTEL', '2026-01-01', '2027-01-03')];
|
||||
yield 'invalid hotel code' => [new ContingentCalendarQuery('HOTEL CODE', '2026-01-01', '2026-01-02')];
|
||||
}
|
||||
|
||||
public function testPricesQueryRequiresFourDigitYear(): void
|
||||
{
|
||||
self::assertCount(0, $this->validator()->validate(new ContingentPricesQuery('HOTEL', 2026)));
|
||||
self::assertGreaterThan(0, $this->validator()->validate(new ContingentPricesQuery('HOTEL', 26))->count());
|
||||
}
|
||||
|
||||
private function validator(): \Symfony\Component\Validator\Validator\ValidatorInterface
|
||||
{
|
||||
return Validation::createValidatorBuilder()
|
||||
->enableAttributeMapping()
|
||||
->getValidator();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user