mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-03 21:34:59 +00:00
Merge branch '244-record-closing-motive-on-acc-period-closing' into 'master'
[Export] Ajout de la comptabilisation du nombre de changements de statuts du parcours Closes #244 See merge request Chill-Projet/chill-bundles!650
This commit is contained in:
@@ -312,4 +312,34 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
|
||||
$this->assertNull($period->getRequestorPerson());
|
||||
$this->assertNull($period->getRequestor());
|
||||
}
|
||||
|
||||
public function testSetStep(): void
|
||||
{
|
||||
$period = new AccompanyingPeriod();
|
||||
|
||||
$period->setStep(AccompanyingPeriod::STEP_CONFIRMED);
|
||||
|
||||
self::assertEquals(AccompanyingPeriod::STEP_CONFIRMED, $period->getStep());
|
||||
self::assertCount(1, $period->getStepHistories());
|
||||
|
||||
$period->setStep(AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT);
|
||||
|
||||
self::assertEquals(AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT, $period->getStep());
|
||||
self::assertCount(2, $period->getStepHistories());
|
||||
|
||||
$periodInactiveSteps = $period->getStepHistories()->filter(fn (AccompanyingPeriod\AccompanyingPeriodStepHistory $h) => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT === $h->getStep());
|
||||
self::assertCount(1, $periodInactiveSteps);
|
||||
|
||||
$period->setStep(AccompanyingPeriod::STEP_CLOSED, ['closing_motive' => $closingMotive = new AccompanyingPeriod\ClosingMotive()]);
|
||||
|
||||
self::assertEquals(AccompanyingPeriod::STEP_CLOSED, $period->getStep());
|
||||
self::assertCount(3, $period->getStepHistories());
|
||||
|
||||
$periodClosedSteps = $period->getStepHistories()->filter(fn (AccompanyingPeriod\AccompanyingPeriodStepHistory $h) => AccompanyingPeriod::STEP_CLOSED === $h->getStep());
|
||||
self::assertCount(1, $periodClosedSteps);
|
||||
|
||||
$periodClosedStep = $periodClosedSteps->first();
|
||||
|
||||
self::assertSame($closingMotive, $periodClosedStep->getClosingMotive());
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,68 @@
|
||||
<?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\Aggregator\AccompanyingPeriodStepHistoryAggregators;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodStepHistory;
|
||||
use Chill\PersonBundle\Export\Aggregator\AccompanyingPeriodStepHistoryAggregators\ByClosingMotiveAggregator;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepositoryInterface;
|
||||
use Chill\PersonBundle\Templating\Entity\ClosingMotiveRender;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class ByClosingMotiveAggregatorTest extends AbstractAggregatorTest
|
||||
{
|
||||
private ClosingMotiveRender $closingMotiveRender;
|
||||
private ClosingMotiveRepositoryInterface $closingMotiveRepository;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
self::bootKernel();
|
||||
$this->closingMotiveRender = self::$container->get(ClosingMotiveRender::class);
|
||||
$this->closingMotiveRepository = self::$container->get(ClosingMotiveRepositoryInterface::class);
|
||||
}
|
||||
|
||||
public function getAggregator()
|
||||
{
|
||||
return new ByClosingMotiveAggregator(
|
||||
$this->closingMotiveRepository,
|
||||
$this->closingMotiveRender
|
||||
);
|
||||
}
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
return [
|
||||
[],
|
||||
];
|
||||
}
|
||||
|
||||
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,
|
||||
];
|
||||
}
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
<?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\Aggregator\AccompanyingPeriodStepHistoryAggregators;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodStepHistory;
|
||||
use Chill\PersonBundle\Export\Enum\DateGroupingChoiceEnum;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Chill\PersonBundle\Export\Aggregator\AccompanyingPeriodStepHistoryAggregators\ByDateAggregator;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class ByDateAggregatorTest extends AbstractAggregatorTest
|
||||
{
|
||||
public function getAggregator()
|
||||
{
|
||||
return new ByDateAggregator();
|
||||
}
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'frequency' => DateGroupingChoiceEnum::YEAR->value,
|
||||
],
|
||||
[
|
||||
'frequency' => DateGroupingChoiceEnum::WEEK->value,
|
||||
],
|
||||
[
|
||||
'frequency' => DateGroupingChoiceEnum::MONTH->value,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
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,
|
||||
];
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
<?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\Aggregator\AccompanyingPeriodStepHistoryAggregators;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodStepHistory;
|
||||
use Chill\PersonBundle\Export\Aggregator\AccompanyingPeriodStepHistoryAggregators\ByStepAggregator;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class ByStepAggregatorTest extends AbstractAggregatorTest
|
||||
{
|
||||
public function getAggregator()
|
||||
{
|
||||
$translator = new class () implements TranslatorInterface {
|
||||
public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null)
|
||||
{
|
||||
return $id;
|
||||
}
|
||||
};
|
||||
|
||||
return new ByStepAggregator($translator);
|
||||
}
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
return [[]];
|
||||
}
|
||||
|
||||
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,
|
||||
];
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
<?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\Export;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\PersonBundle\Export\Export\CountAccompanyingCourseStepHistory;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class CountAccompanyingCourseStepHistoryTest extends AbstractExportTest
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
}
|
||||
|
||||
public function getExport()
|
||||
{
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
yield new CountAccompanyingCourseStepHistory($em, $this->getParameters(true));
|
||||
yield new CountAccompanyingCourseStepHistory($em, $this->getParameters(false));
|
||||
}
|
||||
|
||||
public function getFormData(): array
|
||||
{
|
||||
return [[]];
|
||||
}
|
||||
|
||||
public function getModifiersCombination()
|
||||
{
|
||||
return [[Declarations::ACP_TYPE], [Declarations::ACP_TYPE, Declarations::ACP_STEP_HISTORY]];
|
||||
}
|
||||
}
|
@@ -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 src\Bundle\ChillPersonBundle\Tests\Export\Filter\AccompanyingPeriodStepHistoryFilters;
|
||||
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodStepHistory;
|
||||
use Chill\PersonBundle\Export\Filter\AccompanyingPeriodStepHistoryFilters\ByDateFilter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class ByDateFilterTest extends AbstractFilterTest
|
||||
{
|
||||
private RollingDateConverterInterface $rollingDateConverter;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
self::bootKernel();
|
||||
|
||||
$this->rollingDateConverter = self::$container->get(RollingDateConverterInterface::class);
|
||||
}
|
||||
|
||||
public function getFilter()
|
||||
{
|
||||
return new ByDateFilter($this->rollingDateConverter);
|
||||
}
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'start_date' => new RollingDate(RollingDate::T_YEAR_CURRENT_START),
|
||||
'end_date' => new RollingDate(RollingDate::T_TODAY),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
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,
|
||||
];
|
||||
}
|
||||
}
|
@@ -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