Add HasTemporaryLocationFilter test and update filter parameters

A new test HasTemporaryLocationFilterTest has been added under ChillPersonBundle. This test mainly focuses on checking the filter functionalities related to temporary locations. In addition, the 'having_temporarily' parameter has been added to 'calc_date' field in HasTemporaryLocationFilter class.
This commit is contained in:
Julien Fastré 2024-01-22 11:44:32 +01:00
parent ae7637acc6
commit e2e0b08210
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
2 changed files with 68 additions and 1 deletions

View File

@ -70,7 +70,7 @@ class HasTemporaryLocationFilter implements FilterInterface
},
])
->add('calc_date', PickRollingDateType::class, [
'label' => 'export.filter.course.having_temporarily.Calculation date',
'label' => 'export.filter.course.having_temporarily.Calculation date', 'having_temporarily' => true,
]);
}

View File

@ -0,0 +1,67 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\HasTemporaryLocationFilter;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
*
* @coversNothing
*/
class HasTemporaryLocationFilterTest extends AbstractFilterTest
{
private RollingDateConverterInterface $rollingDateConverter;
protected function setUp(): void
{
self::bootKernel();
$this->rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
}
public function getFilter()
{
return new HasTemporaryLocationFilter($this->rollingDateConverter);
}
public function getFormData()
{
return [
[
'having_temporarily' => true,
'calc_date' => new RollingDate(RollingDate::T_TODAY),
],
[
'having_temporarily' => false,
'calc_date' => new RollingDate(RollingDate::T_TODAY),
],
];
}
public function getQueryBuilders()
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->from('ChillPersonBundle:AccompanyingPeriod', 'acp')
->select('acp.id'),
];
}
}