-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into develop #3147
- Loading branch information
Showing
5 changed files
with
67 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ protected function setUp(): void | |
public function testLoadValidPartnersAndUserInCreateMode(): void | ||
{ | ||
$territory = $this->entityManager->getRepository(Territory::class)->findOneBy(['isActive' => 0]); | ||
$errors = $this->gridAffectationLoader->validate($this->provideValidData()); | ||
$errors = $this->gridAffectationLoader->validate($this->provideValidData(), $territory); | ||
$this->assertCount(0, $errors); | ||
|
||
$this->gridAffectationLoader->load($territory, $this->provideValidData(), []); | ||
|
@@ -104,7 +104,7 @@ public function testLoadValidPartnerAndUserInUpdateMode(): void | |
'Rôle' => self::FIXTURE_ROLE_USER, | ||
]; | ||
|
||
$errors = $this->gridAffectationLoader->validate($data, true); | ||
$errors = $this->gridAffectationLoader->validate($data, $territory, true); | ||
$this->assertCount(0, $errors); | ||
$this->gridAffectationLoader->load($territory, $data, []); | ||
$metaData = $this->gridAffectationLoader->getMetadata(); | ||
|
@@ -120,13 +120,15 @@ public function testLoadValidPartnerAndUserInUpdateMode(): void | |
|
||
public function testValidateWithErrors(): void | ||
{ | ||
$territory = $this->entityManager->getRepository(Territory::class)->findOneBy(['zip' => 13]); | ||
|
||
$errors = [ | ||
'line 3 : E-mail incorrect pour un partenaire : arshistologe.fr', | ||
'line 5 : Type incorrect pour Random Type --> Random Type', | ||
'line 5 : Rôle incorrect pour [email protected] --> Fake role', | ||
'line 6 : Type incorrect pour Random Type --> Random Type', | ||
'line 6 : E-mail incorrect pour un utilisateur : john.doe@', | ||
'line 7 : Partenaire déjà existant avec ([email protected]) dans Bouches-du-Rhône, nom : Partenaire 13-01', | ||
'line 7 : E-mail partenaire déjà existant dans le territoire avec ([email protected]) dans Bouches-du-Rhône, nom : Partenaire 13-01', | ||
'line 8 : E-mail manquant pour Margaretta Borer, partenaire ADIL', | ||
'line 9 : Nom de partenaire manquant', | ||
'line 10 : Utilisateur déjà existant avec ([email protected]) dans Bouches-du-Rhône, partenaire : Partenaire 13-06 ESABORA ARS, rôle : Agent', | ||
|
@@ -137,7 +139,7 @@ public function testValidateWithErrors(): void | |
|
||
$this->assertEquals( | ||
$errors, | ||
$this->gridAffectationLoader->validate($this->provideInvalidDataWithDuplicatePartnersAndUsers()) | ||
$this->gridAffectationLoader->validate($this->provideInvalidDataWithDuplicatePartnersAndUsers(), $territory) | ||
); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,4 +72,30 @@ public function testPartnerSCHSCompetenceRSDWithSpecificInseeCanSyncWithOilhi(): | |
|
||
$this->assertTrue($partner->canSyncWithOilhi($signalement)); | ||
} | ||
|
||
/** | ||
* @dataProvider provideDataForTestPartnerWithEmail | ||
*/ | ||
public function testCreatePartnerNoValidWithEmailExistInTerritory(int $zip, int $countErrors): void | ||
{ | ||
$entityManager = self::getContainer()->get('doctrine')->getManager(); | ||
$territory = $entityManager->getRepository(Territory::class)->find($zip); | ||
$partner = (new Partner()) | ||
->setNom('Random partner') | ||
->setEmail('[email protected]') | ||
->setType(PartnerType::COMMUNE_SCHS) | ||
->setCompetence([Qualification::VISITES]) | ||
->setTerritory($territory); | ||
|
||
$validator = self::getContainer()->get('validator'); | ||
$errors = $validator->validate($partner); | ||
$this->assertEquals($countErrors, $errors->count()); | ||
} | ||
|
||
public function provideDataForTestPartnerWithEmail(): \Generator | ||
{ | ||
yield 'Create partner not valid with email exists in territory' => [13, 1]; | ||
|
||
yield 'Create partner valid with email exists in territory' => [1, 0]; | ||
} | ||
} |