diff --git a/composer.json b/composer.json
index 782a40ea4..dff41432b 100755
--- a/composer.json
+++ b/composer.json
@@ -18,8 +18,6 @@
"knplabs/knp-snappy-bundle": "^1.9",
"league/flysystem-aws-s3-v3": "^3.0",
"league/flysystem-bundle": "^3.0",
- "longitude-one/wkt-parser": "^3.0",
- "mjaschen/phpgeo": "^5.0",
"nelmio/cors-bundle": "^2.2",
"phpdocumentor/reflection-docblock": "^5.3",
"phpoffice/phpspreadsheet": "^2.2",
diff --git a/src/DataFixtures/Files/AutoAffectationRule.yml b/src/DataFixtures/Files/AutoAffectationRule.yml
index 91001e9f8..4cea70771 100644
--- a/src/DataFixtures/Files/AutoAffectationRule.yml
+++ b/src/DataFixtures/Files/AutoAffectationRule.yml
@@ -4,7 +4,7 @@ auto_affectation_rules:
status: "ACTIVE"
profile_declarant: "all"
partner_type: "COMMUNE_SCHS"
- insee_to_include: "partner_list"
+ insee_to_include: null
insee_to_exclude: null
parc: "all"
allocataire: "all"
@@ -13,7 +13,7 @@ auto_affectation_rules:
status: "ACTIVE"
profile_declarant: "all"
partner_type: "COMMUNE_SCHS"
- insee_to_include: "partner_list"
+ insee_to_include: null
insee_to_exclude: null
parc: "prive"
allocataire: "all"
@@ -22,7 +22,7 @@ auto_affectation_rules:
status: "ACTIVE"
profile_declarant: "all"
partner_type: "CAF_MSA"
- insee_to_include: "all"
+ insee_to_include: null
insee_to_exclude: null
parc: "prive"
allocataire: "caf"
@@ -40,7 +40,7 @@ auto_affectation_rules:
status: "ACTIVE"
profile_declarant: "LOCATAIRE"
partner_type: "EPCI"
- insee_to_include: "partner_list"
+ insee_to_include: null
insee_to_exclude:
- "34048"
parc: "prive"
@@ -50,7 +50,7 @@ auto_affectation_rules:
status: "ARCHIVED"
profile_declarant: "all"
partner_type: "EPCI"
- insee_to_include: "partner_list"
+ insee_to_include: null
insee_to_exclude: null
parc: "all"
allocataire: "all"
@@ -59,7 +59,7 @@ auto_affectation_rules:
status: "ACTIVE"
profile_declarant: "all"
partner_type: "POLICE_GENDARMERIE"
- insee_to_include: "all"
+ insee_to_include: null
insee_to_exclude: null
parc: "all"
allocataire: "all"
@@ -70,7 +70,7 @@ auto_affectation_rules:
status: "ACTIVE"
profile_declarant: "all"
partner_type: "COMMUNE_SCHS"
- insee_to_include: "partner_list"
+ insee_to_include: null
insee_to_exclude: null
parc: "all"
allocataire: "all"
@@ -79,7 +79,7 @@ auto_affectation_rules:
status: "ARCHIVED"
profile_declarant: "all"
partner_type: "EPCI"
- insee_to_include: "partner_list"
+ insee_to_include: null
insee_to_exclude: null
parc: "all"
allocataire: "all"
@@ -88,7 +88,7 @@ auto_affectation_rules:
status: "ACTIVE"
profile_declarant: "all"
partner_type: "BAILLEUR_SOCIAL"
- insee_to_include: "all"
+ insee_to_include: null
insee_to_exclude: null
parc: "public"
allocataire: "all"
diff --git a/src/Entity/AutoAffectationRule.php b/src/Entity/AutoAffectationRule.php
index a0bbd2d1a..13831d37d 100644
--- a/src/Entity/AutoAffectationRule.php
+++ b/src/Entity/AutoAffectationRule.php
@@ -53,11 +53,10 @@ enumType: PartnerType::class,
#[AppAssert\ValidProfileDeclarant()]
private string $profileDeclarant;
- #[ORM\Column(length: 255, options: ['comment' => 'Value possible all, partner_list or an array of code insee'])]
- #[Assert\NotBlank(message: 'Merci de renseigner les code insee des communes concernées.')]
+ #[ORM\Column(nullable: true, length: 255, options: ['comment' => 'Value possible null or an array of code insee'])]
#[Assert\Length(max: 255)]
#[AppAssert\InseeToInclude()]
- private string $inseeToInclude;
+ private ?string $inseeToInclude;
#[ORM\Column(nullable: true, options: ['comment' => 'Value possible null or an array of code insee'])]
#[AppAssert\InseeToExclude()]
@@ -144,12 +143,12 @@ public function setProfileDeclarant(string $profileDeclarant): self
return $this;
}
- public function getInseeToInclude(): string
+ public function getInseeToInclude(): ?string
{
return $this->inseeToInclude;
}
- public function setInseeToInclude(string $inseeToInclude): self
+ public function setInseeToInclude(?string $inseeToInclude): self
{
$this->inseeToInclude = $inseeToInclude;
@@ -292,14 +291,11 @@ public function getDescription(bool $isShort = true): string
$description .= ' Elle s\'applique ';
switch ($this->getInseeToInclude()) {
- case 'all':
- $description .= 'à tous les logements du territoire';
- break;
- case 'partner_list':
+ case null:
$description .= 'aux logements situés dans le périmètre géographique du partenaire (codes insee et/ou zones)';
break;
default:
- $description .= 'aux logements situés dans les communes aux codes insee suivants : '.$this->getInseeToInclude();
+ $description .= 'aux logements situés dans le périmètre géographique du partenaire (codes insee et/ou zones), limités aux codes insee suivants : '.$this->getInseeToInclude();
break;
}
if ($this->getInseeToExclude()) {
diff --git a/src/Form/AutoAffectationRuleType.php b/src/Form/AutoAffectationRuleType.php
index 7746c7f19..82489dc6c 100644
--- a/src/Form/AutoAffectationRuleType.php
+++ b/src/Form/AutoAffectationRuleType.php
@@ -124,12 +124,12 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
],
])
->add('inseeToInclude', TextType::class, [
- 'label' => 'Périmètre géographique à inclure',
+ 'label' => 'Périmètre géographique à inclure (facultatif)',
'attr' => [
'class' => 'fr-input',
],
- 'required' => true,
- 'help' => 'Valeurs possibles : "all", "partner_list" (codes insee, et zones) ou une liste de codes insee séparés par des virgules.',
+ 'required' => false,
+ 'help' => 'Une liste de codes insee séparés par des virgules.',
'help_attr' => [
'class' => 'fr-hint-text',
],
diff --git a/src/Repository/PartnerRepository.php b/src/Repository/PartnerRepository.php
index eae81f833..facbe6ff2 100755
--- a/src/Repository/PartnerRepository.php
+++ b/src/Repository/PartnerRepository.php
@@ -178,24 +178,58 @@ public function findFilteredArchivedPaginated(SearchArchivedPartner $searchArchi
* @throws Exception
*/
public function findByLocalization(Signalement $signalement, bool $affected = true): array
+ {
+ $queryData = $this->buildLocalizationQuery($signalement, $affected);
+
+ $resultSet = $this->getEntityManager()->getConnection()->executeQuery(
+ $queryData['sql'],
+ $queryData['params']
+ );
+
+ return $resultSet->fetchAllAssociative();
+ }
+
+ /**
+ * @throws Exception
+ */
+ public function findPartnersByLocalization(Signalement $signalement): array
+ {
+ $queryData = $this->buildLocalizationQuery($signalement, false); // Always use $affected = false
+
+ $resultSet = $this->getEntityManager()->getConnection()->executeQuery(
+ $queryData['sql'],
+ $queryData['params']
+ );
+ $partnerIds = array_column($resultSet->fetchAllAssociative(), 'id');
+
+ return $this->getEntityManager()->getRepository(Partner::class)->findBy(['id' => $partnerIds]);
+ }
+
+ /**
+ * Builds the SQL query and parameters for localization search.
+ *
+ * @throws Exception
+ */
+ private function buildLocalizationQuery(Signalement $signalement, bool $affected): array
{
$operator = $affected ? 'IN' : 'NOT IN';
$subquery = $this->getEntityManager()->getRepository(Affectation::class)->createQueryBuilder('a')
- ->select('IDENTITY(a.partner)')
- ->where('a.signalement = :signalement')
- ->setParameter('signalement', $signalement);
+ ->select('IDENTITY(a.partner)')
+ ->where('a.signalement = :signalement')
+ ->setParameter('signalement', $signalement);
$affectedPartners = $subquery->getQuery()->getSingleColumnResult();
- $conn = $this->getEntityManager()->getConnection();
+
$params = [
'territory' => $signalement->getTerritory()->getId(),
'insee' => '%'.$signalement->getInseeOccupant().'%',
'lng' => $signalement->getGeoloc()['lng'] ?? 'notInZone',
'lat' => $signalement->getGeoloc()['lat'] ?? 'notInZone',
];
+
$clauseSubquery = '';
- if (\count($affectedPartners) || 'IN' == $operator) {
+ if (\count($affectedPartners) || 'IN' === $operator) {
if (0 === \count($affectedPartners)) {
$clauseSubquery = 'AND p.id '.$operator.' (null)';
} else {
@@ -237,9 +271,10 @@ public function findByLocalization(Signalement $signalement, bool $affected = tr
'.$clauseSubquery.'
ORDER BY p.nom ASC';
- $resultSet = $conn->executeQuery($sql, $params);
-
- return $resultSet->fetchAllAssociative();
+ return [
+ 'sql' => $sql,
+ 'params' => $params,
+ ];
}
public function findPartnersWithQualification(Qualification $qualification, ?Territory $territory)
diff --git a/src/Service/Signalement/AutoAssigner.php b/src/Service/Signalement/AutoAssigner.php
index c50cd5333..b49ac8743 100755
--- a/src/Service/Signalement/AutoAssigner.php
+++ b/src/Service/Signalement/AutoAssigner.php
@@ -13,6 +13,7 @@
use App\Manager\SuiviManager;
use App\Manager\UserManager;
use App\Messenger\InterconnectionBus;
+use App\Repository\PartnerRepository;
use App\Specification\Affectation\AllocataireSpecification;
use App\Specification\Affectation\CodeInseeSpecification;
use App\Specification\Affectation\ParcSpecification;
@@ -37,6 +38,7 @@ public function __construct(
private UserManager $userManager,
private ParameterBagInterface $parameterBag,
private InterconnectionBus $interconnectionBus,
+ private PartnerRepository $partnerRepository,
private LoggerInterface $logger,
) {
}
@@ -62,7 +64,7 @@ public function assign(Signalement $signalement): void
}
$adminEmail = $this->parameterBag->get('user_system_email');
$adminUser = $this->userManager->findOneBy(['email' => $adminEmail]);
- $partners = $signalement->getTerritory()->getPartners();
+ $partners = $this->partnerRepository->findPartnersByLocalization($signalement);
$assignablePartners = [];
/** @var AutoAffectationRule $rule */
diff --git a/src/Specification/Affectation/CodeInseeSpecification.php b/src/Specification/Affectation/CodeInseeSpecification.php
index 6c3fbe558..a7c6f2527 100644
--- a/src/Specification/Affectation/CodeInseeSpecification.php
+++ b/src/Specification/Affectation/CodeInseeSpecification.php
@@ -2,26 +2,16 @@
namespace App\Specification\Affectation;
-use App\Entity\Partner;
use App\Entity\Signalement;
-use App\Entity\Zone;
use App\Specification\Context\PartnerSignalementContext;
use App\Specification\Context\SpecificationContextInterface;
use App\Specification\SpecificationInterface;
-use Doctrine\Common\Collections\Collection;
-use Location\Coordinate;
-use Location\Polygon;
-use LongitudeOne\Geo\WKT\Parser;
class CodeInseeSpecification implements SpecificationInterface
{
- private const TYPE_POLYGON = 'POLYGON';
- private const TYPE_MULTIPOLYGON = 'MULTIPOLYGON';
- private const TYPE_GEOMETRYCOLLECTION = 'GEOMETRYCOLLECTION';
-
- public function __construct(private array|string $inseeToInclude, private ?array $inseeToExclude)
+ public function __construct(private string|array|null $inseeToInclude, private ?array $inseeToExclude)
{
- if ('all' !== $inseeToInclude && 'partner_list' !== $inseeToInclude) {
+ if (null !== $inseeToInclude) {
$this->inseeToInclude = explode(',', $inseeToInclude);
} else {
$this->inseeToInclude = $inseeToInclude;
@@ -45,129 +35,18 @@ public function isSatisfiedBy(SpecificationContextInterface $context): bool
/** @var Signalement $signalement */
$signalement = $context->getSignalement();
- /** @var Partner $partner */
- $partner = $context->getPartner();
-
if ($this->isExcludedSignalement($signalement)) {
return false;
}
return match ($this->inseeToInclude) {
- 'all' => true,
- 'partner_list' => $this->isPartnerListSatisfied($signalement, $partner),
+ null => true,
default => $this->isInseeIncluded($signalement->getInseeOccupant()),
};
}
- private function isPartnerListSatisfied(Signalement $signalement, Partner $partner): bool
- {
- $isZoneExcludedOK = true;
- $isInseeOK = $this->isInseeIncludeInPartnerList($partner, $signalement->getInseeOccupant());
- $isZoneOK = $this->isInZone($signalement, $partner->getZones());
- if ($partner->getExcludedZones()->count() > 0) {
- $isZoneExcludedOK = !$this->isInZone($signalement, $partner->getExcludedZones());
- }
-
- return ($isInseeOK || $isZoneOK) && $isZoneExcludedOK;
- }
-
- private function isInZone(Signalement $signalement, Collection $zones): bool
- {
- if (0 === $zones->count()) {
- return false;
- }
-
- foreach ($zones as $zone) {
- if ($this->isSignalementInZone($signalement, $zone)) {
- return true;
- }
- }
-
- return false;
- }
-
- private function isInseeIncludeInPartnerList(Partner $partner, string $insee)
- {
- if (0 === \count($partner->getInsee())) {
- return false;
- }
-
- return \in_array($insee, $partner->getInsee());
- }
-
private function isInseeIncluded(string $insee): bool
{
return !empty($this->inseeToInclude) && \in_array($insee, $this->inseeToInclude);
}
-
- private function isSignalementInZone(Signalement $signalement, Zone $zone): bool
- {
- if (empty($signalement->getGeoloc())) {
- return false;
- }
-
- $parser = new Parser($zone->getArea());
- $zoneArea = $parser->parse();
- $signalementCoordinate = new Coordinate($signalement->getGeoloc()['lat'], $signalement->getGeoloc()['lng']);
-
- return match ($zoneArea['type']) {
- self::TYPE_POLYGON => $this->isPointInPolygon($signalementCoordinate, $zoneArea['value']),
- self::TYPE_MULTIPOLYGON => $this->isPointInMultiPolygon($signalementCoordinate, $zoneArea['value']),
- self::TYPE_GEOMETRYCOLLECTION => $this->isPointInGeometryCollection($signalementCoordinate, $zoneArea['value']),
- default => false,
- };
- }
-
- private function isPointInPolygon(Coordinate $point, array $polygonData): bool
- {
- // special case : POLYGON ((X1 Y1, X2 Y2)))
- if (1 === \count($polygonData)) {
- $polygonData = $polygonData[0];
- }
- $polygon = $this->buildPolygon($polygonData);
-
- return $polygon->contains($point);
- }
-
- private function isPointInMultiPolygon(Coordinate $point, array $multiPolygonData): bool
- {
- // special case : MULTIPOLYGON (((X1 Y1, X2 Y2),(X3 Y3, X4 Y4)))
- if (1 === \count($multiPolygonData)) {
- $multiPolygonData = $multiPolygonData[0];
- }
- foreach ($multiPolygonData as $polygonData) {
- if ($this->isPointInPolygon($point, $polygonData)) {
- return true;
- }
- }
-
- return false;
- }
-
- private function isPointInGeometryCollection(Coordinate $point, array $geometryCollection): bool
- {
- foreach ($geometryCollection as $geometry) {
- if (self::TYPE_POLYGON === $geometry['type'] && $this->isPointInPolygon($point, $geometry['value'])) {
- return true;
- }
- if (self::TYPE_MULTIPOLYGON === $geometry['type'] && $this->isPointInMultiPolygon($point, $geometry['value'])) {
- return true;
- }
- }
-
- return false;
- }
-
- private function buildPolygon(array $points): Polygon
- {
- $geofence = new Polygon();
- if (1 === \count($points) && \count($points[0]) > 2) {
- $points = $points[0];
- }
- foreach ($points as $point) {
- $geofence->addPoint(new Coordinate($point[1], $point[0]));
- }
-
- return $geofence;
- }
}
diff --git a/src/Validator/InseeToInclude.php b/src/Validator/InseeToInclude.php
index 2c165a041..8640cca30 100644
--- a/src/Validator/InseeToInclude.php
+++ b/src/Validator/InseeToInclude.php
@@ -10,7 +10,7 @@
#[\Attribute(\Attribute::TARGET_PROPERTY)]
class InseeToInclude extends Constraint
{
- public $message = 'La valeur "{{ value }}" n\'est pas valide. Elle doit être soit "all", "partner_list", soit une liste de codes INSEE séparés par des virgules.';
+ public $message = 'La valeur "{{ value }}" n\'est pas valide. Elle doit être soit vide soit une liste de codes INSEE séparés par des virgules.';
public function getTargets(): string
{
diff --git a/src/Validator/InseeToIncludeValidator.php b/src/Validator/InseeToIncludeValidator.php
index eb10eda47..c279c75a6 100644
--- a/src/Validator/InseeToIncludeValidator.php
+++ b/src/Validator/InseeToIncludeValidator.php
@@ -18,10 +18,6 @@ public function validate($value, Constraint $constraint): void
return;
}
- if (\in_array($value, ['all', 'partner_list'], true)) {
- return;
- }
-
$inseeCodes = explode(',', $value);
foreach ($inseeCodes as $code) {
if (!preg_match('/^\d{5}$/', trim($code))) {
diff --git a/templates/back/auto-affectation-rule/index.html.twig b/templates/back/auto-affectation-rule/index.html.twig
index ebb105c1d..b5e4d26ca 100755
--- a/templates/back/auto-affectation-rule/index.html.twig
+++ b/templates/back/auto-affectation-rule/index.html.twig
@@ -76,12 +76,12 @@
{{ autoaffectationrule.parc }} |
{{ autoaffectationrule.allocataire }} |
- {% if autoaffectationrule.inseeToInclude is same as('all') or autoaffectationrule.inseeToInclude is same as('partner_list') %}
- {{ autoaffectationrule.inseeToInclude }}
- {% else %}
+ {% if autoaffectationrule.inseeToInclude %}
{% for insee in autoaffectationrule.inseeToInclude|split(',') %}
{{ insee }}
{% endfor %}
+ {% else %}
+ /
{% endif %}
|
diff --git a/tests/FixturesHelper.php b/tests/FixturesHelper.php
index 00b1e19a6..7fcde7205 100644
--- a/tests/FixturesHelper.php
+++ b/tests/FixturesHelper.php
@@ -512,7 +512,7 @@ public function getAutoAffectationRule(
->setProfileDeclarant('all')
->setParc('prive')
->setAllocataire('oui')
- ->setInseeToInclude('partner_list')
+ ->setInseeToInclude(null)
->setInseeToExclude(null)
->setPartnerToExclude([])
->setStatus(AutoAffectationRule::STATUS_ACTIVE);
diff --git a/tests/Functional/Controller/AutoAffectationRuleControllerTest.php b/tests/Functional/Controller/AutoAffectationRuleControllerTest.php
index 7b60e0e84..346329d1c 100644
--- a/tests/Functional/Controller/AutoAffectationRuleControllerTest.php
+++ b/tests/Functional/Controller/AutoAffectationRuleControllerTest.php
@@ -52,7 +52,7 @@ public function testAutoAffectationRuleFormSubmit(): void
'auto_affectation_rule[profileDeclarant]' => 'occupant',
'auto_affectation_rule[parc]' => 'all',
'auto_affectation_rule[allocataire]' => 'oui',
- 'auto_affectation_rule[inseeToInclude]' => 'all',
+ 'auto_affectation_rule[inseeToInclude]' => null,
'auto_affectation_rule[inseeToExclude]' => '',
'auto_affectation_rule[partnerToExclude]' => '',
]
@@ -77,7 +77,7 @@ public function testAutoAffectationRuleEditFormSubmit(): void
'auto_affectation_rule[profileDeclarant]' => 'occupant',
'auto_affectation_rule[parc]' => 'all',
'auto_affectation_rule[allocataire]' => 'oui',
- 'auto_affectation_rule[inseeToInclude]' => 'all',
+ 'auto_affectation_rule[inseeToInclude]' => null,
'auto_affectation_rule[inseeToExclude]' => '',
'auto_affectation_rule[partnerToExclude]' => '',
]
diff --git a/tests/Functional/Specification/Affectation/CodeInseeSpecificationTest.php b/tests/Functional/Specification/Affectation/CodeInseeSpecificationTest.php
index 063217043..59499920b 100644
--- a/tests/Functional/Specification/Affectation/CodeInseeSpecificationTest.php
+++ b/tests/Functional/Specification/Affectation/CodeInseeSpecificationTest.php
@@ -4,179 +4,22 @@
use App\Entity\Partner;
use App\Entity\Signalement;
-use App\Entity\Zone;
use App\Specification\Affectation\CodeInseeSpecification;
use App\Specification\Context\PartnerSignalementContext;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
class CodeInseeSpecificationTest extends KernelTestCase
{
- private string $zoneBourgStMars = 'GEOMETRYCOLLECTION(POLYGON ((-1.403246 47.368071, -1.405563 47.369234, -1.409512 47.368652, -1.41346 47.369699, -1.41758 47.368478, -1.417408 47.365571, -1.41758 47.362316, -1.415176 47.359932, -1.410713 47.359583, -1.40625 47.358479, -1.401443 47.358188, -1.400757 47.362374, -1.40316 47.365339, -1.403246 47.368071)), POLYGON ((-1.423073 47.368304, -1.419983 47.369641, -1.420326 47.372024, -1.424017 47.372489, -1.426506 47.371036, -1.42642 47.369583, -1.423073 47.368304)))';
- private string $zoneLaBodiniere = 'POLYGON ((-1.444273 47.350861, -1.448994 47.352024, -1.450453 47.350745, -1.44865 47.349059, -1.446505 47.348593, -1.444273 47.349, -1.444273 47.350861))';
-
- private array $geolocLaBodiniere = [
- 'lat' => 47.349698,
- 'lng' => -1.446676,
- ];
-
- private array $geolocLaTourmentinerie = [
- 'lat' => 47.363934,
- 'lng' => -1.41422,
- ];
-
- private array $geolocLaGree = [
- 'lat' => 47.37025,
- 'lng' => -1.455196,
- ];
-
private const string INSEE_STMARS = '44179';
private const string INSEE_CELLIER = '44028';
/**
- * @dataProvider provideRulesAndSignalementWithZone
+ * @dataProvider provideRulesAndSignalement
*/
- public function testIsSatisfiedByWithZone(
+ public function testIsSatisfiedBy(
?string $inseeSignalement,
array $inseePartenaire,
- ?array $inseeToExcludeRule,
- array $geolocSignalement,
- ?string $zoneToInclude,
- ?string $zoneToExclude,
- bool $isSatisfied,
- ): void {
- $partner = new Partner();
- $partner->setInsee($inseePartenaire);
- $this->assertEquals($inseePartenaire, $partner->getInsee());
- if (null !== $zoneToInclude) {
- /** @var Zone $zone */
- $zone = new Zone();
- $zone->setArea($zoneToInclude);
- $partner->addZone($zone);
- $this->assertEquals($zoneToInclude, $partner->getZones()[0]->getArea());
- }
- if (null !== $zoneToExclude) {
- /** @var Zone $zone */
- $zone = new Zone();
- $zone->setArea($zoneToExclude);
- $partner->addExcludedZone($zone);
- $this->assertEquals($zoneToExclude, $partner->getExcludedZones()[0]->getArea());
- }
-
- $signalement = new Signalement();
- $signalement->setInseeOccupant($inseeSignalement);
- $signalement->setGeoloc($geolocSignalement);
- $this->assertEquals($inseeSignalement, $signalement->getInseeOccupant());
-
- $specification = new CodeInseeSpecification('partner_list', $inseeToExcludeRule);
- $context = new PartnerSignalementContext($partner, $signalement);
- if ($isSatisfied) {
- $this->assertTrue($specification->isSatisfiedBy($context));
- } else {
- $this->assertFalse($specification->isSatisfiedBy($context));
- }
- }
-
- public function provideRulesAndSignalementWithZone(): \Generator
- {
- yield 'same insee as partner - no excluded insee - same zone as geoloc, no zone excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], null, $this->geolocLaBodiniere, $this->zoneLaBodiniere, null, true];
- yield 'same insee as partner - no excluded insee - same zone as geoloc, same zone as excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], null, $this->geolocLaBodiniere, $this->zoneLaBodiniere, $this->zoneLaBodiniere, false]; // illogique, mais à tester, doit renvoyer false
- yield 'same insee as partner - no excluded insee - same zone as geoloc, different zone as excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], null, $this->geolocLaBodiniere, $this->zoneLaBodiniere, $this->zoneBourgStMars, true];
- yield 'same insee as partner - no excluded insee - no zone - no zone excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], null, $this->geolocLaBodiniere, null, null, true];
- yield 'same insee as partner - no excluded insee - no zone - same zone as excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], null, $this->geolocLaBodiniere, null, $this->zoneLaBodiniere, false];
- yield 'same insee as partner - no excluded insee - no zone - different zone as excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], null, $this->geolocLaBodiniere, null, $this->zoneBourgStMars, true];
- yield 'same insee as partner - no excluded insee - different zone as geoloc, no zone excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], null, $this->geolocLaBodiniere, $this->zoneBourgStMars, null, true];
- yield 'same insee as partner - no excluded insee - different zone as geoloc, same zone as excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], null, $this->geolocLaTourmentinerie, $this->zoneBourgStMars, $this->zoneBourgStMars, false];
- yield 'same insee as partner - no excluded insee - different zone as geoloc, different zone as excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], null, $this->geolocLaGree, $this->zoneBourgStMars, $this->zoneBourgStMars, true];
-
- // tout cela est illogique, et doit renvoyer false
- yield 'same insee as partner - but excluded - same zone as geoloc, no zone excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], [self::INSEE_STMARS], $this->geolocLaBodiniere, $this->zoneLaBodiniere, null, false];
- yield 'same insee as partner - but excluded - same zone as geoloc, same zone as excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], [self::INSEE_STMARS], $this->geolocLaBodiniere, $this->zoneLaBodiniere, $this->zoneLaBodiniere, false];
- yield 'same insee as partner - but excluded - same zone as geoloc, different zone as excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], [self::INSEE_STMARS], $this->geolocLaBodiniere, $this->zoneLaBodiniere, $this->zoneBourgStMars, false];
- yield 'same insee as partner - but excluded - no zone - no zone excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], [self::INSEE_STMARS], $this->geolocLaBodiniere, null, null, false];
- yield 'same insee as partner - but excluded - no zone - same zone as excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], [self::INSEE_STMARS], $this->geolocLaBodiniere, null, $this->zoneLaBodiniere, false];
- yield 'same insee as partner - but excluded - no zone - different zone as excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], [self::INSEE_STMARS], $this->geolocLaBodiniere, null, $this->zoneBourgStMars, false];
- yield 'same insee as partner - but excluded - different zone as geoloc, no zone excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], [self::INSEE_STMARS], $this->geolocLaBodiniere, $this->zoneBourgStMars, null, false];
- yield 'same insee as partner - but excluded - different zone as geoloc, same zone as excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], [self::INSEE_STMARS], $this->geolocLaTourmentinerie, $this->zoneBourgStMars, $this->zoneBourgStMars, false];
- yield 'same insee as partner - but excluded - different zone as geoloc, different zone as excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], [self::INSEE_STMARS], $this->geolocLaGree, $this->zoneBourgStMars, $this->zoneBourgStMars, false];
-
- yield 'same insee as partner - another insee excluded - same zone as geoloc, no zone excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], [self::INSEE_CELLIER], $this->geolocLaBodiniere, $this->zoneLaBodiniere, null, true];
- yield 'same insee as partner - another insee excluded - same zone as geoloc, same zone as excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], [self::INSEE_CELLIER], $this->geolocLaBodiniere, $this->zoneLaBodiniere, $this->zoneLaBodiniere, false]; // illogique, mais à tester, doit renvoyer false
- yield 'same insee as partner - another insee excluded - same zone as geoloc, different zone as excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], [self::INSEE_CELLIER], $this->geolocLaBodiniere, $this->zoneLaBodiniere, $this->zoneBourgStMars, true];
- yield 'same insee as partner - another insee excluded - no zone - no zone excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], [self::INSEE_CELLIER], $this->geolocLaBodiniere, null, null, true];
- yield 'same insee as partner - another insee excluded - no zone - same zone as excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], [self::INSEE_CELLIER], $this->geolocLaBodiniere, null, $this->zoneLaBodiniere, false];
- yield 'same insee as partner - another insee excluded - no zone - different zone as excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], [self::INSEE_CELLIER], $this->geolocLaBodiniere, null, $this->zoneBourgStMars, true];
- yield 'same insee as partner - another insee excluded - different zone as geoloc, no zone excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], [self::INSEE_CELLIER], $this->geolocLaBodiniere, $this->zoneBourgStMars, null, true];
- yield 'same insee as partner - another insee excluded - different zone as geoloc, same zone as excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], [self::INSEE_CELLIER], $this->geolocLaTourmentinerie, $this->zoneBourgStMars, $this->zoneBourgStMars, false];
- yield 'same insee as partner - another insee excluded - different zone as geoloc, different zone as excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], [self::INSEE_CELLIER], $this->geolocLaGree, $this->zoneBourgStMars, $this->zoneBourgStMars, true];
-
- yield 'different insee than partner - no excluded insee - same zone as geoloc, no zone excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], null, $this->geolocLaBodiniere, $this->zoneLaBodiniere, null, true];
- yield 'different insee than partner - no excluded insee - same zone as geoloc, same zone as excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], null, $this->geolocLaBodiniere, $this->zoneLaBodiniere, $this->zoneLaBodiniere, false]; // illogique, mais à tester, doit renvoyer false
- yield 'different insee than partner - no excluded insee - same zone as geoloc, different zone as excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], null, $this->geolocLaBodiniere, $this->zoneLaBodiniere, $this->zoneBourgStMars, true];
- yield 'different insee than partner - no excluded insee - no zone - no zone excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], null, $this->geolocLaBodiniere, null, null, false];
- yield 'different insee than partner - no excluded insee - no zone - same zone as excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], null, $this->geolocLaBodiniere, null, $this->zoneLaBodiniere, false];
- yield 'different insee than partner - no excluded insee - no zone - different zone as excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], null, $this->geolocLaBodiniere, null, $this->zoneBourgStMars, false];
- yield 'different insee than partner - no excluded insee - different zone as geoloc, no zone excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], null, $this->geolocLaBodiniere, $this->zoneBourgStMars, null, false];
- yield 'different insee than partner - no excluded insee - different zone as geoloc, same zone as excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], null, $this->geolocLaTourmentinerie, $this->zoneBourgStMars, $this->zoneBourgStMars, false];
- yield 'different insee than partner - no excluded insee - different zone as geoloc, different zone as excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], null, $this->geolocLaGree, $this->zoneBourgStMars, $this->zoneBourgStMars, false];
-
- yield 'different insee than partner - but excluded - same zone as geoloc, no zone excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], [self::INSEE_STMARS], $this->geolocLaBodiniere, $this->zoneLaBodiniere, null, false];
- yield 'different insee than partner - but excluded - same zone as geoloc, same zone as excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], [self::INSEE_STMARS], $this->geolocLaBodiniere, $this->zoneLaBodiniere, $this->zoneLaBodiniere, false]; // illogique, mais à tester, doit renvoyer false
- yield 'different insee than partner - but excluded - same zone as geoloc, different zone as excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], [self::INSEE_STMARS], $this->geolocLaBodiniere, $this->zoneLaBodiniere, $this->zoneBourgStMars, false];
- yield 'different insee than partner - but excluded - no zone - no zone excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], [self::INSEE_STMARS], $this->geolocLaBodiniere, null, null, false];
- yield 'different insee than partner - but excluded - no zone - same zone as excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], [self::INSEE_STMARS], $this->geolocLaBodiniere, null, $this->zoneLaBodiniere, false];
- yield 'different insee than partner - but excluded - no zone - different zone as excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], [self::INSEE_STMARS], $this->geolocLaBodiniere, null, $this->zoneBourgStMars, false];
- yield 'different insee than partner - but excluded - different zone as geoloc, no zone excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], [self::INSEE_STMARS], $this->geolocLaBodiniere, $this->zoneBourgStMars, null, false];
- yield 'different insee than partner - but excluded - different zone as geoloc, same zone as excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], [self::INSEE_STMARS], $this->geolocLaTourmentinerie, $this->zoneBourgStMars, $this->zoneBourgStMars, false];
- yield 'different insee than partner - but excluded - different zone as geoloc, different zone as excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], [self::INSEE_STMARS], $this->geolocLaGree, $this->zoneBourgStMars, $this->zoneBourgStMars, false];
-
- yield 'different insee than partner - another insee excluded - same zone as geoloc, no zone excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], [self::INSEE_CELLIER], $this->geolocLaBodiniere, $this->zoneLaBodiniere, null, true];
- yield 'different insee than partner - another insee excluded - same zone as geoloc, same zone as excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], [self::INSEE_CELLIER], $this->geolocLaBodiniere, $this->zoneLaBodiniere, $this->zoneLaBodiniere, false]; // illogique, mais à tester, doit renvoyer false
- yield 'different insee than partner - another insee excluded - same zone as geoloc, different zone as excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], [self::INSEE_CELLIER], $this->geolocLaBodiniere, $this->zoneLaBodiniere, $this->zoneBourgStMars, true];
- yield 'different insee than partner - another insee excluded - no zone - no zone excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], [self::INSEE_CELLIER], $this->geolocLaBodiniere, null, null, false];
- yield 'different insee than partner - another insee excluded - no zone - same zone as excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], [self::INSEE_CELLIER], $this->geolocLaBodiniere, null, $this->zoneLaBodiniere, false];
- yield 'different insee than partner - another insee excluded - no zone - different zone as excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], [self::INSEE_CELLIER], $this->geolocLaBodiniere, null, $this->zoneBourgStMars, false];
- yield 'different insee than partner - another insee excluded - different zone as geoloc, no zone excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], [self::INSEE_CELLIER], $this->geolocLaBodiniere, $this->zoneBourgStMars, null, false];
- yield 'different insee than partner - another insee excluded - different zone as geoloc, same zone as excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], [self::INSEE_CELLIER], $this->geolocLaTourmentinerie, $this->zoneBourgStMars, $this->zoneBourgStMars, false];
- yield 'different insee than partner - another insee excluded - different zone as geoloc, different zone as excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], [self::INSEE_CELLIER], $this->geolocLaGree, $this->zoneBourgStMars, $this->zoneBourgStMars, false];
-
- yield 'partner without insee - no excluded insee - same zone as geoloc, no zone excluded' => [self::INSEE_STMARS, [], null, $this->geolocLaBodiniere, $this->zoneLaBodiniere, null, true];
- yield 'partner without insee - no excluded insee - same zone as geoloc, same zone as excluded' => [self::INSEE_STMARS, [], null, $this->geolocLaBodiniere, $this->zoneLaBodiniere, $this->zoneLaBodiniere, false]; // illogique, mais à tester, doit renvoyer false
- yield 'partner without insee - no excluded insee - same zone as geoloc, different zone as excluded' => [self::INSEE_STMARS, [], null, $this->geolocLaBodiniere, $this->zoneLaBodiniere, $this->zoneBourgStMars, true];
- yield 'partner without insee - no excluded insee - no zone - no zone excluded' => [self::INSEE_STMARS, [], null, $this->geolocLaBodiniere, null, null, false];
- yield 'partner without insee - no excluded insee - no zone - same zone as excluded' => [self::INSEE_STMARS, [], null, $this->geolocLaBodiniere, null, $this->zoneLaBodiniere, false];
- yield 'partner without insee - no excluded insee - no zone - different zone as excluded' => [self::INSEE_STMARS, [], null, $this->geolocLaBodiniere, null, $this->zoneBourgStMars, false];
- yield 'partner without insee - no excluded insee - different zone as geoloc, no zone excluded' => [self::INSEE_STMARS, [], null, $this->geolocLaBodiniere, $this->zoneBourgStMars, null, false];
- yield 'partner without insee - no excluded insee - different zone as geoloc, same zone as excluded' => [self::INSEE_STMARS, [], null, $this->geolocLaTourmentinerie, $this->zoneBourgStMars, $this->zoneBourgStMars, false];
- yield 'partner without insee - no excluded insee - different zone as geoloc, different zone as excluded' => [self::INSEE_STMARS, [], null, $this->geolocLaGree, $this->zoneBourgStMars, $this->zoneBourgStMars, false];
-
- yield 'partner without insee - but excluded - same zone as geoloc, no zone excluded' => [self::INSEE_STMARS, [], [self::INSEE_STMARS], $this->geolocLaBodiniere, $this->zoneLaBodiniere, null, false];
- yield 'partner without insee - but excluded - same zone as geoloc, same zone as excluded' => [self::INSEE_STMARS, [], [self::INSEE_STMARS], $this->geolocLaBodiniere, $this->zoneLaBodiniere, $this->zoneLaBodiniere, false]; // illogique, mais à tester, doit renvoyer false
- yield 'partner without insee - but excluded - same zone as geoloc, different zone as excluded' => [self::INSEE_STMARS, [], [self::INSEE_STMARS], $this->geolocLaBodiniere, $this->zoneLaBodiniere, $this->zoneBourgStMars, false];
- yield 'partner without insee - but excluded - no zone - no zone excluded' => [self::INSEE_STMARS, [], [self::INSEE_STMARS], $this->geolocLaBodiniere, null, null, false];
- yield 'partner without insee - but excluded - no zone - same zone as excluded' => [self::INSEE_STMARS, [], [self::INSEE_STMARS], $this->geolocLaBodiniere, null, $this->zoneLaBodiniere, false];
- yield 'partner without insee - but excluded - no zone - different zone as excluded' => [self::INSEE_STMARS, [], [self::INSEE_STMARS], $this->geolocLaBodiniere, null, $this->zoneBourgStMars, false];
- yield 'partner without insee - but excluded - different zone as geoloc, no zone excluded' => [self::INSEE_STMARS, [], [self::INSEE_STMARS], $this->geolocLaBodiniere, $this->zoneBourgStMars, null, false];
- yield 'partner without insee - but excluded - different zone as geoloc, same zone as excluded' => [self::INSEE_STMARS, [], [self::INSEE_STMARS], $this->geolocLaTourmentinerie, $this->zoneBourgStMars, $this->zoneBourgStMars, false];
- yield 'partner without insee - but excluded - different zone as geoloc, different zone as excluded' => [self::INSEE_STMARS, [], [self::INSEE_STMARS], $this->geolocLaGree, $this->zoneBourgStMars, $this->zoneBourgStMars, false];
-
- yield 'partner without insee - another insee excluded - same zone as geoloc, no zone excluded' => [self::INSEE_STMARS, [], [self::INSEE_CELLIER], $this->geolocLaBodiniere, $this->zoneLaBodiniere, null, true];
- yield 'partner without insee - another insee excluded - same zone as geoloc, same zone as excluded' => [self::INSEE_STMARS, [], [self::INSEE_CELLIER], $this->geolocLaBodiniere, $this->zoneLaBodiniere, $this->zoneLaBodiniere, false]; // illogique, mais à tester, doit renvoyer false
- yield 'partner without insee - another insee excluded - same zone as geoloc, different zone as excluded' => [self::INSEE_STMARS, [], [self::INSEE_CELLIER], $this->geolocLaBodiniere, $this->zoneLaBodiniere, $this->zoneBourgStMars, true];
- yield 'partner without insee - another insee excluded - no zone - no zone excluded' => [self::INSEE_STMARS, [], [self::INSEE_CELLIER], $this->geolocLaBodiniere, null, null, false];
- yield 'partner without insee - another insee excluded - no zone - same zone as excluded' => [self::INSEE_STMARS, [], [self::INSEE_CELLIER], $this->geolocLaBodiniere, null, $this->zoneLaBodiniere, false];
- yield 'partner without insee - another insee excluded - no zone - different zone as excluded' => [self::INSEE_STMARS, [], [self::INSEE_CELLIER], $this->geolocLaBodiniere, null, $this->zoneBourgStMars, false];
- yield 'partner without insee - another insee excluded - different zone as geoloc, no zone excluded' => [self::INSEE_STMARS, [], [self::INSEE_CELLIER], $this->geolocLaBodiniere, $this->zoneBourgStMars, null, false];
- yield 'partner without insee - another insee excluded - different zone as geoloc, same zone as excluded' => [self::INSEE_STMARS, [], [self::INSEE_CELLIER], $this->geolocLaTourmentinerie, $this->zoneBourgStMars, $this->zoneBourgStMars, false];
- yield 'partner without insee - another insee excluded - different zone as geoloc, different zone as excluded' => [self::INSEE_STMARS, [], [self::INSEE_CELLIER], $this->geolocLaGree, $this->zoneBourgStMars, $this->zoneBourgStMars, false];
- }
-
- /**
- * @dataProvider provideRulesAndSignalementWithoutZone
- */
- public function testIsSatisfiedByWithoutZone(
- ?string $inseeSignalement,
- array $inseePartenaire,
- string $inseeToIncludeRule,
+ ?string $inseeToIncludeRule,
?array $inseeToExcludeRule,
bool $isSatisfied,
): void {
@@ -197,27 +40,17 @@ public function testIsSatisfiedByWithoutZone(
}
}
- public function provideRulesAndSignalementWithoutZone(): \Generator
+ public function provideRulesAndSignalement(): \Generator
{
- yield 'all - same insee as partner - no exclude' => [self::INSEE_STMARS, [self::INSEE_STMARS], 'all', null, true];
- yield 'all - same insee as partner - but excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], 'all', [self::INSEE_STMARS], false];
- yield 'all - same insee as partner - another excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], 'all', [self::INSEE_CELLIER], true];
- yield 'all - different insee than partner - no exclude' => [self::INSEE_STMARS, [self::INSEE_CELLIER], 'all', null, true];
- yield 'all - different insee than partner - but excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], 'all', [self::INSEE_STMARS], false];
- yield 'all - different insee than partner - another excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], 'all', [self::INSEE_CELLIER], true];
- yield 'all - partner without insee - no exclude' => [self::INSEE_STMARS, [], 'all', null, true];
- yield 'all - partner without insee - but excluded' => [self::INSEE_STMARS, [], 'all', [self::INSEE_STMARS], false];
- yield 'all - partner without insee - another excluded' => [self::INSEE_STMARS, [], 'all', [self::INSEE_CELLIER], true];
-
- yield 'partner_list - same insee as partner - no exclusion' => [self::INSEE_STMARS, [self::INSEE_STMARS], 'partner_list', null, true];
- yield 'partner_list - same insee as partner - but excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], 'partner_list', [self::INSEE_STMARS], false];
- yield 'partner_list - same insee as partner - another excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], 'partner_list', [self::INSEE_CELLIER], true];
- yield 'partner_list - different insee than partner - no exclusion' => [self::INSEE_STMARS, [self::INSEE_CELLIER], 'partner_list', null, false];
- yield 'partner_list - different insee than partner - but excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], 'partner_list', [self::INSEE_STMARS], false];
- yield 'partner_list - different insee than partner - another excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], 'partner_list', [self::INSEE_CELLIER], false];
- yield 'partner_list - partner without insee - no exclusion' => [self::INSEE_STMARS, [], 'partner_list', null, false];
- yield 'partner_list - partner without insee - but excluded' => [self::INSEE_STMARS, [], 'partner_list', [self::INSEE_STMARS], false];
- yield 'partner_list - partner without insee - another excluded' => [self::INSEE_STMARS, [], 'partner_list', [self::INSEE_CELLIER], false];
+ yield 'null - same insee as partner - no exclude' => [self::INSEE_STMARS, [self::INSEE_STMARS], null, null, true];
+ yield 'null - same insee as partner - but excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], null, [self::INSEE_STMARS], false];
+ yield 'null - same insee as partner - another excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], null, [self::INSEE_CELLIER], true];
+ yield 'null - different insee than partner - no exclude' => [self::INSEE_STMARS, [self::INSEE_CELLIER], null, null, true];
+ yield 'null - different insee than partner - but excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], null, [self::INSEE_STMARS], false];
+ yield 'null - different insee than partner - another excluded' => [self::INSEE_STMARS, [self::INSEE_CELLIER], null, [self::INSEE_CELLIER], true];
+ yield 'null - partner without insee - no exclude' => [self::INSEE_STMARS, [], null, null, true];
+ yield 'null - partner without insee - but excluded' => [self::INSEE_STMARS, [], null, [self::INSEE_STMARS], false];
+ yield 'null - partner without insee - another excluded' => [self::INSEE_STMARS, [], null, [self::INSEE_CELLIER], true];
yield 'array of insee with this one - same insee as partner - no exclusion' => [self::INSEE_STMARS, [self::INSEE_STMARS], self::INSEE_STMARS, null, true];
yield 'array of insee with this one - same insee as partner - but excluded' => [self::INSEE_STMARS, [self::INSEE_STMARS], self::INSEE_STMARS, [self::INSEE_STMARS], false];
@@ -240,8 +73,7 @@ public function provideRulesAndSignalementWithoutZone(): \Generator
yield 'array of insee without this one - partner without insee - another excluded' => [self::INSEE_STMARS, [], self::INSEE_CELLIER, [self::INSEE_CELLIER], false];
// tous les cas ne sont pas testés en cas d'absence d'insee sur le signalement, car ça renvoie toujours false
- yield 'all - no insee signalement' => [null, [self::INSEE_CELLIER], 'all', [self::INSEE_CELLIER], false];
- yield 'partner_list - no insee signalement - another excluded' => [null, [], 'partner_list', [self::INSEE_CELLIER], false];
+ yield 'null - no insee signalement' => [null, [self::INSEE_CELLIER], null, [self::INSEE_CELLIER], false];
yield 'array of insee - no insee signalement - another excluded' => [null, [], self::INSEE_STMARS, [self::INSEE_CELLIER], false];
}
}
diff --git a/tests/Unit/Entity/AutoAffectationRuleTest.php b/tests/Unit/Entity/AutoAffectationRuleTest.php
index b89e7f2b2..229cf4d39 100644
--- a/tests/Unit/Entity/AutoAffectationRuleTest.php
+++ b/tests/Unit/Entity/AutoAffectationRuleTest.php
@@ -27,7 +27,7 @@ public function testDescriptionLong(): void
$this->assertEquals('prive', $autoAffectationRule->getParc());
$this->assertEquals('all', $autoAffectationRule->getProfileDeclarant());
$this->assertEquals('oui', $autoAffectationRule->getAllocataire());
- $this->assertEquals('partner_list', $autoAffectationRule->getInseeToInclude());
+ $this->assertNull($autoAffectationRule->getInseeToInclude());
$this->assertNull($autoAffectationRule->getInseeToExclude());
$this->assertEmpty($autoAffectationRule->getPartnerToExclude());
$this->assertEquals(AutoAffectationRule::STATUS_ACTIVE, $autoAffectationRule->getStatus());
diff --git a/tests/Unit/Service/AutoAssignerTest.php b/tests/Unit/Service/AutoAssignerTest.php
index d0f559982..77367f3c5 100644
--- a/tests/Unit/Service/AutoAssignerTest.php
+++ b/tests/Unit/Service/AutoAssignerTest.php
@@ -4,6 +4,7 @@
use App\Entity\Enum\ProfileDeclarant;
use App\Entity\Enum\Qualification;
+use App\Entity\Partner;
use App\Entity\Signalement;
use App\Entity\SignalementQualification;
use App\Manager\AffectationManager;
@@ -11,6 +12,7 @@
use App\Manager\SuiviManager;
use App\Manager\UserManager;
use App\Messenger\InterconnectionBus;
+use App\Repository\PartnerRepository;
use App\Repository\SignalementRepository;
use App\Service\Signalement\AutoAssigner;
use Doctrine\ORM\EntityManagerInterface;
@@ -24,6 +26,7 @@ class AutoAssignerTest extends KernelTestCase
private EntityManagerInterface $entityManager;
private AffectationManager $affectationManager;
private SignalementRepository $signalementRepository;
+ private PartnerRepository $partnerRepository;
private SuiviManager|MockObject $suiviManager;
protected function setUp(): void
@@ -32,6 +35,7 @@ protected function setUp(): void
$this->entityManager = $kernel->getContainer()->get('doctrine')->getManager();
$this->affectationManager = self::getContainer()->get(AffectationManager::class);
$this->signalementRepository = $this->entityManager->getRepository(Signalement::class);
+ $this->partnerRepository = $this->entityManager->getRepository(Partner::class);
$this->suiviManager = $this->createMock(SuiviManager::class);
}
@@ -192,16 +196,16 @@ public function testAutoAssignmentZoneIncluded(): void
public function testAutoAssignmentWithoutZoneWithoutInsee(): void
{
- // signalement 2025-01 au Cellier, 1 partenaire pour le bailleur social, pas de partenaire sur le code insee ou la zone
+ // signalement 2025-01 au Cellier, pas de partenaire sur le code insee ou la zone
/** @var Signalement $signalement */
$signalement = $this->signalementRepository->findOneBy(['reference' => '2025-01']);
$signalement->setStatut(Signalement::STATUS_NEED_VALIDATION);
- $this->suiviManager->expects($this->once())
+ $this->suiviManager->expects($this->never())
->method('createSuivi');
- $this->suiviManager->expects($this->once())
+ $this->suiviManager->expects($this->never())
->method('persist');
- $this->testHelper($signalement, 1, ['Partner Habitat 44']);
- $this->assertEquals(Signalement::STATUS_ACTIVE, $signalement->getStatut());
+ $this->testHelper($signalement, 0, null);
+ $this->assertEquals(Signalement::STATUS_NEED_VALIDATION, $signalement->getStatut());
}
public function testAutoAssignmentProcedure(): void
@@ -239,6 +243,10 @@ public function testAutoAssignmentBailleurSocial(): void
private function testHelper(Signalement $signalement, int $expectedCount, ?array $expectedPartnerNames = null)
{
+ foreach ($signalement->getAffectations() as $affectation) {
+ $signalement->removeAffectation($affectation);
+ }
+
/** @var SignalementManager|MockObject $signalementManager */
$signalementManager = $this->createMock(SignalementManager::class);
/** @var UserManager|MockObject $userManager */
@@ -256,6 +264,7 @@ private function testHelper(Signalement $signalement, int $expectedCount, ?array
$userManager,
$parameterBag,
$esaboraBus,
+ $this->partnerRepository,
$logger,
);
diff --git a/tests/Unit/Validator/InseeToIncludeValidatorTest.php b/tests/Unit/Validator/InseeToIncludeValidatorTest.php
index 7ed3d5b4a..c328d298c 100644
--- a/tests/Unit/Validator/InseeToIncludeValidatorTest.php
+++ b/tests/Unit/Validator/InseeToIncludeValidatorTest.php
@@ -9,7 +9,7 @@
class InseeToIncludeValidatorTest extends ConstraintValidatorTestCase
{
- private const ERROR = 'La valeur "{{ value }}" n\'est pas valide. Elle doit être soit "all", "partner_list", soit une liste de codes INSEE séparés par des virgules.';
+ private const ERROR = 'La valeur "{{ value }}" n\'est pas valide. Elle doit être soit vide soit une liste de codes INSEE séparés par des virgules.';
protected function createValidator(): ConstraintValidatorInterface
{
@@ -19,7 +19,7 @@ protected function createValidator(): ConstraintValidatorInterface
/**
* @dataProvider provideValues
*/
- public function testValues(string $insee, bool $isValid, ?string $message = null): void
+ public function testValues(?string $insee, bool $isValid, ?string $message = null): void
{
$constraint = new InseeToInclude();
$this->validator->validate($insee, $constraint);
@@ -34,8 +34,9 @@ public function testValues(string $insee, bool $isValid, ?string $message = null
public function provideValues(): \Generator
{
- yield 'all' => ['all', true];
- yield 'partner_list' => ['partner_list', true];
+ yield 'null' => [null, true];
+ yield 'all' => ['all', false, self::ERROR];
+ yield 'partner_list' => ['partner_list', false, self::ERROR];
yield '44058' => ['44058', true];
yield '44058,44890' => ['44058,44890', true];
yield 'error' => ['error', false, self::ERROR];
|