Merge branch '111_exports_suite' into 111_export_GeographicalUnit

This commit is contained in:
2022-10-03 12:00:15 +02:00
205 changed files with 7277 additions and 761 deletions

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Entity;
use Chill\MainBundle\Entity\Center;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Household\HouseholdMember;
@@ -191,4 +192,29 @@ final class PersonTest extends \PHPUnit\Framework\TestCase
$this->assertEquals($r['result'], Person::ERROR_ADDIND_PERIOD_AFTER_AN_OPEN_PERIOD);
}
public function testSetCenter()
{
$person = new Person();
$centerA = new Center();
$centerB = new Center();
$this->assertCount(0, $person->getCenterHistory());
$this->assertNull($person->getCenter());
$this->assertNull($person->getCenterCurrent());
$person->setCenter($centerA);
$this->assertCount(1, $person->getCenterHistory());
$this->assertSame($centerA, $person->getCenter());
$this->assertInstanceOf(Person\PersonCenterCurrent::class, $person->getCenterCurrent());
$this->assertSame($centerA, $person->getCenterCurrent()->getCenter());
$person->setCenter($centerB);
$this->assertCount(2, $person->getCenterHistory());
$this->assertSame($centerB, $person->getCenter());
$this->assertInstanceOf(Person\PersonCenterCurrent::class, $person->getCenterCurrent());
$this->assertSame($centerB, $person->getCenterCurrent()->getCenter());
}
}

View File

@@ -0,0 +1,58 @@
<?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\Aggregator\AccompanyingCourseAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\AdministrativeLocationAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class AdministrativeLocationAggregatorTest extends AbstractAggregatorTest
{
private AdministrativeLocationAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_administrative_location');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.administrativeLocation', 'acploc')
,
];
}
}

View File

@@ -0,0 +1,58 @@
<?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\Aggregator\AccompanyingCourseAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ClosingMotiveAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class ClosingMotiveAggregatorTest extends AbstractAggregatorTest
{
private ClosingMotiveAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_closingmotive');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.closingMotive', 'acpmotive')
,
];
}
}

View File

@@ -0,0 +1,57 @@
<?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\Aggregator\AccompanyingCourseAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ConfidentialAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class ConfidentialAggregatorTest extends AbstractAggregatorTest
{
private ConfidentialAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_confidential');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
,
];
}
}

View File

@@ -0,0 +1,57 @@
<?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\Aggregator\AccompanyingCourseAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\DurationAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class DurationAggregatorTest extends AbstractAggregatorTest
{
private DurationAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_duration');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
,
];
}
}

View File

@@ -0,0 +1,57 @@
<?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\Aggregator\AccompanyingCourseAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\EmergencyAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class EmergencyAggregatorTest extends AbstractAggregatorTest
{
private EmergencyAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_emergency');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
,
];
}
}

View File

@@ -0,0 +1,59 @@
<?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\Aggregator\AccompanyingCourseAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\EvaluationAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class EvaluationAggregatorTest extends AbstractAggregatorTest
{
private EvaluationAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_evaluation');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.works', 'acpw')
->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval')
,
];
}
}

View File

@@ -0,0 +1,57 @@
<?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\Aggregator\AccompanyingCourseAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\IntensityAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class IntensityAggregatorTest extends AbstractAggregatorTest
{
private IntensityAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_intensity');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
,
];
}
}

View File

@@ -0,0 +1,58 @@
<?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\Aggregator\AccompanyingCourseAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\JobAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class JobAggregatorTest extends AbstractAggregatorTest
{
private JobAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_referrer_job');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.job', 'acpjob')
,
];
}
}

View File

@@ -0,0 +1,58 @@
<?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\Aggregator\AccompanyingCourseAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\OriginAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class OriginAggregatorTest extends AbstractAggregatorTest
{
private OriginAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_origin');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.origin', 'acporigin')
,
];
}
}

View File

@@ -0,0 +1,58 @@
<?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\Aggregator\AccompanyingCourseAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ReferrerAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class ReferrerAggregatorTest extends AbstractAggregatorTest
{
private ReferrerAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_referrer');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.user', 'acpuser')
,
];
}
}

