taktik-nette
This commit is contained in:
58
tests/Unit/UI/DTO/OrderDTOTest.php
Normal file
58
tests/Unit/UI/DTO/OrderDTOTest.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use App\UI\DTO\OrderDirection;
|
||||
use App\UI\DTO\OrderDTO;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class OrderDTOTest extends TestCase
|
||||
{
|
||||
public function testCreateOrReturnNullFromInvalidDataWithValidInputs(): void
|
||||
{
|
||||
$acceptFilters = ['name', 'created_at'];
|
||||
$order = 'name';
|
||||
$direction = 'ASC';
|
||||
|
||||
$orderDTO = OrderDTO::createOrReturnNullFromData($order, $direction, $acceptFilters);
|
||||
|
||||
$this->assertInstanceOf(OrderDTO::class, $orderDTO);
|
||||
$this->assertSame($order, $orderDTO->column);
|
||||
$this->assertSame(OrderDirection::ASC, $orderDTO->direction);
|
||||
}
|
||||
|
||||
public function testCreateOrReturnNullFromInvalidDataWithInvalidOrder(): void
|
||||
{
|
||||
$acceptFilters = ['name', 'created_at'];
|
||||
$order = 'invalid_column';
|
||||
$direction = 'ASC';
|
||||
|
||||
$orderDTO = OrderDTO::createOrReturnNullFromData($order, $direction, $acceptFilters);
|
||||
|
||||
$this->assertNull($orderDTO);
|
||||
}
|
||||
|
||||
public function testCreateOrReturnNullFromInvalidDataWithInvalidDirection(): void
|
||||
{
|
||||
$acceptFilters = ['name', 'created_at'];
|
||||
$order = 'name';
|
||||
$direction = 'INVALID_DIRECTION';
|
||||
|
||||
$orderDTO = OrderDTO::createOrReturnNullFromData($order, $direction, $acceptFilters);
|
||||
|
||||
$this->assertNull($orderDTO);
|
||||
}
|
||||
|
||||
public function testCreateOrReturnNullFromInvalidDataWithEmptyFilters(): void
|
||||
{
|
||||
$acceptFilters = [];
|
||||
$order = 'name';
|
||||
$direction = 'ASC';
|
||||
|
||||
$orderDTO = OrderDTO::createOrReturnNullFromData($order, $direction, $acceptFilters);
|
||||
|
||||
$this->assertNull($orderDTO);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user