Files
myep-team/tests/Model/TeamerFilterDtoTest.php

43 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Tests\Model;
use App\Model\TeamerFilterDto;
use PHPUnit\Framework\TestCase;
/**
* The all-season teamer list is a second view onto the same filter DTO: it is always scoped,
* but that scope is not something the admin chose. AbstractFilterDto counts every property that
* differs from a fresh instance, so an ordinary property would make the list permanently claim
* "1 Filter aktiv" and offer a Reset button that resets nothing. The underscore keeps it out.
*/
class TeamerFilterDtoTest extends TestCase
{
public function testTheScopeDoesNotCountAsAnActiveFilter(): void
{
$filterDto = (new TeamerFilterDto())->setAllSeason(true);
$this->assertTrue($filterDto->isAllSeason());
$this->assertSame(0, $filterDto->getActiveFiltersCount());
$this->assertFalse($filterDto->isActive());
}
public function testAFilterOnTopOfTheScopeStillCounts(): void
{
$filterDto = (new TeamerFilterDto())
->setAllSeason(true)
->setName('Fromme')
;
$this->assertSame(1, $filterDto->getActiveFiltersCount());
$this->assertTrue($filterDto->isActive());
}
public function testTheListIsUnscopedByDefault(): void
{
$this->assertFalse((new TeamerFilterDto())->isAllSeason());
}
}