View File

@@ -0,0 +1,58 @@
<?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\Aggregator\AccompanyingCourseAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\RequestorAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class RequestorAggregatorTest extends AbstractAggregatorTest
{
private RequestorAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_requestor');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.participations', 'acppart')
,
];
}
}

View File

@@ -0,0 +1,58 @@
<?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\Aggregator\AccompanyingCourseAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ScopeAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class ScopeAggregatorTest extends AbstractAggregatorTest
{
private ScopeAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_referrer_scope');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.scopes', 'acpscope')
,
];
}
}

View File

@@ -0,0 +1,58 @@
<?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\Aggregator\AccompanyingCourseAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\SocialActionAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class SocialActionAggregatorTest extends AbstractAggregatorTest
{
private SocialActionAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_socialaction');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.works', 'acpw')
,
];
}
}

View File

@@ -0,0 +1,58 @@
<?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\Aggregator\AccompanyingCourseAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\SocialIssueAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class SocialIssueAggregatorTest extends AbstractAggregatorTest
{
private SocialIssueAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_socialissue');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.socialIssues', 'acpsocialissue')
,
];
}
}

View File

@@ -0,0 +1,59 @@
<?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\Aggregator\AccompanyingCourseAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\StepAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class StepAggregatorTest extends AbstractAggregatorTest
{
private StepAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_step');
}
public function getAggregator()
{
return $this->aggregator;
}
public function getFormData(): array
{
return [
[
'on_date' => \DateTime::createFromFormat('Y-m-d', '2022-01-01'),
],
];
}
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->select('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
,
];
}
}

View File

@@ -0,0 +1,59 @@
<?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\Aggregator\EvaluationAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\EvaluationAggregators\EvaluationTypeAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class EvaluationTypeAggregatorTest extends AbstractAggregatorTest
{
private EvaluationTypeAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_evaluationtype');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.works', 'acpw')
->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval')
,
];
}
}

View File

@@ -0,0 +1,64 @@
<?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\Aggregator\HouseholdAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\HouseholdAggregators\ChildrenNumberAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class ChildrenNumberAggregatorTest extends AbstractAggregatorTest
{
private ChildrenNumberAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_household_childrennumber');
}
public function getAggregator()
{
return $this->aggregator;
}
public function getFormData(): array
{
return [
[
'on_date' => \DateTime::createFromFormat('Y-m-d', '2022-07-01')
],
];
}
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->select('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.participations', 'acppart')
->join('acppart.person', 'partperson')
->join('partperson.householdParticipations', 'member')
->join('member.household', 'household')
->join('household.compositions', 'composition')
,
];
}
}

View File

@@ -0,0 +1,64 @@
<?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\Aggregator\HouseholdAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\HouseholdAggregators\CompositionAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class CompositionAggregatorTest extends AbstractAggregatorTest
{
private CompositionAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_household_composition');
}
public function getAggregator()
{
return $this->aggregator;
}
public function getFormData(): array
{
return [
[
'on_date' => \DateTime::createFromFormat('Y-m-d', '2022-07-01')
],
];
}
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->select('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.participations', 'acppart')
->join('acppart.person', 'partperson')
->join('partperson.householdParticipations', 'member')
->join('member.household', 'household')
->join('household.compositions', 'composition')
,
];
}
}

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Aggregator\PersonAggregators;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\PersonAggregators\AgeAggregator;
use DateTime;
/**
@@ -20,10 +21,7 @@ use DateTime;
*/
final class AgeAggregatorTest extends AbstractAggregatorTest
{
/**
* @var \Chill\PersonBundle\Export\Aggregator\PersonAggregators\AgeAggregator
*/
private $aggregator;
private AgeAggregator $aggregator;
protected function setUp(): void
{

View File

@@ -0,0 +1,59 @@
<?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\Aggregator\PersonAggregators;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Export\Aggregator\PersonAggregators\CountryOfBirthAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class CountryOfBirthAggregatorTest extends AbstractAggregatorTest
{
private CountryOfBirthAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_country_of_birth');
}
public function getAggregator()
{
return $this->aggregator;
}
public function getFormData(): array
{
return [
['group_by_level' => 'continent'],
['group_by_level' => 'country',],
];
}
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->select('count(person.id)')
->from(Person::class, 'person')
->leftJoin('person.countryOfBirth', 'countryOfBirth')
,
];
}
}

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Aggregator\PersonAggregators;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\PersonAggregators\GenderAggregator;
/**
* @internal
@@ -19,10 +20,7 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
*/
final class GenderAggregatorTest extends AbstractAggregatorTest
{
/**
* @var \Chill\PersonBundle\Export\Aggregator\PersonAggregators\GenderAggregator
*/
private $aggregator;
private GenderAggregator $aggregator;
protected function setUp(): void
{

View File

@@ -0,0 +1,63 @@
<?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\Aggregator\PersonAggregators;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Entity\Household\HouseholdMember;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Export\Aggregator\PersonAggregators\HouseholdPositionAggregator;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\Expr;
final class HouseholdPositionAggregatorTest extends AbstractAggregatorTest
{
private HouseholdPositionAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_household_position');
}
public function getAggregator()
{
return $this->aggregator;
}
public function getFormData(): array
{
return [
[
'date_position' => \DateTime::createFromFormat('Y-m-d', '2022-07-01')
],
];
}
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->select('count(person.id)')
->from(Person::class, 'person')
->join(HouseholdMember::class, 'householdmember', Expr\Join::WITH, 'householdmember.person = person')
->join('person.center', 'center')
,
];
}
}

