mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-03 21:34:59 +00:00
Implement ByStepFilter for AccompanyingPeriodStepHistoryFilters and its tests
A new feature has been added, the ByStepFilter, to the Chill project. The ByStepFilter provides a way to filter data in AccompanyingPeriodStepHistoryFilters based on certain steps. In addition, a new test suite has been introduced to ensure the correct functionality of this filter. The necessary translations for completing this feature have also been included.
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?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 src\Bundle\ChillPersonBundle\Tests\Export\Filter\AccompanyingPeriodStepHistoryFilters;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodStepHistory;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingPeriodStepHistoryFilters\ByStepFilter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class ByStepFilterTest extends AbstractFilterTest
|
||||
{
|
||||
public function getFilter()
|
||||
{
|
||||
$translator = new class () implements TranslatorInterface {
|
||||
public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null)
|
||||
{
|
||||
return $id;
|
||||
}
|
||||
};
|
||||
|
||||
return new ByStepFilter($translator);
|
||||
}
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'steps' => [AccompanyingPeriod::STEP_CONFIRMED, AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG],
|
||||
],
|
||||
[
|
||||
'steps' => [AccompanyingPeriod::STEP_CLOSED],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function getQueryBuilders()
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$qb = $em->createQueryBuilder()
|
||||
->select('COUNT(DISTINCT acpstephistory.id) As export_result')
|
||||
->from(AccompanyingPeriodStepHistory::class, 'acpstephistory')
|
||||
->join('acpstephistory.period', 'acp');
|
||||
|
||||
return [
|
||||
$qb,
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user