mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 22:04:23 +00:00
export: create new filter tests
This commit is contained in:
parent
37dcbe92c0
commit
390009b395
@ -11,6 +11,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\ActivityBundle\Export\Filter\PersonFilters;
|
namespace Chill\ActivityBundle\Export\Filter\PersonFilters;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
use Chill\ActivityBundle\Repository\ActivityReasonRepository;
|
use Chill\ActivityBundle\Repository\ActivityReasonRepository;
|
||||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||||
@ -59,10 +60,10 @@ class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInt
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
// create a query for activity
|
// create a subquery for activity
|
||||||
$sqb = $qb->getEntityManager()->createQueryBuilder();
|
$sqb = $qb->getEntityManager()->createQueryBuilder();
|
||||||
$sqb->select('person_person_having_activity.id')
|
$sqb->select('person_person_having_activity.id')
|
||||||
->from('ChillActivityBundle:Activity', 'activity_person_having_activity')
|
->from(Activity::class, 'activity_person_having_activity')
|
||||||
->join('activity_person_having_activity.person', 'person_person_having_activity');
|
->join('activity_person_having_activity.person', 'person_person_having_activity');
|
||||||
|
|
||||||
// add clause between date
|
// add clause between date
|
||||||
|
@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityType;
|
||||||
|
use Chill\ActivityBundle\Export\Filter\ACPFilters\ActivityTypeFilter;
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Doctrine\ORM\Query\Expr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class ActivityTypeFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private ActivityTypeFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.person.export.filter_activitytype');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$array = $em->createQueryBuilder()
|
||||||
|
->from(ActivityType::class, 'at')
|
||||||
|
->select('at')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($array as $a) {
|
||||||
|
$data[] = [
|
||||||
|
'accepted_activitytypes' => $a
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('count(activity.id)')
|
||||||
|
->from(AccompanyingPeriod::class, 'acp')
|
||||||
|
->join(Activity::class, 'activity', Expr\Join::WITH, 'activity.accompanyingPeriod = acp')
|
||||||
|
->join('activity.activityType', 'acttype'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Chill\ActivityBundle\Export\Filter\ACPFilters\BySocialActionFilter;
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class BySocialActionFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private BySocialActionFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.activity.export.bysocialaction_filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$array = $em->createQueryBuilder()
|
||||||
|
->from(SocialAction::class, 'sa')
|
||||||
|
->select('sa')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($array as $a) {
|
||||||
|
$data[] = [
|
||||||
|
'accepted_socialactions' => $a
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('count(activity.id)')
|
||||||
|
->from(Activity::class, 'activity')
|
||||||
|
->join('activity.socialActions', 'actsocialaction'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Chill\ActivityBundle\Export\Filter\ACPFilters\BySocialIssueFilter;
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class BySocialIssueFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private BySocialIssueFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.activity.export.bysocialissue_filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$array = $em->createQueryBuilder()
|
||||||
|
->from(SocialIssue::class, 'si')
|
||||||
|
->select('si')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($array as $a) {
|
||||||
|
$data[] = [
|
||||||
|
'accepted_socialissues' => $a
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('count(activity.id)')
|
||||||
|
->from(Activity::class, 'activity')
|
||||||
|
->join('activity.socialIssues', 'actsocialissue')
|
||||||
|
,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Chill\ActivityBundle\Export\Filter\ACPFilters\ByUserFilter;
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class ByUserFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private ByUserFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.activity.export.byuser_filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$array = $em->createQueryBuilder()
|
||||||
|
->from(User::class, 'u')
|
||||||
|
->select('u')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($array as $a) {
|
||||||
|
$data[] = [
|
||||||
|
'accepted_users' => $a
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('count(activity.id)')
|
||||||
|
->from(Activity::class, 'activity')
|
||||||
|
->join('activity.users', 'actusers'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Chill\ActivityBundle\Export\Filter\ACPFilters\EmergencyFilter;
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class EmergencyFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private EmergencyFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.activity.export.emergency_filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['accepted_emergency' => true ],
|
||||||
|
['accepted_emergency' => false ],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('count(activity.id)')
|
||||||
|
->from(Activity::class, 'activity'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Chill\ActivityBundle\Export\Filter\ACPFilters\LocationTypeFilter;
|
||||||
|
use Chill\MainBundle\Entity\LocationType;
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class LocationTypeFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private LocationTypeFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.activity.export.locationtype_filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$array = $em->createQueryBuilder()
|
||||||
|
->from(LocationType::class, 'lt')
|
||||||
|
->select('lt')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($array as $a) {
|
||||||
|
$data[] = [
|
||||||
|
'accepted_locationtype' => $a
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('count(activity.id)')
|
||||||
|
->from(Activity::class, 'activity')
|
||||||
|
->join('activity.location', 'actloc'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Chill\ActivityBundle\Export\Filter\ACPFilters\SentReceivedFilter;
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class SentReceivedFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private SentReceivedFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.activity.export.sentreceived_filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['accepted_sentreceived' => Activity::SENTRECEIVED_SENT ],
|
||||||
|
['accepted_sentreceived' => Activity::SENTRECEIVED_RECEIVED ]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('count(activity.id)')
|
||||||
|
->from(Activity::class, 'activity'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Chill\ActivityBundle\Export\Filter\ACPFilters\UserFilter;
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class UserFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private UserFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.activity.export.user_filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$array = $em->createQueryBuilder()
|
||||||
|
->from(User::class, 'u')
|
||||||
|
->select('u')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($array as $a) {
|
||||||
|
$data[] = [
|
||||||
|
'accepted_users' => $a
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('count(activity.id)')
|
||||||
|
->from(Activity::class, 'activity'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Chill\ActivityBundle\Export\Filter\ACPFilters\UserScopeFilter;
|
||||||
|
use Chill\MainBundle\Entity\Scope;
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class UserScopeFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private UserScopeFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.activity.export.userscope_filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$array = $em->createQueryBuilder()
|
||||||
|
->from(Scope::class, 's')
|
||||||
|
->select('s')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($array as $a) {
|
||||||
|
$data[] = [
|
||||||
|
'accepted_userscope' => $a
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('count(activity.id)')
|
||||||
|
->from(Activity::class, 'activity')
|
||||||
|
->join('activity.user', 'actuser'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Tests\Export\Filter;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Chill\ActivityBundle\Export\Filter\ActivityDateFilter;
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class ActivityDateFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private ActivityDateFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.activity.export.date_filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'date_from' => \DateTime::createFromFormat('Y-m-d', '2020-01-01'),
|
||||||
|
'date_to' => \DateTime::createFromFormat('Y-m-d', '2021-01-01'),
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('count(activity.id)')
|
||||||
|
->from(Activity::class, 'activity'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Tests\Export\Filter;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityType;
|
||||||
|
use Chill\ActivityBundle\Export\Filter\ActivityTypeFilter;
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class ActivityTypeFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private ActivityTypeFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.activity.export.type_filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$array = $em->createQueryBuilder()
|
||||||
|
->from(ActivityType::class, 'at')
|
||||||
|
->select('at')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($array as $a) {
|
||||||
|
$data[] = [
|
||||||
|
'types' => $a
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('count(activity.id)')
|
||||||
|
->from(Activity::class, 'activity'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Tests\Export\Filter\PersonFilters;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
|
use Chill\ActivityBundle\Export\Filter\PersonFilters\ActivityReasonFilter;
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class ActivityReasonFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private ActivityReasonFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.activity.export.reason_filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$array = $em->createQueryBuilder()
|
||||||
|
->from(ActivityReason::class, 'ar')
|
||||||
|
->select('ar')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($array as $a) {
|
||||||
|
$data[] = [
|
||||||
|
'reasons' => $a
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('count(activity.id)')
|
||||||
|
->from(Activity::class, 'activity')
|
||||||
|
->join('activity.reasons', 'actreasons'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\ActivityBundle\Tests\Export\Filter\PersonFilters;
|
||||||
|
|
||||||
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
|
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||||
|
use Chill\ActivityBundle\Export\Filter\PersonFilters\PersonHavingActivityBetweenDateFilter;
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private PersonHavingActivityBetweenDateFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.activity.export.person_having_an_activity_between_date_filter');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$array = $em->createQueryBuilder()
|
||||||
|
->from(ActivityReason::class, 'ar')
|
||||||
|
->select('ar')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($array as $a) {
|
||||||
|
$data[] = [
|
||||||
|
'date_from' => \DateTime::createFromFormat('Y-m-d', '2021-07-01'),
|
||||||
|
'date_to' => \DateTime::createFromFormat('Y-m-d', '2022-07-01'),
|
||||||
|
'reasons' => $a
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('count(activity.id)')
|
||||||
|
->from(Activity::class, 'activity'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Tests\Export\Filter\EvaluationFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
||||||
|
use Chill\PersonBundle\Export\Filter\EvaluationFilters\EvaluationTypeFilter;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class EvaluationTypeFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private EvaluationTypeFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.person.export.filter_evaluationtype');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$array = $em->createQueryBuilder()
|
||||||
|
->from(Evaluation::class, 'e')
|
||||||
|
->select('e')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($array as $r) {
|
||||||
|
$data[] = [
|
||||||
|
'accepted_evaluationtype' => $r
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('workeval.id')
|
||||||
|
->from(AccompanyingPeriod::class, 'acp')
|
||||||
|
->join('acp.works', 'acpw')
|
||||||
|
->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Tests\Export\Filter\EvaluationFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
|
||||||
|
use Chill\PersonBundle\Export\Filter\EvaluationFilters\MaxDateFilter;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class MaxDateFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private MaxDateFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.person.export.filter_maxdate');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['maxdate' => false ],
|
||||||
|
['maxdate' => true ]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('workeval.id')
|
||||||
|
->from(AccompanyingPeriod::class, 'acp')
|
||||||
|
->join('acp.works', 'acpw')
|
||||||
|
->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Tests\Export\Filter\HouseholdFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
|
use Chill\PersonBundle\Entity\Household\HouseholdCompositionType;
|
||||||
|
use Chill\PersonBundle\Export\Filter\HouseholdFilters\CompositionFilter;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class CompositionFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private CompositionFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.person.export.filter_household_composition');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$array = $em->createQueryBuilder()
|
||||||
|
->from(HouseholdCompositionType::class, 'r')
|
||||||
|
->select('r')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($array as $r) {
|
||||||
|
$data[] = [
|
||||||
|
'accepted_composition' => $r,
|
||||||
|
'on_date' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('h.id')
|
||||||
|
->from(Household::class, 'h'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Export\Filter\PersonFilters\AccompanyingPeriodClosingFilter;
|
||||||
|
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class AccompanyingPeriodClosingFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private AccompanyingPeriodClosingFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->filter = self::$container->get('chill.person.export.filter_accompanying_period_closing');
|
||||||
|
} catch (ServiceNotFoundException $e) {
|
||||||
|
$this->markTestSkipped('The current configuration does not use accompanying_periods');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'date_from' => \DateTime::createFromFormat('Y-m-d', '2000-01-01'),
|
||||||
|
'date_to' => \DateTime::createFromFormat('Y-m-d', '2010-01-01'),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container
|
||||||
|
->get('doctrine.orm.entity_manager');
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('person.firstName')
|
||||||
|
->from('ChillPersonBundle:Person', 'person'),
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('person.firstName')
|
||||||
|
->from('ChillPersonBundle:Person', 'person')
|
||||||
|
// add a dummy where clause
|
||||||
|
->where('person.firstname IS NOT NULL'),
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('count(IDENTITY(p))')
|
||||||
|
->from('ChillPersonBundle:Person', 'person')
|
||||||
|
// add a dummy where clause
|
||||||
|
->where('person.firstname IS NOT NULL'),
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('count(IDENTITY(p))')
|
||||||
|
->from('ChillPersonBundle:Person', 'person')
|
||||||
|
->join('person.accompanyingPeriods', 'accompanying_period')
|
||||||
|
// add a dummy where clause
|
||||||
|
->where('person.firstname IS NOT NULL'),
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('activity.date AS date')
|
||||||
|
->select('activity.attendee as attendee')
|
||||||
|
->from('ChillActivityBundle:Activity', 'activity')
|
||||||
|
->join('activity.person', 'person')
|
||||||
|
->join('person.center', 'center'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Export\Filter\PersonFilters\AccompanyingPeriodOpeningFilter;
|
||||||
|
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class AccompanyingPeriodOpeningFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private AccompanyingPeriodOpeningFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->filter = self::$container->get('chill.person.export.filter_accompanying_period_opening');
|
||||||
|
} catch (ServiceNotFoundException $e) {
|
||||||
|
$this->markTestSkipped('The current configuration does not use accompanying_periods');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'date_from' => \DateTime::createFromFormat('Y-m-d', '2000-01-01'),
|
||||||
|
'date_to' => \DateTime::createFromFormat('Y-m-d', '2010-01-01'),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders()
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container
|
||||||
|
->get('doctrine.orm.entity_manager');
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('person.firstName')
|
||||||
|
->from('ChillPersonBundle:Person', 'person'),
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('person.firstName')
|
||||||
|
->from('ChillPersonBundle:Person', 'person')
|
||||||
|
// add a dummy where clause
|
||||||
|
->where('person.firstname IS NOT NULL'),
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('count(IDENTITY(p))')
|
||||||
|
->from('ChillPersonBundle:Person', 'person')
|
||||||
|
// add a dummy where clause
|
||||||
|
->where('person.firstname IS NOT NULL'),
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('count(IDENTITY(p))')
|
||||||
|
->from('ChillPersonBundle:Person', 'person')
|
||||||
|
->join('person.accompanyingPeriods', 'accompanying_period')
|
||||||
|
// add a dummy where clause
|
||||||
|
->where('person.firstname IS NOT NULL'),
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('activity.date AS date')
|
||||||
|
->select('activity.attendee as attendee')
|
||||||
|
->from('ChillActivityBundle:Activity', 'activity')
|
||||||
|
->join('activity.person', 'person')
|
||||||
|
->join('person.center', 'center'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\PersonBundle\Export\Filter\PersonFilters\AgeFilter;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class AgeFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private AgeFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.person.export.filter_age');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'min_age' => '18',
|
||||||
|
'max_age' => '60',
|
||||||
|
'date_calc' => \DateTime::createFromFormat('Y-m-d', '2020-05-01'),
|
||||||
|
],
|
||||||
|
[ // ça devrait faire boum !
|
||||||
|
'min_age' => '35',
|
||||||
|
'max_age' => '30',
|
||||||
|
'date_calc' => \DateTime::createFromFormat('Y-m-d', '2020-05-01'),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('p.id')
|
||||||
|
->from(Person::class, 'p'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\PersonBundle\Export\Filter\PersonFilters\DeadOrAliveFilter;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class DeadOrAliveFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private DeadOrAliveFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.person.export.filter_dead_or_alive');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'person_state' => 'alive',
|
||||||
|
'date_calc' => \DateTime::createFromFormat('Y-m-d', '2021-05-01'),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'person_state' => 'deceased',
|
||||||
|
'date_calc' => \DateTime::createFromFormat('Y-m-d', '2021-05-01'),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('p.id')
|
||||||
|
->from(Person::class, 'p'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\PersonBundle\Export\Filter\PersonFilters\DeathdateFilter;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class DeathdateFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private DeathdateFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.person.export.filter_deathdate');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'date_from' => \DateTime::createFromFormat('Y-m-d', '2020-05-01'),
|
||||||
|
'date_to' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'),
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('p.id')
|
||||||
|
->from(Person::class, 'p'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Entity\MaritalStatus;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\PersonBundle\Export\Filter\PersonFilters\MaritalStatusFilter;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class MaritalStatusFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private MaritalStatusFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.person.export.filter_marital_status');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$array = $em->createQueryBuilder()
|
||||||
|
->from(MaritalStatus::class, 'm')
|
||||||
|
->select('m')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($array as $m) {
|
||||||
|
$data[] = [
|
||||||
|
'maritalStatus' => $m,
|
||||||
|
'calc_date' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('p.id')
|
||||||
|
->from(Person::class, 'p'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\Country;
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\PersonBundle\Export\Filter\PersonFilters\NationalityFilter;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class NationalityFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private NationalityFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.person.export.filter_nationality');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$countries = $em->getRepository(Country::class)->findAll();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($countries as $c) {
|
||||||
|
$data[] = [
|
||||||
|
'nationalities' => $c
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('p.id')
|
||||||
|
->from(Person::class, 'p'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\PersonBundle\Entity\Person\ResidentialAddress;
|
||||||
|
use Chill\PersonBundle\Export\Filter\PersonFilters\ResidentialAddressAtThirdpartyFilter;
|
||||||
|
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Doctrine\ORM\Query\Expr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class ResidentialAddressAtThirdpartyFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private ResidentialAddressAtThirdpartyFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.person.export.filter_residential_address_at_thirdparty');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$array = $em->createQueryBuilder()
|
||||||
|
->from(ThirdPartyCategory::class, 'tpc')
|
||||||
|
->select('tpc')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($array as $r) {
|
||||||
|
$data[] = [
|
||||||
|
'thirdparty_cat' => $r,
|
||||||
|
'date_calc' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('p.id')
|
||||||
|
->from(Person::class, 'p')
|
||||||
|
->join(ResidentialAddress::class, 'resaddr', Expr\Join::WITH, 'resaddr.person = p')
|
||||||
|
->join('p.center', 'center')
|
||||||
|
->join('resaddr.hostThirdParty', 'tparty')
|
||||||
|
->join('tparty.categories', 'tpartycat')
|
||||||
|
,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\PersonBundle\Export\Filter\PersonFilters\ResidentialAddressAtThirdpartyFilter;
|
||||||
|
use Chill\PersonBundle\Export\Filter\PersonFilters\ResidentialAddressAtUserFilter;
|
||||||
|
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Doctrine\ORM\Query\Expr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class ResidentialAddressAtUserFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private ResidentialAddressAtUserFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.person.export.filter_residential_address_at_user');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('p.id')
|
||||||
|
->from(Person::class, 'p')
|
||||||
|
->join(Person\ResidentialAddress::class, 'resaddr', Expr\Join::WITH, 'resaddr.person = p')
|
||||||
|
->join('p.center', 'center'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Tests\Export\Filter\SocialWorkFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Chill\PersonBundle\Export\Filter\SocialWorkFilters\ReferrerFilter;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class ReferrerFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private ReferrerFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.person.export.filter_treatingagent');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$users = $em->getRepository(User::class)->findAll();
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach ($users as $u) {
|
||||||
|
$data[] = [
|
||||||
|
'accepted_agents' => $u
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('acpw.id')
|
||||||
|
->from(AccompanyingPeriod::class, 'acp')
|
||||||
|
->join('acp.works', 'acpw'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Tests\Export\Filter\SocialWorkFilters;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Chill\PersonBundle\Export\Filter\SocialWorkFilters\SocialWorkTypeFilter;
|
||||||
|
use Chill\PersonBundle\Repository\SocialWork\GoalRepository;
|
||||||
|
use Chill\PersonBundle\Repository\SocialWork\ResultRepository;
|
||||||
|
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
|
final class SocialWorkTypeFilterTest extends AbstractFilterTest
|
||||||
|
{
|
||||||
|
private SocialWorkTypeFilter $filter;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
|
||||||
|
// add a fake request with a default locale (used in translatable string)
|
||||||
|
$request = $this->prophesize();
|
||||||
|
|
||||||
|
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||||
|
$request->getLocale()->willReturn('fr');
|
||||||
|
|
||||||
|
$this->filter = self::$container->get('chill.person.export.filter_social_work_type');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
return $this->filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormData(): array
|
||||||
|
{
|
||||||
|
$action_repository = self::$container->get(SocialActionRepository::class);
|
||||||
|
$goal_repository = self::$container->get(GoalRepository::class);
|
||||||
|
$result_repository = self::$container->get(ResultRepository::class);
|
||||||
|
|
||||||
|
$actions = [];
|
||||||
|
$goals = [];
|
||||||
|
$results = [];
|
||||||
|
|
||||||
|
$social_actions = $action_repository->findAll();
|
||||||
|
foreach ($social_actions as $action) {
|
||||||
|
$actions[] = $action->getId();
|
||||||
|
$goals_by_action = $goal_repository->findBySocialActionWithDescendants($action);
|
||||||
|
foreach ($goals_by_action as $goal) {
|
||||||
|
$goals[] = $goal->getId();
|
||||||
|
$results_by_goal = $result_repository->findByGoal($goal);
|
||||||
|
foreach ($results_by_goal as $result) {
|
||||||
|
$results[] = $result->getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$results_by_action = $result_repository->findBySocialActionWithDescendants($action);
|
||||||
|
foreach ($results_by_action as $result) {
|
||||||
|
$results[] = $result->getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sort($actions);
|
||||||
|
sort($goals);
|
||||||
|
sort($results);
|
||||||
|
|
||||||
|
$actions = array_unique($actions);
|
||||||
|
$goals = array_unique($goals);
|
||||||
|
$results = array_unique($results);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
[
|
||||||
|
'actionType' => implode(',', $actions),
|
||||||
|
'goal' => implode(',', $goals),
|
||||||
|
'result' => implode(',', $results),
|
||||||
|
]
|
||||||
|
];
|
||||||
|
/// TODO ne fonctionne pas
|
||||||
|
var_dump($data);
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getQueryBuilders(): array
|
||||||
|
{
|
||||||
|
if (null === self::$kernel) {
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
return [
|
||||||
|
$em->createQueryBuilder()
|
||||||
|
->select('acpw.id')
|
||||||
|
->from(AccompanyingPeriod::class, 'acp')
|
||||||
|
->join('acp.works', 'acpw'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user