View File

@@ -0,0 +1,58 @@
<?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\Aggregator\PersonAggregators;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Export\Aggregator\PersonAggregators\MaritalStatusAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class MaritalStatusAggregatorTest extends AbstractAggregatorTest
{
private MaritalStatusAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_marital_status');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(person.id)')
->from(Person::class, 'person')
->join('person.maritalStatus', 'personmarital')
,
];
}
}

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Aggregator\PersonAggregators;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\PersonAggregators\NationalityAggregator;
/**
* @internal
@@ -19,10 +20,7 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
*/
final class NationalityAggregatorTest extends AbstractAggregatorTest
{
/**
* @var \Chill\PersonBundle\Export\Aggregator\PersonAggregators\NationalityAggregator
*/
private $aggregator;
private NationalityAggregator $aggregator;
protected function setUp(): void
{

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ActionTypeAggregator;
/**
@@ -34,14 +35,14 @@ final class ActionTypeAggregatorTest extends AbstractAggregatorTest
return $this->aggregator;
}
public function getFormData()
public function getFormData(): array
{
return [
[],
];
}
public function getQueryBuilders()
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
@@ -53,7 +54,8 @@ final class ActionTypeAggregatorTest extends AbstractAggregatorTest
return [
$em->createQueryBuilder()
->select('count(acpw.id)')
->from('ChillPersonBundle:AccompanyingPeriodWork', 'acpw'),
->from(AccompanyingPeriodWork::class, 'acpw')
,
];
}
}

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\GoalAggregator;
/**
@@ -34,14 +35,14 @@ final class GoalAggregatorTest extends AbstractAggregatorTest
return $this->aggregator;
}
public function getFormData()
public function getFormData(): array
{
return [
[],
];
}
public function getQueryBuilders()
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
@@ -53,7 +54,8 @@ final class GoalAggregatorTest extends AbstractAggregatorTest
return [
$em->createQueryBuilder()
->select('count(acpw.id)')
->from('ChillPersonBundle:AccompanyingPeriodWork', 'acpw'),
->from(AccompanyingPeriodWork::class, 'acpw')
,
];
}
}

View File

@@ -0,0 +1,60 @@
<?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\Aggregator\SocialWorkAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\GoalResultAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class GoalResultAggregatorTest extends AbstractAggregatorTest
{
private GoalResultAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_goalresult');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.works', 'acpw')
->join('acpw.goals', 'goal')
->join('goal.results', 'goalresult')
,
];
}
}

View File

@@ -0,0 +1,59 @@
<?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\Aggregator\SocialWorkAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\JobAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class JobAggregatorTest extends AbstractAggregatorTest
{
private JobAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_treatingagent_job');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.works', 'acpw')
->join('acpw.referrers', 'acpwuser')
,
];
}
}

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ReferrerAggregator;
/**
@@ -34,14 +35,14 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest
return $this->aggregator;
}
public function getFormData()
public function getFormData(): array
{
return [
[],
];
}
public function getQueryBuilders()
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
@@ -53,7 +54,8 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest
return [
$em->createQueryBuilder()
->select('count(acpw.id)')
->from('ChillPersonBundle:AccompanyingPeriodWork', 'acpw'),
->from(AccompanyingPeriodWork::class, 'acpw')
,
];
}
}

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ResultAggregator;
/**
@@ -34,14 +35,14 @@ final class ResultAggregatorTest extends AbstractAggregatorTest
return $this->aggregator;
}
public function getFormData()
public function getFormData(): array
{
return [
[],
];
}
public function getQueryBuilders()
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
@@ -53,7 +54,8 @@ final class ResultAggregatorTest extends AbstractAggregatorTest
return [
$em->createQueryBuilder()
->select('count(acpw.id)')
->from('ChillPersonBundle:AccompanyingPeriodWork', 'acpw'),
->from(AccompanyingPeriodWork::class, 'acpw')
,
];
}
}

View File

@@ -0,0 +1,59 @@
<?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\Aggregator\SocialWorkAggregators;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ScopeAggregator;
use Doctrine\ORM\EntityManagerInterface;
final class ScopeAggregatorTest extends AbstractAggregatorTest
{
private ScopeAggregator $aggregator;
protected function setUp(): void
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.person.export.aggregator_treatingagent_scope');
}
public function getAggregator()
{
return $this->aggregator;
}
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('count(acp.id)')
->from(AccompanyingPeriod::class, 'acp')
->join('acp.works', 'acpw')
->join('acpw.referrers', 'acpwuser')
,
];
}
}

View File

@@ -12,7 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\UserJobFilter;
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\CurrentUserJobFilter;
use Doctrine\ORM\EntityManagerInterface;
/**
@@ -21,7 +21,7 @@ use Doctrine\ORM\EntityManagerInterface;
*/
final class CurrentUserJobFilterTest extends AbstractFilterTest
{
private UserJobFilter $filter;
private CurrentUserJobFilter $filter;
protected function setUp(): void
{

View File

@@ -12,7 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\UserScopeFilter;
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\CurrentUserScopeFilter;
use Doctrine\ORM\EntityManagerInterface;
/**
@@ -21,7 +21,7 @@ use Doctrine\ORM\EntityManagerInterface;
*/
final class CurrentUserScopeFilterTest extends AbstractFilterTest
{
private UserScopeFilter $filter;
private CurrentUserScopeFilter $filter;
protected function setUp(): void
{

View File

@@ -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'),
];
}
}

View File

@@ -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'),
];
}
}

View File

@@ -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'),
];
}
}

View File

@@ -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'),
];
}
}

View File

@@ -12,7 +12,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Export\Filter\PersonFilters\BirthdateFilter;
use Chill\PersonBundle\Export\Filter\PersonFilters\AccompanyingPeriodFilter;
use DateTime;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
@@ -22,7 +22,7 @@ use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
*/
final class AccompanyingPeriodFilterTest extends AbstractFilterTest
{
private BirthdateFilter $filter;
private AccompanyingPeriodFilter $filter;
protected function setUp(): void
{

View File

@@ -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'),
];
}
}

View File

@@ -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'),
];
}
}

View File

@@ -19,7 +19,7 @@ use DateTime;
* @internal
* @coversNothing
*/
final class BirthdayFilterTest extends AbstractFilterTest
final class BirthdateFilterTest extends AbstractFilterTest
{
private BirthdateFilter $filter;

View File

@@ -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'),
];
}
}

View File

@@ -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'),
];
}
}

View File

@@ -9,34 +9,33 @@
declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters;
namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters;
use Chill\ActivityBundle\Entity\ActivityType;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\ActivityTypeFilter;
use Chill\PersonBundle\Entity\MaritalStatus;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Export\Filter\PersonFilters\MaritalStatusFilter;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* @internal
* @coversNothing
*/
final class ActivityTypeFilterTest extends AbstractFilterTest
final class MaritalStatusFilterTest extends AbstractFilterTest
{
private ActivityTypeFilter $filter;
private MaritalStatusFilter $filter;
protected function setUp(): void
{
//parent::setUp();
self::bootKernel();
// add a fake request with a default locale (used in translatable string)
$request = $this->prophesize();
$request->willExtend(Request::class);
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
$request->getLocale()->willReturn('fr');
$this->filter = self::$container->get('chill.person.export.filter_activitytype');
$this->filter = self::$container->get('chill.person.export.filter_marital_status');
}
public function getFilter()
@@ -49,15 +48,18 @@ final class ActivityTypeFilterTest extends AbstractFilterTest
$em = self::$container->get(EntityManagerInterface::class);
$array = $em->createQueryBuilder()
->from(ActivityType::class, 'at')
->select('at')
->from(MaritalStatus::class, 'm')
->select('m')
->getQuery()
->getResult();
$data = [];
foreach ($array as $t) {
$data[] = ['accepted_activitytypes' => $t];
foreach ($array as $m) {
$data[] = [
'maritalStatus' => $m,
'calc_date' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'),
];
}
return $data;
@@ -73,8 +75,9 @@ final class ActivityTypeFilterTest extends AbstractFilterTest
return [
$em->createQueryBuilder()
->from('ChillPersonBundle:AccompanyingPeriod', 'acp')
->select('acp.id'),
->select('p.id')
->from(Person::class, 'p'),
];
}
}

View File

@@ -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'),
];
}
}

View File

@@ -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')
,
];
}
}

View File

@@ -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'),
];
}
}

View File

@@ -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'),
];
}
}

View File

@@ -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'),
];
}
}

View File

@@ -0,0 +1,79 @@
<?php
namespace Chill\PersonBundle\Tests\Repository;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Repository\CenterRepositoryInterface;
use Chill\MainBundle\Repository\CountryRepository;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperInterface;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Repository\PersonACLAwareRepository;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Doctrine\ORM\EntityManagerInterface;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Security\Core\Security;
class PersonACLAwareRepositoryTest extends KernelTestCase
{
use ProphecyTrait;
private EntityManagerInterface $entityManager;
private CountryRepository $countryRepository;
private CenterRepositoryInterface $centerRepository;
protected function setUp(): void
{
self::bootKernel();
$this->entityManager = self::$container->get(EntityManagerInterface::class);
$this->countryRepository = self::$container->get(CountryRepository::class);
$this->centerRepository = self::$container->get(CenterRepositoryInterface::class);
}
public function testCountByCriteria()
{
$user = new User();
$authorizationHelper = $this->prophesize(AuthorizationHelperInterface::class);
$authorizationHelper->getReachableCenters(Argument::exact($user), Argument::exact(PersonVoter::SEE))
->willReturn($this->centerRepository->findAll());
$security = $this->prophesize(Security::class);
$security->getUser()->willReturn($user);
$repository = new PersonACLAwareRepository($security->reveal(), $this->entityManager, $this->countryRepository,
$authorizationHelper->reveal());
$number = $repository->countBySearchCriteria('diallo');
$this->assertGreaterThan(0, $number);
}
public function testFindByCriteria()
{
$user = new User();
$authorizationHelper = $this->prophesize(AuthorizationHelperInterface::class);
$authorizationHelper->getReachableCenters(Argument::exact($user), Argument::exact(PersonVoter::SEE))
->willReturn($this->centerRepository->findAll());
$security = $this->prophesize(Security::class);
$security->getUser()->willReturn($user);
$repository = new PersonACLAwareRepository($security->reveal(), $this->entityManager, $this->countryRepository,
$authorizationHelper->reveal());
$results = $repository->findBySearchCriteria(0, 5, false, 'diallo');
$this->assertGreaterThan(0, count($results));
$this->assertContainsOnlyInstancesOf(Person::class, $results);
foreach ($results as $person) {
$this->assertStringContainsString('diallo', strtolower($person->getFirstName() . ' ' . $person->getLastName()));
}
}
}