Vincent 1 年之前
父节点
当前提交
662d9122ba
共有 37 个文件被更改,包括 340 次插入308 次删除
  1. 6 11
      src/ApiResources/Core/File/Upload.php
  2. 0 1
      src/ApiResources/Profile/OrganizationProfile.php
  3. 5 13
      src/Entity/Core/File.php
  4. 14 14
      src/Enum/Access/FunctionEnum.php
  5. 4 3
      src/Service/Access/Utils.php
  6. 5 4
      src/Service/Dolibarr/DolibarrSyncService.php
  7. 2 1
      src/Service/Export/BaseExporter.php
  8. 1 1
      src/Service/Export/LicenceCmfExporter.php
  9. 4 8
      src/Service/Export/Model/LicenceCmf.php
  10. 5 4
      src/Service/File/FileManager.php
  11. 5 4
      src/Service/File/Storage/LocalStorage.php
  12. 1 1
      src/Service/Security/Module.php
  13. 11 11
      tests/Unit/Security/Voter/EntityVoter/Core/FileVoterTest.php
  14. 3 2
      tests/Unit/Service/Access/AccessProfileCreatorTest.php
  15. 3 3
      tests/Unit/Service/Access/OptionalsRoles/CriteriaNotationOptionalRoleTest.php
  16. 13 12
      tests/Unit/Service/Access/UtilsTest.php
  17. 3 3
      tests/Unit/Service/Core/ContactPointUtilsTest.php
  18. 3 2
      tests/Unit/Service/Cotisation/CotisationCreatorTest.php
  19. 5 5
      tests/Unit/Service/Cotisation/UtilsTest.php
  20. 90 73
      tests/Unit/Service/Dolibarr/DolibarrSyncServiceTest.php
  21. 2 2
      tests/Unit/Service/Education/EducationNotationUtilsTest.php
  22. 10 4
      tests/Unit/Service/Export/BaseExporterTest.php
  23. 8 4
      tests/Unit/Service/Export/LicenceCmfExporterTest.php
  24. 3 2
      tests/Unit/Service/Export/Model/LicenceCmfTest.php
  25. 5 4
      tests/Unit/Service/File/FileManagerTest.php
  26. 27 25
      tests/Unit/Service/File/Storage/LocalStorageTest.php
  27. 7 7
      tests/Unit/Service/Mailer/Builder/AbstractBuilderTest.php
  28. 11 11
      tests/Unit/Service/Mailer/MailerTest.php
  29. 4 3
      tests/Unit/Service/Network/TreeTest.php
  30. 12 12
      tests/Unit/Service/Network/UtilsTest.php
  31. 9 9
      tests/Unit/Service/NotifierTest.php
  32. 6 6
      tests/Unit/Service/OnChange/Organization/OnOrganizationChangeTest.php
  33. 6 6
      tests/Unit/Service/OnChange/Organization/OnParametersChangeTest.php
  34. 17 8
      tests/Unit/Service/Organization/OrganizationProfileCreatorTest.php
  35. 23 23
      tests/Unit/Service/Organization/UtilsTest.php
  36. 5 4
      tests/Unit/Service/Security/ModuleTest.php
  37. 2 2
      tests/Unit/Service/Utils/EnvironnementTest.php

+ 6 - 11
src/ApiResources/Core/File/Upload.php

@@ -9,6 +9,7 @@ use ApiPlatform\Metadata\ApiResource;
 use ApiPlatform\Metadata\Post;
 use ApiPlatform\Metadata\Put;
 use App\Enum\Core\FileTypeEnum;
+use App\Enum\Core\FileVisibilityEnum;
 use App\State\Processor\Core\UploadRequestProcessor;
 use App\State\Provider\Core\DownloadRequestProvider;
 use Ramsey\Uuid\Uuid;
@@ -62,9 +63,9 @@ class Upload
 
     /**
      * Visibilité du fichier
-     * @var string
      */
-    private string $visibility = 'NOBODY';
+    #[Assert\Type(type: FileVisibilityEnum::class)]
+    private FileVisibilityEnum $visibility = FileVisibilityEnum::NOBODY;
 
     /**
      * Type mime (il sera déduit automatiquement du nom du fichier s'il n'est pas fourni ici)
@@ -160,19 +161,13 @@ class Upload
         return $this;
     }
 
-    /**
-     * @return string
-     */
-    public function getVisibility(): string
+    public function getVisibility(): FileVisibilityEnum
     {
         return $this->visibility;
     }
 
-    /**
-     * @param string $visibility
-     * @return self
-     */
-    public function setVisibility(string $visibility): self
+
+    public function setVisibility(FileVisibilityEnum $visibility): self
     {
         $this->visibility = $visibility;
         return $this;

+ 0 - 1
src/ApiResources/Profile/OrganizationProfile.php

@@ -7,7 +7,6 @@ use ApiPlatform\Metadata\ApiResource;
 use ApiPlatform\Metadata\ApiProperty;
 use ApiPlatform\Metadata\Get;
 use App\ApiResources\ApiResourcesInterface;
-use App\Entity\Organization\Organization;
 use App\Enum\Organization\LegalEnum;
 use App\Enum\Organization\SettingsProductEnum;
 use Symfony\Component\Serializer\Annotation\Groups;

+ 5 - 13
src/Entity/Core/File.php

@@ -19,6 +19,7 @@ use App\Entity\Organization\Organization;
 use App\Entity\Person\Person;
 use App\Enum\Core\FileHostEnum;
 use App\Enum\Core\FileTypeEnum;
+use App\Enum\Core\FileVisibilityEnum;
 use App\Repository\Core\FileRepository;
 use App\Entity\Organization\Parameters;
 use DateTime;
@@ -101,10 +102,9 @@ class File
 
     /**
      * Visibilité du fichier (tout le monde, personne, l'organisation seulement...)
-     * @var string
      */
-    #[ORM\Column(length: 24, options: ['default' => 'NOBODY'])]
-    private string $visibility = 'NOBODY';
+    #[ORM\Column(length: 24, enumType: FileVisibilityEnum::class,options: ['default' => FileVisibilityEnum::NOBODY])]
+    private FileVisibilityEnum $visibility = FileVisibilityEnum::NOBODY;
 
     /**
      * Configuration particulière associée au fichier (exemple: image recadrée)
@@ -387,20 +387,12 @@ class File
     public function getAccessRoles(): Collection {
         return new ArrayCollection([]);
     }
-
-    /**
-     * @return string
-     */
-    public function getVisibility(): string
+    public function getVisibility(): FileVisibilityEnum
     {
         return $this->visibility;
     }
 
-    /**
-     * @param string $visibility
-     * @return File
-     */
-    public function setVisibility(string $visibility): self
+    public function setVisibility(FileVisibilityEnum $visibility): self
     {
         $this->visibility = $visibility;
         return $this;

+ 14 - 14
src/Enum/Access/FunctionEnum.php

@@ -62,24 +62,24 @@ enum FunctionEnum: string
      *
      * Used by the DolibarrSyncService
      *
-     * @return list<FunctionEnum>
+     * @return list<string>
      */
     public static function getOfficeMissions(): array
     {
         return [
-            self::PRESIDENT,
-            self::PRESIDENT_ASSISTANT,
-            self::DIRECTOR,
-            self::DIRECTOR_ASSISTANT,
-            self::SECRETARY,
-            self::ASSISTANT_SECRETARY,
-            self::TREASURER,
-            self::TREASURER_ASSISTANT,
-            self::ADMINISTRATIVE_OFFICER,
-            self::ADMINISTRATIVE_SECRETARY,
-            self::ADMINISTRATIVE_DIRECTOR,
-            self::ADMINISTRATIVE_DIRECTOR_ASSISTANT,
-            self::ADMINISTRATIVE_STAFF
+            self::PRESIDENT->value,
+            self::PRESIDENT_ASSISTANT->value,
+            self::DIRECTOR->value,
+            self::DIRECTOR_ASSISTANT->value,
+            self::SECRETARY->value,
+            self::ASSISTANT_SECRETARY->value,
+            self::TREASURER->value,
+            self::TREASURER_ASSISTANT->value,
+            self::ADMINISTRATIVE_OFFICER->value,
+            self::ADMINISTRATIVE_SECRETARY->value,
+            self::ADMINISTRATIVE_DIRECTOR->value,
+            self::ADMINISTRATIVE_DIRECTOR_ASSISTANT->value,
+            self::ADMINISTRATIVE_STAFF->value
         ];
     }
 }

+ 4 - 3
src/Service/Access/Utils.php

@@ -5,6 +5,7 @@ namespace App\Service\Access;
 
 use App\Entity\Access\Access;
 use App\Entity\Organization\Organization;
+use App\Enum\Access\FunctionEnum;
 use App\Repository\Access\AccessRepository;
 use App\Service\ServiceIterator\OptionalsRolesIterator;
 use App\Service\Utils\DatesUtils;
@@ -117,11 +118,11 @@ class Utils
      * L'access possède-t-il la fonction donnée au sein de son organisation
      *
      * @param Access $access
-     * @param string $functionName
+     * @param FunctionEnum $functionName
      * @return bool
      * @throws \Exception
      */
-    public function hasActiveFunction(Access $access, string $functionName): bool {
-        return in_array($functionName, $this->getActiveFunctions($access));
+    public function hasActiveFunction(Access $access, FunctionEnum $functionName): bool {
+        return in_array($functionName->value, $this->getActiveFunctions($access));
     }
 }

+ 5 - 4
src/Service/Dolibarr/DolibarrSyncService.php

@@ -94,7 +94,7 @@ class DolibarrSyncService
         // Get all the missions with an admin default role
         $adminMissions = [];
         foreach ($this->functionTypeRepository->findBy(['roleByDefault' => RoleEnum::ROLE_ADMIN]) as $functionType) {
-            $adminMissions[] = $functionType->getMission();
+            $adminMissions[] = $functionType->getMission()->value;
         }
 
         // Store networks ids id dolibarr
@@ -162,11 +162,12 @@ class DolibarrSyncService
             $product = $organization->getSettings()->getProduct();
             if ($this->organizationUtils->isSchool($organization)) {
                 $infos[] = $this->translator->trans('STUDENTS_COUNT') . " : " .
-                    $this->countWithMission([FunctionEnum::STUDENT], $organizationMembers);
+                    $this->countWithMission([FunctionEnum::STUDENT->value], $organizationMembers);
             }
             if ($this->organizationUtils->isSchool($organization) || $this->organizationUtils->isArtist($organization)) {
+
                 $infos[] = $this->translator->trans('ADHERENTS_COUNT') . " : " .
-                    $this->countWithMission([FunctionEnum::ADHERENT], $organizationMembers);
+                    $this->countWithMission([FunctionEnum::ADHERENT->value], $organizationMembers);
             }
             $infos[] = $this->translator->trans('ADMIN_ACCESS_COUNT') . " : " .
                 $this->countWithMission($adminMissions, $organizationMembers);
@@ -237,7 +238,7 @@ class DolibarrSyncService
                     'email' => $contact?->getEmail(),
                     'phone_pro' => $contact?->getTelphone() ? $this->formatPhoneNumber($contact->getTelphone()) : null,
                     'phone_mobile' => $contact?->getMobilPhone() ? $this->formatPhoneNumber($contact->getMobilPhone()): null,
-                    'poste' => $this->formatContactPosition($missions, $person->getGender()->value),
+                    'poste' => $this->formatContactPosition($missions, $person->getGender()?->value),
                     'statut' => '1'
                 ];
 

+ 2 - 1
src/Service/Export/BaseExporter.php

@@ -6,6 +6,7 @@ namespace App\Service\Export;
 use App\ApiResources\Export\ExportRequest;
 use App\Entity\Core\File;
 use App\Enum\Core\FileTypeEnum;
+use App\Enum\Core\FileVisibilityEnum;
 use App\Repository\Access\AccessRepository;
 use App\Repository\Core\FileRepository;
 use App\Service\Export\Model\ExportModelInterface;
@@ -131,7 +132,7 @@ abstract class BaseExporter
             $this->getFileType(),
             $requester,
             true,
-            'NOBODY',
+            FileVisibilityEnum::NOBODY,
             $this->fileUtils->getMimeTypeFromExt($exportRequest->getFormat()->value),
             $flushFile
         );

+ 1 - 1
src/Service/Export/LicenceCmfExporter.php

@@ -71,7 +71,7 @@ class LicenceCmfExporter extends BaseExporter implements ExporterInterface
             $president = $presidents[0]->getPerson();
             if ($president !== null) {
                 $licenceCmf->setPersonId($president->getId());
-                $licenceCmf->setPersonGender($president->getGender() ?? '');
+                $licenceCmf->setPersonGender($president->getGender() ?? null);
                 $licenceCmf->setPersonFirstName($president->getGivenName());
                 $licenceCmf->setPersonLastName($president->getName());
             }

+ 4 - 8
src/Service/Export/Model/LicenceCmf.php

@@ -4,6 +4,7 @@ declare(strict_types=1);
 namespace App\Service\Export\Model;
 
 use App\Entity\Core\File;
+use App\Enum\Person\GenderEnum;
 
 /**
  * Modèle de données d'une licence CMF (d'organisation ou personnelle)
@@ -72,9 +73,8 @@ class LicenceCmf implements ExportModelInterface
 
     /**
      * Gender of the licence owner
-     * @var string
      */
-    private string $personGender = '';
+    private ?GenderEnum $personGender = null;
 
     /**
      * First name of the licence owner
@@ -285,19 +285,15 @@ class LicenceCmf implements ExportModelInterface
         return $this;
     }
 
-    /**
-     * @return string
-     */
-    public function getPersonGender(): string
+    public function getPersonGender(): GenderEnum
     {
         return $this->personGender;
     }
 
     /**
-     * @param string $personGender
      * @return LicenceCmf
      */
-    public function setPersonGender(string $personGender): LicenceCmf
+    public function setPersonGender(GenderEnum $personGender): LicenceCmf
     {
         $this->personGender = $personGender;
 

+ 5 - 4
src/Service/File/FileManager.php

@@ -9,6 +9,7 @@ use ApiPlatform\Metadata\Get;
 use App\Entity\Core\File;
 use App\Entity\Organization\Organization;
 use App\Entity\Person\Person;
+use App\Enum\Core\FileVisibilityEnum;
 use App\Service\File\Exception\FileNotFoundException;
 use App\Service\File\Factory\ImageFactory;
 use App\Service\File\Storage\FileStorageInterface;
@@ -78,7 +79,7 @@ class FileManager
      * @param Access $createdBy Id of the access responsible for this creation
      * @param bool $isTemporary Is it a temporary file that can be deleted after some time
      * @param string|null $mimeType Mimetype of the file, if not provided, the method will try to guess it from its file name's extension
-     * @param string $visibility
+     * @param FileVisibilityEnum $visibility
      * @param bool $flushFile Should the newly created file be flushed after having been persisted?
      * @return File
      */
@@ -88,7 +89,7 @@ class FileManager
         FileTypeEnum $type,
         Access $createdBy,
         bool $isTemporary = false,
-        string $visibility = 'NOBODY',
+        FileVisibilityEnum $visibility = FileVisibilityEnum::NOBODY,
         string $mimeType = null,
         bool $flushFile = true
     ): File
@@ -123,7 +124,7 @@ class FileManager
      * @param Access $author
      * @param bool $isTemporary
      * @param string|null $mimeType
-     * @param string $visibility
+     * @param FileVisibilityEnum $visibility
      * @param string|null $config
      * @return File
      */
@@ -134,7 +135,7 @@ class FileManager
         string                         $content,
         Access                         $author,
         bool                           $isTemporary = false,
-        string                         $visibility = 'NOBODY',
+        FileVisibilityEnum             $visibility = FileVisibilityEnum::NOBODY,
         string                         $mimeType = null,
         string                         $config = null
     ): File {

+ 5 - 4
src/Service/File/Storage/LocalStorage.php

@@ -11,6 +11,7 @@ use App\Enum\Core\FileHostEnum;
 use App\Enum\Core\FileSizeEnum;
 use App\Enum\Core\FileStatusEnum;
 use App\Enum\Core\FileTypeEnum;
+use App\Enum\Core\FileVisibilityEnum;
 use App\Repository\Access\AccessRepository;
 use App\Service\File\Factory\ImageFactory;
 use App\Service\Utils\FileUtils;
@@ -148,7 +149,7 @@ class LocalStorage implements FileStorageInterface
      * @param Access $createdBy Id of the access responsible for this creation
      * @param bool $isTemporary Is it a temporary file that can be deleted after some time
      * @param string|null $mimeType Mimetype of the file, if not provided, the method will try to guess it from its file name's extension
-     * @param string $visibility
+     * @param FileVisibilityEnum $visibility
      * @param bool $flushFile Should the newly created file be flushed after having been persisted?
      * @return File
      */
@@ -158,7 +159,7 @@ class LocalStorage implements FileStorageInterface
         FileTypeEnum $type,
         Access $createdBy,
         bool $isTemporary = false,
-        string $visibility = 'NOBODY',
+        FileVisibilityEnum $visibility = FileVisibilityEnum::NOBODY,
         string $mimeType = null,
         bool $flushFile = true
     ): File
@@ -257,7 +258,7 @@ class LocalStorage implements FileStorageInterface
      * @param Access $author
      * @param bool $isTemporary
      * @param string|null $mimeType
-     * @param string $visibility
+     * @param FileVisibilityEnum $visibility
      * @param string|null $config
      * @return File
      */
@@ -268,7 +269,7 @@ class LocalStorage implements FileStorageInterface
         string                         $content,
         Access                         $author,
         bool                           $isTemporary = false,
-        string                         $visibility = 'NOBODY',
+        FileVisibilityEnum             $visibility = FileVisibilityEnum::NOBODY,
         string                         $mimeType = null,
         string                         $config = null
     ): File

+ 1 - 1
src/Service/Security/Module.php

@@ -135,7 +135,7 @@ class Module
         $modules = $productConfig['modules'] ?? [];
 
         if (array_key_exists('extend', $productConfig)) {
-            $modules = array_merge($modules, $this->getModulesByProductConfiguration($productConfig['extend']));
+            $modules = array_merge($modules, $this->getModulesByProductConfiguration(SettingsProductEnum::from($productConfig['extend'])));
             unset($productConfig['extend']);
         }
 

+ 11 - 11
tests/Unit/Security/Voter/EntityVoter/Core/FileVoterTest.php

@@ -90,7 +90,7 @@ class FileVoterTest extends TestCase
 
         $fileVoter->method('isAvailable')->with($file, $user)->willReturn(true);
 
-        $file->method('getVisibility')->willReturn(FileVisibilityEnum::EVERYBODY()->getValue());
+        $file->method('getVisibility')->willReturn(FileVisibilityEnum::EVERYBODY);
 
         $this->assertTrue($fileVoter->canView($file));
     }
@@ -106,7 +106,7 @@ class FileVoterTest extends TestCase
         $fileVoter->method('isAvailable')->with($file, $user)->willReturn(true);
         $fileVoter->method('isValidInternalRequest')->willReturn(true);
 
-        $file->method('getVisibility')->willReturn(FileVisibilityEnum::NOBODY()->getValue());
+        $file->method('getVisibility')->willReturn(FileVisibilityEnum::NOBODY);
 
         $this->assertTrue($fileVoter->canView($file));
     }
@@ -123,7 +123,7 @@ class FileVoterTest extends TestCase
         $fileVoter->method('isValidInternalRequest')->willReturn(false);
         $fileVoter->method('isUserLoggedIn')->willReturn(false);
 
-        $file->method('getVisibility')->willReturn(FileVisibilityEnum::NOBODY()->getValue());
+        $file->method('getVisibility')->willReturn(FileVisibilityEnum::NOBODY);
 
         $this->assertFalse($fileVoter->canView($file));
     }
@@ -140,7 +140,7 @@ class FileVoterTest extends TestCase
         $fileVoter->method('isValidInternalRequest')->willReturn(false);
         $fileVoter->method('isUserLoggedIn')->willReturn(true);
 
-        $file->method('getVisibility')->willReturn(FileVisibilityEnum::NOBODY()->getValue());
+        $file->method('getVisibility')->willReturn(FileVisibilityEnum::NOBODY);
 
         $owner = $this->getMockBuilder(Person::class)->getMock();
         $userPerson = $this->getMockBuilder(Person::class)->getMock();
@@ -164,7 +164,7 @@ class FileVoterTest extends TestCase
         $fileVoter->method('isValidInternalRequest')->willReturn(false);
         $fileVoter->method('isUserLoggedIn')->willReturn(true);
 
-        $file->method('getVisibility')->willReturn(FileVisibilityEnum::NOBODY()->getValue());
+        $file->method('getVisibility')->willReturn(FileVisibilityEnum::NOBODY);
 
         $owner = $this->getMockBuilder(Person::class)->getMock();
 
@@ -188,7 +188,7 @@ class FileVoterTest extends TestCase
         $fileVoter->method('isValidInternalRequest')->willReturn(false);
         $fileVoter->method('isUserLoggedIn')->willReturn(true);
 
-        $file->method('getVisibility')->willReturn(FileVisibilityEnum::NOBODY()->getValue());
+        $file->method('getVisibility')->willReturn(FileVisibilityEnum::NOBODY);
 
         $owner = $this->getMockBuilder(Person::class)->getMock();
         $userPerson = $this->getMockBuilder(Person::class)->getMock();
@@ -213,7 +213,7 @@ class FileVoterTest extends TestCase
         $fileVoter->method('isValidInternalRequest')->willReturn(false);
         $fileVoter->method('isUserLoggedIn')->willReturn(true);
 
-        $file->method('getVisibility')->willReturn(FileVisibilityEnum::NOBODY()->getValue());
+        $file->method('getVisibility')->willReturn(FileVisibilityEnum::NOBODY);
 
         $owner = $this->getMockBuilder(Person::class)->getMock();
         $userPerson = $this->getMockBuilder(Person::class)->getMock();
@@ -241,7 +241,7 @@ class FileVoterTest extends TestCase
 
         $fileVoter->method('isUserLoggedIn')->willReturn(true);
 
-        $file->method('getVisibility')->willReturn(FileVisibilityEnum::NOBODY()->getValue());
+        $file->method('getVisibility')->willReturn(FileVisibilityEnum::NOBODY);
 
         $owner = $this->getMockBuilder(Person::class)->getMock();
         $userPerson = $this->getMockBuilder(Person::class)->getMock();
@@ -268,7 +268,7 @@ class FileVoterTest extends TestCase
 
         $fileVoter->method('isUserLoggedIn')->willReturn(true);
 
-        $file->method('getVisibility')->willReturn(FileVisibilityEnum::NOBODY()->getValue());
+        $file->method('getVisibility')->willReturn(FileVisibilityEnum::NOBODY);
 
         $owner = $this->getMockBuilder(Person::class)->getMock();
         $userPerson = $this->getMockBuilder(Person::class)->getMock();
@@ -590,7 +590,7 @@ class FileVoterTest extends TestCase
 
         $file = $this->getMockBuilder(File::class)->getMock();
         $file->method('getAvailabilityDate')->willReturn(new \DateTime('2020-01-31'));
-        $file->method('getType')->willReturn(FileTypeEnum::UNKNOWN()->getValue());
+        $file->method('getType')->willReturn(FileTypeEnum::UNKNOWN);
         $this->accessUtils->method('hasRole')->with($user, 'ROLE_BILLACCOUNTING')->willReturn(false);
 
         $this->assertFalse($fileVoter->isAvailable($file, $user));
@@ -606,7 +606,7 @@ class FileVoterTest extends TestCase
 
         $file = $this->getMockBuilder(File::class)->getMock();
         $file->method('getAvailabilityDate')->willReturn(new \DateTime('2020-01-31'));
-        $file->method('getType')->willReturn(FileTypeEnum::BILL()->getValue());
+        $file->method('getType')->willReturn(FileTypeEnum::BILL);
         $this->accessUtils->method('hasRole')->with($user, 'ROLE_BILLACCOUNTING')->willReturn(true);
 
         $this->assertTrue($fileVoter->isAvailable($file, $user));

+ 3 - 2
tests/Unit/Service/Access/AccessProfileCreatorTest.php

@@ -7,6 +7,7 @@ use App\Entity\Access\Access;
 use App\Entity\Core\File;
 use App\Entity\Organization\Organization;
 use App\Entity\Person\Person;
+use App\Enum\Person\GenderEnum;
 use App\Repository\Access\AccessRepository;
 use App\Service\Access\AccessProfileCreator;
 use App\Service\Access\Utils as AccessUtils;
@@ -359,7 +360,7 @@ class AccessProfileCreatorTest extends TestCase
         $person = $this->getMockBuilder(Person::class)->getMock();
         $person->expects(self::once())->method('getName')->willReturn('Foo');
         $person->expects(self::once())->method('getGivenName')->willReturn('Bar');
-        $person->expects(self::once())->method('getGender')->willReturn('MR');
+        $person->expects(self::once())->method('getGender')->willReturn(GenderEnum::MISTER);
         $person->expects(self::once())->method('getImage')->willReturn($image);
 
         $this->access->expects(self::once())->method('getId')->willReturn(1);
@@ -379,7 +380,7 @@ class AccessProfileCreatorTest extends TestCase
         $this->assertEquals(1, $accessProfile->getId());
         $this->assertEquals('Foo', $accessProfile->getName());
         $this->assertEquals('Bar', $accessProfile->getGivenName());
-        $this->assertEquals('MR', $accessProfile->getGender());
+        $this->assertEquals(GenderEnum::MISTER, $accessProfile->getGender());
         $this->assertEquals(2020, $accessProfile->getActivityYear());
         $this->assertEquals(123, $accessProfile->getAvatarId());
         $this->assertFalse($accessProfile->getIsSuperAdminAccess());

+ 3 - 3
tests/Unit/Service/Access/OptionalsRoles/CriteriaNotationOptionalRoleTest.php

@@ -41,7 +41,7 @@ class CriteriaNotationOptionalRoleTest extends TestCase
 
         $this->accessRepository
             ->method('hasGotFunctionAtThisDate')
-            ->with($access, FunctionEnum::TEACHER(), self::isInstanceOf(DateTime::class))
+            ->with($access, FunctionEnum::TEACHER, self::isInstanceOf(DateTime::class))
             ->willReturn(true);
 
         $this->assertTrue(
@@ -71,7 +71,7 @@ class CriteriaNotationOptionalRoleTest extends TestCase
 
         $this->accessRepository
             ->method('hasGotFunctionAtThisDate')
-            ->with($access, FunctionEnum::TEACHER(), self::isInstanceOf(DateTime::class))
+            ->with($access, FunctionEnum::TEACHER, self::isInstanceOf(DateTime::class))
             ->willReturn(false);
 
         $this->assertFalse(
@@ -101,7 +101,7 @@ class CriteriaNotationOptionalRoleTest extends TestCase
 
         $this->accessRepository
             ->method('hasGotFunctionAtThisDate')
-            ->with($access, FunctionEnum::TEACHER(), self::isInstanceOf(DateTime::class))
+            ->with($access, FunctionEnum::TEACHER, self::isInstanceOf(DateTime::class))
             ->willReturn(true);
 
         $this->assertFalse(

+ 13 - 12
tests/Unit/Service/Access/UtilsTest.php

@@ -6,6 +6,7 @@ use App\Entity\Access\Access;
 use App\Entity\Access\FunctionType;
 use App\Entity\Access\OrganizationFunction;
 use App\Entity\Organization\Organization;
+use App\Enum\Access\FunctionEnum;
 use App\Repository\Access\AccessRepository;
 use App\Service\Access\Utils as AccessUtils;
 use App\Service\ServiceIterator\OptionalsRolesIterator;
@@ -137,7 +138,7 @@ class UtilsTest extends TestCase
 
         // Valide: pas de date de fin ou de début
         $functionType1 = $this->getMockBuilder(FunctionType::class)->getMock();
-        $functionType1->method('getMission')->willReturn('Mission1');
+        $functionType1->method('getMission')->willReturn(FunctionEnum::ADHERENT);
 
         $function1 = $this->getMockBuilder(OrganizationFunction::class)->getMock();
         $function1->method('getEndDate')->willReturn(null);
@@ -146,7 +147,7 @@ class UtilsTest extends TestCase
 
         // Valide: pas de date de fin ou de début
         $functionType2 = $this->getMockBuilder(FunctionType::class)->getMock();
-        $functionType2->method('getMission')->willReturn('Mission2');
+        $functionType2->method('getMission')->willReturn(FunctionEnum::ACCOUNTANT);
 
         $function2 = $this->getMockBuilder(OrganizationFunction::class)->getMock();
         $function2->method('getEndDate')->willReturn(null);
@@ -155,7 +156,7 @@ class UtilsTest extends TestCase
 
         // Invalide: date de fin dépassée
         $functionType3 = $this->getMockBuilder(FunctionType::class)->getMock();
-        $functionType3->method('getMission')->willReturn('Mission3');
+        $functionType3->method('getMission')->willReturn(FunctionEnum::ACTIVE_MEMBER_OF_THE_CA);
 
         $function3 = $this->getMockBuilder(OrganizationFunction::class)->getMock();
         $function3->method('getEndDate')->willReturn(new \DateTime('2022-01-01'));
@@ -164,7 +165,7 @@ class UtilsTest extends TestCase
 
         // Valide : date de fin dans les 24h suivant le jour même
         $functionType4 = $this->getMockBuilder(FunctionType::class)->getMock();
-        $functionType4->method('getMission')->willReturn('Mission4');
+        $functionType4->method('getMission')->willReturn(FunctionEnum::ADMINISTRATIVE_OFFICER);
 
         $function4 = $this->getMockBuilder(OrganizationFunction::class)->getMock();
         $function4->method('getEndDate')->willReturn(new \DateTime('2023-01-01 18:00'));
@@ -173,7 +174,7 @@ class UtilsTest extends TestCase
 
         // Valide: date de fin dans le futur
         $functionType5 = $this->getMockBuilder(FunctionType::class)->getMock();
-        $functionType5->method('getMission')->willReturn('Mission5');
+        $functionType5->method('getMission')->willReturn(FunctionEnum::ADMINISTRATIVE_SECRETARY);
 
         $function5 = $this->getMockBuilder(OrganizationFunction::class)->getMock();
         $function5->method('getEndDate')->willReturn(new \DateTime('2023-06-01'));
@@ -182,7 +183,7 @@ class UtilsTest extends TestCase
 
         // Invalide: date de début dans le futur
         $functionType6 = $this->getMockBuilder(FunctionType::class)->getMock();
-        $functionType6->method('getMission')->willReturn('Mission6');
+        $functionType6->method('getMission')->willReturn(FunctionEnum::BENEFACTOR_MEMBER);
 
         $function6 = $this->getMockBuilder(OrganizationFunction::class)->getMock();
         $function6->method('getEndDate')->willReturn(null);
@@ -191,7 +192,7 @@ class UtilsTest extends TestCase
 
         // Valide: date de début dans le passé
         $functionType7 = $this->getMockBuilder(FunctionType::class)->getMock();
-        $functionType7->method('getMission')->willReturn('Mission7');
+        $functionType7->method('getMission')->willReturn(FunctionEnum::DIRECTOR_ASSISTANT);
 
         $function7 = $this->getMockBuilder(OrganizationFunction::class)->getMock();
         $function7->method('getEndDate')->willReturn(null);
@@ -200,7 +201,7 @@ class UtilsTest extends TestCase
 
         // Valide: date de début dans le passé et date de fin dans le futur
         $functionType8 = $this->getMockBuilder(FunctionType::class)->getMock();
-        $functionType8->method('getMission')->willReturn('Mission8');
+        $functionType8->method('getMission')->willReturn(FunctionEnum::DESK_OFFICER);
 
         $function8 = $this->getMockBuilder(OrganizationFunction::class)->getMock();
         $function8->method('getEndDate')->willReturn(new \DateTime('2023-06-01'));
@@ -212,7 +213,7 @@ class UtilsTest extends TestCase
         );
 
         $this->assertEquals(
-            ['Mission1', 'Mission2', 'Mission4', 'Mission5', 'Mission7', 'Mission8'],
+            [FunctionEnum::ADHERENT, FunctionEnum::ACCOUNTANT, FunctionEnum::ADMINISTRATIVE_OFFICER, FunctionEnum::ADMINISTRATIVE_SECRETARY, FunctionEnum::DIRECTOR_ASSISTANT, FunctionEnum::DESK_OFFICER],
             $accessUtils->getActiveFunctions($access)
         );
     }
@@ -225,13 +226,13 @@ class UtilsTest extends TestCase
         $accessUtils
             ->method('getActiveFunctions')
             ->with($access)
-            ->willReturn(['Mission1', 'Mission2']);
+            ->willReturn([FunctionEnum::ADHERENT->value, FunctionEnum::ACCOUNTANT->value]);
 
         $this->assertTrue(
-            $accessUtils->hasActiveFunction($access, 'Mission1')
+            $accessUtils->hasActiveFunction($access, FunctionEnum::ADHERENT)
         );
         $this->assertFalse(
-            $accessUtils->hasActiveFunction($access, 'Mission3')
+            $accessUtils->hasActiveFunction($access, FunctionEnum::ACTIVE_MEMBER_OF_THE_CA)
         );
     }
 }

+ 3 - 3
tests/Unit/Service/Core/ContactPointUtilsTest.php

@@ -34,7 +34,7 @@ class ContactPointUtilsTest extends TestCase
 
         $this->contactPointRepository
             ->method('getByTypeAndPerson')
-            ->with(ContactPointTypeEnum::PRINCIPAL()->getValue(), $access->getPerson())
+            ->with(ContactPointTypeEnum::PRINCIPAL, $access->getPerson())
             ->willReturn([$contactPoint]);
 
         $contactPointUtils = $this
@@ -60,7 +60,7 @@ class ContactPointUtilsTest extends TestCase
 
         $this->contactPointRepository
             ->method('getByTypeAndPerson')
-            ->with(ContactPointTypeEnum::PRINCIPAL()->getValue(), $access->getPerson())
+            ->with(ContactPointTypeEnum::PRINCIPAL, $access->getPerson())
             ->willReturn([]);
 
         $contactPointUtils = $this
@@ -87,7 +87,7 @@ class ContactPointUtilsTest extends TestCase
 
         $this->contactPointRepository
             ->method('getByTypeAndPerson')
-            ->with(ContactPointTypeEnum::PRINCIPAL()->getValue(), $access->getPerson())
+            ->with(ContactPointTypeEnum::PRINCIPAL, $access->getPerson())
             ->willReturn([$contactPoint1, $contactPoint2]);
 
         $contactPointUtils = $this

+ 3 - 2
tests/Unit/Service/Cotisation/CotisationCreatorTest.php

@@ -3,6 +3,7 @@
 namespace App\Tests\Unit\Service\Cotisation;
 
 use App\Entity\Organization\Organization;
+use App\Enum\Cotisation\AlertStateEnum;
 use App\Repository\Organization\OrganizationRepository;
 use App\Service\Cotisation\CotisationCreator;
 use App\Service\Cotisation\Utils;
@@ -35,12 +36,12 @@ class CotisationCreatorTest extends TestCase
         $organization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock();
         $this->organizationRepository->expects(self::once())->method('find')->willReturn($organization);
 
-        $this->cotisationUtils->expects(self::once())->method('getAlertState')->with($organization, 2000)->willReturn('foo');
+        $this->cotisationUtils->expects(self::once())->method('getAlertState')->with($organization, 2000)->willReturn(AlertStateEnum::ADVERTISINGINSURANCE);
 
         $cotisation = $cotisationCreator->getCotisation(1);
 
         $this->assertEquals(1, $cotisation->getOrganizationId());
         $this->assertEquals(2000, $cotisation->getCotisationYear());
-        $this->assertEquals('foo', $cotisation->getAlertState());
+        $this->assertEquals(AlertStateEnum::ADVERTISINGINSURANCE, $cotisation->getAlertState());
     }
 }

+ 5 - 5
tests/Unit/Service/Cotisation/UtilsTest.php

@@ -265,9 +265,9 @@ class UtilsTest extends TestCase
                 self::MEMBERSHIP_WAITING, self::SUBMIT_IN_PROGRESS, self::MEMBERSHIP_NOPAYMENT
             );
 
-        $this->assertEquals(AlertStateEnum::AFFILIATION()->getValue(), $cotisationUtils->getAlertState($organization, $year) );
-        $this->assertEquals(AlertStateEnum::AFFILIATION()->getValue(), $cotisationUtils->getAlertState($organization, $year) );
-        $this->assertEquals(AlertStateEnum::INVOICE()->getValue(), $cotisationUtils->getAlertState($organization, $year) );
+        $this->assertEquals(AlertStateEnum::AFFILIATION, $cotisationUtils->getAlertState($organization, $year) );
+        $this->assertEquals(AlertStateEnum::AFFILIATION, $cotisationUtils->getAlertState($organization, $year) );
+        $this->assertEquals(AlertStateEnum::INVOICE, $cotisationUtils->getAlertState($organization, $year) );
     }
 
     /**
@@ -295,7 +295,7 @@ class UtilsTest extends TestCase
             ->with($organization->getId(), $year)
             ->willReturn(true);
 
-        $this->assertEquals(AlertStateEnum::INSURANCE()->getValue(), $cotisationUtils->getAlertState($organization, $year) );
+        $this->assertEquals(AlertStateEnum::INSURANCE, $cotisationUtils->getAlertState($organization, $year) );
     }
 
     /**
@@ -323,7 +323,7 @@ class UtilsTest extends TestCase
             ->with($organization->getId())
             ->willReturn(true);
 
-        $this->assertEquals(AlertStateEnum::ADVERTISINGINSURANCE()->getValue(), $cotisationUtils->getAlertState($organization, $year) );
+        $this->assertEquals(AlertStateEnum::ADVERTISINGINSURANCE, $cotisationUtils->getAlertState($organization, $year) );
     }
 
     /**

+ 90 - 73
tests/Unit/Service/Dolibarr/DolibarrSyncServiceTest.php

@@ -6,6 +6,7 @@ use App\Entity\Access\Access;
 use App\Entity\Access\FunctionType;
 use App\Entity\Core\AddressPostal;
 use App\Entity\Core\ContactPoint;
+use App\Entity\Core\Gender;
 use App\Entity\Network\Network;
 use App\Entity\Network\NetworkOrganization;
 use App\Entity\Organization\Organization;
@@ -18,12 +19,14 @@ use App\Enum\Core\ContactPointTypeEnum;
 use App\Enum\Network\NetworkEnum;
 use App\Enum\Organization\AddressPostalOrganizationTypeEnum;
 use App\Enum\Organization\SettingsProductEnum;
+use App\Enum\Person\GenderEnum;
 use App\Repository\Access\AccessRepository;
 use App\Repository\Access\FunctionTypeRepository;
 use App\Repository\Organization\OrganizationRepository;
 use App\Service\Core\AddressPostalUtils;
 use App\Service\Dolibarr\DolibarrApiService;
 use App\Service\Dolibarr\DolibarrSyncService;
+use App\Service\Organization\Utils;
 use App\Service\Rest\Operation\BaseRestOperation;
 use App\Service\Rest\Operation\CreateOperation;
 use App\Service\Rest\Operation\DeleteOperation;
@@ -92,6 +95,9 @@ class DolibarrSyncServiceTest extends TestCase
         $this->logger = $this->getMockBuilder(LoggerInterface::class)
             ->disableOriginalConstructor()
             ->getMock();
+        $this->organizationUtils = $this->getMockBuilder(Utils::class)
+            ->disableOriginalConstructor()
+            ->getMock();
 
         $this->logger->method('info')->willReturnSelf();
         $this->logger->method('debug')->willReturnSelf();
@@ -102,7 +108,7 @@ class DolibarrSyncServiceTest extends TestCase
     private function getMockForMethod(string $method) {
         $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
             ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator])
+                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->organizationUtils])
             ->setMethodsExcept([$method, 'setLoggerInterface'])
             ->getMock();
         $dolibarrSyncService->setLoggerInterface($this->logger);
@@ -132,8 +138,8 @@ class DolibarrSyncServiceTest extends TestCase
             'city' => 'ByteCity',
             'email' => 'foo@bar.net',
             'phone' => '0102030405',
-            'networkId' => NetworkEnum::CMF()->getValue(),
-            'product' => SettingsProductEnum::SCHOOL()->getValue()
+            'networkId' => NetworkEnum::CMF->value,
+            'product' => SettingsProductEnum::SCHOOL
         ];
 
         $orgId2 = 20;
@@ -145,7 +151,7 @@ class DolibarrSyncServiceTest extends TestCase
             'email' => null,
             'phone' => null,
             'networkId' => null,
-            'product' => SettingsProductEnum::ARTIST()->getValue()
+            'product' => SettingsProductEnum::ARTIST
         ];
 
         $orgId3 = 30;
@@ -163,7 +169,7 @@ class DolibarrSyncServiceTest extends TestCase
         $personData1 = [
             'name' => 'Dupont',
             'givenName' => 'Hercules',
-            'gender' => 'Mr',
+            'gender' => GenderEnum::MISTER,
             'email' => 'an@email.net',
             'phone' => '0102030405',
             'mobilePhone' => '0607080910',
@@ -186,13 +192,13 @@ class DolibarrSyncServiceTest extends TestCase
         ];
 
         $activeMembers1 = [
-            $accessId1 => [FunctionEnum::PRESIDENT()->getValue()],
-            $accessId3 => [FunctionEnum::STUDENT()->getValue()],
-            $accessId5 => [FunctionEnum::TREASURER()->getValue()]
+            $accessId1 => [FunctionEnum::PRESIDENT->value],
+            $accessId3 => [FunctionEnum::STUDENT->value],
+            $accessId5 => [FunctionEnum::TREASURER->value]
         ];
 
         $activeMembers2 = [
-            $accessId2 => [FunctionEnum::PRESIDENT()->getValue()]
+            $accessId2 => [FunctionEnum::PRESIDENT->value]
         ];
 
 
@@ -279,9 +285,9 @@ class DolibarrSyncServiceTest extends TestCase
             ['STUDENTS_COUNT', [], null, null, "Nombre d'élèves"],
             ['ADHERENTS_COUNT', [], null, null, "Nombre d'adhérents"],
             ['ADMIN_ACCESS_COUNT', [], null, null, "Nombre d'accès admin"],
-            ['school', [], null, null, 'Opentalent School'],
-            ['artist', [], null, null, 'Opentalent Artist'],
-            ['Mr', [], null, null, 'MR'],
+            [SettingsProductEnum::SCHOOL->value, [], null, null, 'Opentalent School'],
+            [SettingsProductEnum::ARTIST->value, [], null, null, 'Opentalent Artist'],
+            [GenderEnum::MISTER->value, [], null, null, 'MR'],
         ]);
 
         // Get societies
@@ -312,13 +318,13 @@ class DolibarrSyncServiceTest extends TestCase
 
         // Function types
         $functionType1 = $this->getMockBuilder(FunctionType::class)->getMock();
-        $functionType1->method('getMission')->willReturn(FunctionEnum::DIRECTOR()->getValue());
+        $functionType1->method('getMission')->willReturn(FunctionEnum::DIRECTOR);
         $functionType2 = $this->getMockBuilder(FunctionType::class)->getMock();
-        $functionType2->method('getMission')->willReturn(FunctionEnum::PRESIDENT()->getValue());
+        $functionType2->method('getMission')->willReturn(FunctionEnum::PRESIDENT);
         $this->functionTypeRepository
             ->expects($this->once())
             ->method('findBy')
-            ->with(['roleByDefault' => RoleEnum::ROLE_ADMIN()->getValue()])
+            ->with(['roleByDefault' => RoleEnum::ROLE_ADMIN])
             ->willReturn([$functionType1, $functionType2]);
 
         // Get CMF and FFEC ids
@@ -383,14 +389,24 @@ class DolibarrSyncServiceTest extends TestCase
         $organization1->method('getSettings')->willReturn($settings1);
 
         $settings2 = $this->getMockBuilder(Settings::class)->getMock();
-        $settings1->method('getProduct')->willReturn($organizationData2['product']);
+        $settings2->method('getProduct')->willReturn($organizationData2['product']);
         $organization2->method('getSettings')->willReturn($settings2);
 
+        $this->organizationUtils->method('isSchool')->willReturnMap([
+            [$organization1, true],
+            [$organization2, false]
+        ]);
+        $this->organizationUtils->method('isArtist')->willReturnMap([
+            [$organization1, false],
+            [$organization2, true]
+        ]);
+
         $dolibarrSyncService->method('countWithMission')->willReturnMap([
-            [[FunctionEnum::STUDENT()->getValue()], $activeMembers1, 1],
-            [[FunctionEnum::ADHERENT()->getValue()], $activeMembers1, 2],
-            [[FunctionEnum::DIRECTOR()->getValue(), FunctionEnum::PRESIDENT()->getValue()], $activeMembers1, 1],
-            [[FunctionEnum::DIRECTOR()->getValue(), FunctionEnum::PRESIDENT()->getValue()], $activeMembers2, 2]
+            [[FunctionEnum::STUDENT->value], $activeMembers1, 1],
+            [[FunctionEnum::ADHERENT->value], $activeMembers1, 2],
+            [[FunctionEnum::ADHERENT->value], $activeMembers2, 0],
+            [[FunctionEnum::DIRECTOR->value, FunctionEnum::PRESIDENT->value], $activeMembers1, 1],
+            [[FunctionEnum::DIRECTOR->value, FunctionEnum::PRESIDENT->value], $activeMembers2, 2]
         ]);
 
         $this->arrayUtils
@@ -475,8 +491,8 @@ class DolibarrSyncServiceTest extends TestCase
         ]);
 
         $dolibarrSyncService->method('formatContactPosition')->willReturnMap([
-            [[FunctionEnum::PRESIDENT()->getValue()], 'Mr', 'Président'],
-            [[FunctionEnum::PRESIDENT()->getValue()], null, 'Président(e)'],
+            [[FunctionEnum::PRESIDENT->value], GenderEnum::MISTER->value, 'Président'],
+            [[FunctionEnum::PRESIDENT->value], null, 'Président(e)'],
         ]);
 
         // Expected logged error messages
@@ -548,7 +564,8 @@ class DolibarrSyncServiceTest extends TestCase
                 'status : (new) => `1`',
                 'town : (new) => ``',
                 'zip : (new) => ``',
-                'array_options.options_2iopeninfoopentalent : (new) => `Nombre d\'accès admin : 2`',
+                'array_options.options_2iopen_software_opentalent : (new) => `Opentalent Artist`',
+                "array_options.options_2iopeninfoopentalent : (new) => `Nombre d'adhérents : 0\nNombre d'accès admin : 2`",
             ],
             $operations[3]->getChangeLog()
         );
@@ -686,18 +703,18 @@ class DolibarrSyncServiceTest extends TestCase
             ->method('getAllActiveMembersAndMissions')
             ->willReturn(
                 [
-                    ['id' => 1, 'organization_id' => 1, 'mission' => FunctionEnum::PRESIDENT()->getValue()],
-                    ['id' => 2, 'organization_id' => 1, 'mission' => FunctionEnum::STUDENT()->getValue()],
-                    ['id' => 3, 'organization_id' => 2, 'mission' => FunctionEnum::PRESIDENT()->getValue()],
-                    ['id' => 3, 'organization_id' => 2, 'mission' => FunctionEnum::TEACHER()->getValue()]
+                    ['id' => 1, 'organization_id' => 1, 'mission' => FunctionEnum::PRESIDENT],
+                    ['id' => 2, 'organization_id' => 1, 'mission' => FunctionEnum::STUDENT],
+                    ['id' => 3, 'organization_id' => 2, 'mission' => FunctionEnum::PRESIDENT],
+                    ['id' => 3, 'organization_id' => 2, 'mission' => FunctionEnum::TEACHER]
                 ]
             );
 
         $index = $dolibarrSyncService->getActiveMembersIndex();
 
         $this->assertEqualsCanonicalizing([
-            1 => [1 => [FunctionEnum::PRESIDENT()->getValue()], 2 => [FunctionEnum::STUDENT()->getValue()]],
-            2 => [3 => [FunctionEnum::PRESIDENT()->getValue(), FunctionEnum::TEACHER()->getValue()]]
+            1 => [1 => [FunctionEnum::PRESIDENT], 2 => [FunctionEnum::STUDENT]],
+            2 => [3 => [FunctionEnum::PRESIDENT, FunctionEnum::TEACHER]]
         ], $index);
     }
 
@@ -830,9 +847,9 @@ class DolibarrSyncServiceTest extends TestCase
         $organizationAddressPostal3 = $this->getMockBuilder(OrganizationAddressPostal::class)->getMock();
         $addressPostal = $this->getMockBuilder(AddressPostal::class)->getMock();
 
-        $organizationAddressPostal1->method('getType')->willReturn(AddressPostalOrganizationTypeEnum::ADDRESS_PRACTICE()->getValue());
-        $organizationAddressPostal2->method('getType')->willReturn(AddressPostalOrganizationTypeEnum::ADDRESS_BILL()->getValue());
-        $organizationAddressPostal3->method('getType')->willReturn(AddressPostalOrganizationTypeEnum::ADDRESS_OTHER()->getValue());
+        $organizationAddressPostal1->method('getType')->willReturn(AddressPostalOrganizationTypeEnum::ADDRESS_PRACTICE);
+        $organizationAddressPostal2->method('getType')->willReturn(AddressPostalOrganizationTypeEnum::ADDRESS_BILL);
+        $organizationAddressPostal3->method('getType')->willReturn(AddressPostalOrganizationTypeEnum::ADDRESS_OTHER);
 
         $organizationAddressPostal2->method('getAddressPostal')->willReturn($addressPostal);
 
@@ -877,9 +894,9 @@ class DolibarrSyncServiceTest extends TestCase
         $contactPoint2 = $this->getMockBuilder(ContactPoint::class)->getMock();
         $contactPoint3 = $this->getMockBuilder(ContactPoint::class)->getMock();
 
-        $contactPoint1->method('getContactType')->willReturn(ContactPointTypeEnum::OTHER()->getValue());
-        $contactPoint2->method('getContactType')->willReturn(ContactPointTypeEnum::BILL()->getValue());
-        $contactPoint3->method('getContactType')->willReturn(ContactPointTypeEnum::PRINCIPAL()->getValue());
+        $contactPoint1->method('getContactType')->willReturn(ContactPointTypeEnum::OTHER);
+        $contactPoint2->method('getContactType')->willReturn(ContactPointTypeEnum::BILL);
+        $contactPoint3->method('getContactType')->willReturn(ContactPointTypeEnum::PRINCIPAL);
 
         $phone = $this->getMockBuilder(PhoneNumber::class)->disableOriginalConstructor()->getMock();
         $contactPoint2->method('getTelphone')->willReturn($phone);
@@ -911,9 +928,9 @@ class DolibarrSyncServiceTest extends TestCase
         $contactPoint2 = $this->getMockBuilder(ContactPoint::class)->getMock();
         $contactPoint3 = $this->getMockBuilder(ContactPoint::class)->getMock();
 
-        $contactPoint1->method('getContactType')->willReturn(ContactPointTypeEnum::OTHER()->getValue());
-        $contactPoint2->method('getContactType')->willReturn(ContactPointTypeEnum::BILL()->getValue());
-        $contactPoint3->method('getContactType')->willReturn(ContactPointTypeEnum::PRINCIPAL()->getValue());
+        $contactPoint1->method('getContactType')->willReturn(ContactPointTypeEnum::OTHER);
+        $contactPoint2->method('getContactType')->willReturn(ContactPointTypeEnum::BILL);
+        $contactPoint3->method('getContactType')->willReturn(ContactPointTypeEnum::PRINCIPAL);
 
         $contactPoint2->expects($this->once())->method('getTelphone')->willReturn(null);
 
@@ -966,9 +983,9 @@ class DolibarrSyncServiceTest extends TestCase
         $contactPoint2 = $this->getMockBuilder(ContactPoint::class)->getMock();
         $contactPoint3 = $this->getMockBuilder(ContactPoint::class)->getMock();
 
-        $contactPoint1->method('getContactType')->willReturn(ContactPointTypeEnum::OTHER()->getValue());
-        $contactPoint2->method('getContactType')->willReturn(ContactPointTypeEnum::BILL()->getValue());
-        $contactPoint3->method('getContactType')->willReturn(ContactPointTypeEnum::PRINCIPAL()->getValue());
+        $contactPoint1->method('getContactType')->willReturn(ContactPointTypeEnum::OTHER);
+        $contactPoint2->method('getContactType')->willReturn(ContactPointTypeEnum::BILL);
+        $contactPoint3->method('getContactType')->willReturn(ContactPointTypeEnum::PRINCIPAL);
 
         $contactPoint2->method('getEmail')->willReturn('email@email.com');
 
@@ -1079,33 +1096,33 @@ class DolibarrSyncServiceTest extends TestCase
         $dolibarrSyncService = $this->getMockForMethod('countWithMission');
 
         $members = [
-            123 => [FunctionEnum::PRESIDENT()->getValue(), FunctionEnum::TEACHER()->getValue()],
-            124 => [FunctionEnum::TEACHER()->getValue()],
-            125 => [FunctionEnum::STUDENT()->getValue()],
-            126 => [FunctionEnum::TREASURER()->getValue()],
+            123 => [FunctionEnum::PRESIDENT->value, FunctionEnum::TEACHER->value],
+            124 => [FunctionEnum::TEACHER->value],
+            125 => [FunctionEnum::STUDENT->value],
+            126 => [FunctionEnum::TREASURER->value],
         ];
 
         $this->assertEquals(
             2,
-            $dolibarrSyncService->countWithMission([FunctionEnum::TEACHER()->getValue()], $members)
+            $dolibarrSyncService->countWithMission([FunctionEnum::TEACHER->value], $members)
         );
 
         $this->assertEquals(
             3,
             $dolibarrSyncService->countWithMission(
-                [FunctionEnum::TEACHER()->getValue(), FunctionEnum::TREASURER()->getValue()],
+                [FunctionEnum::TEACHER->value, FunctionEnum::TREASURER->value],
                 $members
             )
         );
 
         $this->assertEquals(
             1,
-            $dolibarrSyncService->countWithMission([FunctionEnum::STUDENT()->getValue()], $members)
+            $dolibarrSyncService->countWithMission([FunctionEnum::STUDENT->value], $members)
         );
 
         $this->assertEquals(
             0,
-            $dolibarrSyncService->countWithMission([FunctionEnum::ARCHIVIST()->getValue()], $members)
+            $dolibarrSyncService->countWithMission([FunctionEnum::ARCHIVIST->value], $members)
         );
     }
 
@@ -1120,8 +1137,8 @@ class DolibarrSyncServiceTest extends TestCase
         $contactPoint1 = $this->getMockBuilder(ContactPoint::class)->getMock();
         $contactPoint2 = $this->getMockBuilder(ContactPoint::class)->getMock();
 
-        $contactPoint1->method('getContactType')->willReturn(ContactPointTypeEnum::OTHER()->getValue());
-        $contactPoint2->method('getContactType')->willReturn(ContactPointTypeEnum::PRINCIPAL()->getValue());
+        $contactPoint1->method('getContactType')->willReturn(ContactPointTypeEnum::OTHER);
+        $contactPoint2->method('getContactType')->willReturn(ContactPointTypeEnum::PRINCIPAL);
 
         $person->expects($this->once())->method('getContactPoints')->willReturn(new ArrayCollection([$contactPoint1, $contactPoint2]));
 
@@ -1147,38 +1164,38 @@ class DolibarrSyncServiceTest extends TestCase
 
         $this->translator->method('trans')->willReturnMap(
             [
-                [FunctionEnum::PRESIDENT()->getValue(), ['gender' => 'X'], null, null, 'Président(e)'],
-                [FunctionEnum::PRESIDENT()->getValue(), ['gender' => 'M'], null, null, 'Président'],
-                [FunctionEnum::PRESIDENT()->getValue(), ['gender' => 'F'], null, null, 'Présidente'],
-                [FunctionEnum::DIRECTOR()->getValue(), ['gender' => 'X'], null, null, 'Directeur(ice)'],
-                [FunctionEnum::DIRECTOR()->getValue(), ['gender' => 'M'], null, null, 'Directeur'],
-                [FunctionEnum::DIRECTOR()->getValue(), ['gender' => 'F'], null, null, 'Directrice'],
-                [FunctionEnum::TEACHER()->getValue(), ['gender' => 'X'], null, null, 'Professeur(e)'],
-                [FunctionEnum::ARCHIVIST()->getValue(), ['gender' => 'X'], null, null, 'Archiviste'],
-                [FunctionEnum::TREASURER()->getValue(), ['gender' => 'X'], null, null, 'Trésorier(ère)'],
-                [FunctionEnum::ADMINISTRATIVE_STAFF()->getValue(), ['gender' => 'X'], null, null, 'Personnel administratif'],
+                [FunctionEnum::PRESIDENT->value, ['gender' => 'X'], null, null, 'Président(e)'],
+                [FunctionEnum::PRESIDENT->value, ['gender' => 'M'], null, null, 'Président'],
+                [FunctionEnum::PRESIDENT->value, ['gender' => 'F'], null, null, 'Présidente'],
+                [FunctionEnum::DIRECTOR->value, ['gender' => 'X'], null, null, 'Directeur(ice)'],
+                [FunctionEnum::DIRECTOR->value, ['gender' => 'M'], null, null, 'Directeur'],
+                [FunctionEnum::DIRECTOR->value, ['gender' => 'F'], null, null, 'Directrice'],
+                [FunctionEnum::TEACHER->value, ['gender' => 'X'], null, null, 'Professeur(e)'],
+                [FunctionEnum::ARCHIVIST->value, ['gender' => 'X'], null, null, 'Archiviste'],
+                [FunctionEnum::TREASURER->value, ['gender' => 'X'], null, null, 'Trésorier(ère)'],
+                [FunctionEnum::ADMINISTRATIVE_STAFF->value, ['gender' => 'X'], null, null, 'Personnel administratif'],
             ]
         );
 
         $this->assertEquals(
             'Président(e)',
-            $dolibarrSyncService->formatContactPosition([FunctionEnum::PRESIDENT()->getValue()])
+            $dolibarrSyncService->formatContactPosition([FunctionEnum::PRESIDENT->value])
         );
 
         $this->assertEquals(
             'Président',
-            $dolibarrSyncService->formatContactPosition([FunctionEnum::PRESIDENT()->getValue()], 'MISTER')
+            $dolibarrSyncService->formatContactPosition([FunctionEnum::PRESIDENT->value], 'MISTER')
         );
 
         $this->assertEquals(
             'Présidente',
-            $dolibarrSyncService->formatContactPosition([FunctionEnum::PRESIDENT()->getValue()], 'MISS')
+            $dolibarrSyncService->formatContactPosition([FunctionEnum::PRESIDENT->value], 'MISS')
         );
 
         $this->assertEquals(
             'Présidente, Directrice',
             $dolibarrSyncService->formatContactPosition(
-                [FunctionEnum::PRESIDENT()->getValue(), FunctionEnum::DIRECTOR()->getValue()],
+                [FunctionEnum::PRESIDENT->value, FunctionEnum::DIRECTOR->value],
                 'MISS'
             )
         );
@@ -1186,7 +1203,7 @@ class DolibarrSyncServiceTest extends TestCase
         $this->assertEquals(
             'Président, Directeur',
             $dolibarrSyncService->formatContactPosition(
-                [FunctionEnum::PRESIDENT()->getValue(), FunctionEnum::DIRECTOR()->getValue(), FunctionEnum::ADHERENT()->getValue()],
+                [FunctionEnum::PRESIDENT->value, FunctionEnum::DIRECTOR->value, FunctionEnum::ADHERENT->value],
                 'MISTER'
             )
         );
@@ -1194,7 +1211,7 @@ class DolibarrSyncServiceTest extends TestCase
         $this->assertEquals(
             'Président, Directeur',
             $dolibarrSyncService->formatContactPosition(
-                [FunctionEnum::PRESIDENT()->getValue(), FunctionEnum::DIRECTOR()->getValue(), FunctionEnum::ADHERENT()->getValue()],
+                [FunctionEnum::PRESIDENT->value, FunctionEnum::DIRECTOR->value, FunctionEnum::ADHERENT->value],
                 'MISTER'
             )
         );
@@ -1203,12 +1220,12 @@ class DolibarrSyncServiceTest extends TestCase
             'Président(e), Directeur(ice), Professeur(e), Archiviste, Trésorier(ère), Pers...',
             $dolibarrSyncService->formatContactPosition(
                 [
-                    FunctionEnum::PRESIDENT()->getValue(),
-                    FunctionEnum::DIRECTOR()->getValue(),
-                    FunctionEnum::TEACHER()->getValue(),
-                    FunctionEnum::ARCHIVIST()->getValue(),
-                    FunctionEnum::TREASURER()->getValue(),
-                    FunctionEnum::ADMINISTRATIVE_STAFF()->getValue(),
+                    FunctionEnum::PRESIDENT->value,
+                    FunctionEnum::DIRECTOR->value,
+                    FunctionEnum::TEACHER->value,
+                    FunctionEnum::ARCHIVIST->value,
+                    FunctionEnum::TREASURER->value,
+                    FunctionEnum::ADMINISTRATIVE_STAFF->value,
                 ],
                 'X'
             )

+ 2 - 2
tests/Unit/Service/Education/EducationNotationUtilsTest.php

@@ -105,7 +105,7 @@ class EducationNotationUtilsTest extends TestCase
         $noteMax = 20;
 
         $criteriaNotation = $this->getMockBuilder(CriteriaNotation::class)->getMock();
-        $criteriaNotation->method('getType')->willReturn(TypeCriteriaEnum::WITH_NOTATION()->getValue());
+        $criteriaNotation->method('getType')->willReturn(TypeCriteriaEnum::WITH_NOTATION);
 
         $educationNotation1 = $this->getMockBuilder(EducationNotation::class)->getMock();
         $educationNotation1->method('getCriteriaNotation')->willReturn($criteriaNotation);
@@ -194,7 +194,7 @@ class EducationNotationUtilsTest extends TestCase
         $noteMax = 20;
 
         $criteriaNotation = $this->getMockBuilder(CriteriaNotation::class)->getMock();
-        $criteriaNotation->expects(self::once())->method('getType')->willReturn(TypeCriteriaEnum::WITHOUT_NOTATION()->getValue());
+        $criteriaNotation->expects(self::once())->method('getType')->willReturn(TypeCriteriaEnum::WITHOUT_NOTATION);
 
         $educationNotation = $this->getMockBuilder(EducationNotation::class)->getMock();
         $educationNotation->expects(self::atLeastOnce())->method('getNote')->willReturn($note);

+ 10 - 4
tests/Unit/Service/Export/BaseExporterTest.php

@@ -7,6 +7,8 @@ use App\Entity\Access\Access;
 use App\Entity\Core\File;
 use App\Entity\Organization\Organization;
 use App\Enum\Core\FileTypeEnum;
+use App\Enum\Core\FileVisibilityEnum;
+use App\Enum\Export\ExportFormatEnum;
 use App\Repository\Access\AccessRepository;
 use App\Repository\Core\FileRepository;
 use App\Service\Export\BaseExporter;
@@ -94,6 +96,7 @@ class BaseExporterTest extends TestCase
         $exportRequest = $this->getMockBuilder(ExportRequest::class)->disableOriginalConstructor()->getMock();
         $exportRequest->method('getRequesterId')->willReturn(123);
         $exportRequest->method('getFileId')->willReturn(456);
+        $exportRequest->method('getFormat')->willReturn(ExportFormatEnum::PDF);
 
         $model = $this->getMockBuilder(ExportModelInterface::class)->disableOriginalConstructor()->getMock();
         $exporter->expects(self::once())->method('buildModel')->with($exportRequest)->willReturn($model);
@@ -124,6 +127,7 @@ class BaseExporterTest extends TestCase
         $exportRequest = $this->getMockBuilder(ExportRequest::class)->disableOriginalConstructor()->getMock();
         $exportRequest->method('getRequesterId')->willReturn(123);
         $exportRequest->method('getFileId')->willReturn(null);
+        $exportRequest->method('getFormat')->willReturn(ExportFormatEnum::PDF);
 
         $model = $this->getMockBuilder(ExportModelInterface::class)->disableOriginalConstructor()->getMock();
         $exporter->expects(self::once())->method('buildModel')->with($exportRequest)->willReturn($model);
@@ -156,6 +160,7 @@ class BaseExporterTest extends TestCase
         $exportRequest = $this->getMockBuilder(ExportRequest::class)->disableOriginalConstructor()->getMock();
         $exportRequest->method('getRequesterId')->willReturn(123);
         $exportRequest->method('getFileId')->willReturn(456);
+        $exportRequest->method('getFormat')->willReturn(ExportFormatEnum::PDF);
 
         $this->accessRepository->method('find')->with(123, null, null)->willReturn(null);
 
@@ -176,6 +181,7 @@ class BaseExporterTest extends TestCase
         $exportRequest = $this->getMockBuilder(ExportRequest::class)->disableOriginalConstructor()->getMock();
         $exportRequest->method('getRequesterId')->willReturn(123);
         $exportRequest->method('getFileId')->willReturn(null);
+        $exportRequest->method('getFormat')->willReturn(ExportFormatEnum::PDF);
 
         $model = $this->getMockBuilder(ExportModelInterface::class)->disableOriginalConstructor()->getMock();
         $exporter->expects(self::once())->method('buildModel')->with($exportRequest)->willReturn($model);
@@ -206,13 +212,13 @@ class BaseExporterTest extends TestCase
 
         $exportRequest = $this->getMockBuilder(ExportRequest::class)->disableOriginalConstructor()->getMock();
         $exportRequest->method('getRequesterId')->willReturn(123);
-        $exportRequest->method('getFormat')->willReturn('pdf');
+        $exportRequest->method('getFormat')->willReturn(ExportFormatEnum::PDF);
 
         $access = $this->getMockBuilder(Access::class)->disableOriginalConstructor()->getMock();
         $this->accessRepository->method('find')->with(123, null, null)->willReturn($access);
 
         $exporter->method('getFileBasename')->with($exportRequest)->willReturn('Foo');
-        $exporter->method('getFileType')->willReturn(FileTypeEnum::UNKNOWN());
+        $exporter->method('getFileType')->willReturn(FileTypeEnum::UNKNOWN);
 
         $file = $this->getMockBuilder(File::class)->disableOriginalConstructor()->getMock();
 
@@ -221,7 +227,7 @@ class BaseExporterTest extends TestCase
         $this->fileManager->expects(self::once())
             ->method('prepareFile')
             ->with(
-                $access, 'Foo.pdf', FileTypeEnum::UNKNOWN(), $access, true, 'NOBODY', 'application/pdf', false
+                $access, 'Foo.pdf', FileTypeEnum::UNKNOWN, $access, true, FileVisibilityEnum::NOBODY , 'application/pdf', false
             )->willReturn($file);
 
         $result = $exporter->prepareFile($exportRequest, false);
@@ -359,6 +365,6 @@ class BaseExporterTest extends TestCase
     public function testGetFileType(): void {
         $exporter = $this->getBaseExporterMockFor('getFileType');
 
-        $this->assertEquals(FileTypeEnum::UNKNOWN(), $exporter->getFileType());
+        $this->assertEquals(FileTypeEnum::UNKNOWN, $exporter->getFileType());
     }
 }

+ 8 - 4
tests/Unit/Service/Export/LicenceCmfExporterTest.php

@@ -6,11 +6,15 @@ use App\ApiResources\Export\ExportRequest;
 use App\ApiResources\Export\LicenceCmf\LicenceCmfOrganizationER;
 use App\Entity\Access\Access;
 use App\Entity\Core\File;
+use App\Entity\Core\Gender;
 use App\Entity\Network\NetworkOrganization;
 use App\Entity\Organization\Organization;
 use App\Entity\Organization\Parameters;
 use App\Entity\Person\Person;
 use App\Enum\Access\FunctionEnum;
+use App\Enum\Core\FileTypeEnum;
+use App\Enum\Export\ExportFormatEnum;
+use App\Enum\Person\GenderEnum;
 use App\Repository\Access\AccessRepository;
 use App\Repository\Organization\OrganizationRepository;
 use App\Service\Export\Encoder\PdfEncoder;
@@ -106,7 +110,7 @@ class LicenceCmfExporterTest extends TestCase
     {
         $this->exportRequest->method('getRequesterId')->willReturn(1);
         $this->exportRequest->method('getYear')->willReturn(2020);
-        $this->exportRequest->method('getFormat')->willReturn('pdf');
+        $this->exportRequest->method('getFormat')->willReturn(ExportFormatEnum::PDF);
 
         $this->accessRepo->method('find')->with(1)->willReturn($this->access);
         $this->access->method('getOrganization')->willReturn($this->organization);
@@ -121,13 +125,13 @@ class LicenceCmfExporterTest extends TestCase
         $this->logo->method('getId')->willReturn(1);
         $this->fileManager->method('getDownloadIri')->willReturn('http:://foo.bar/1');
         $this->president->method('getId')->willReturn(1);
-        $this->president->method('getGender')->willReturn('M');
+        $this->president->method('getGender')->willReturn(GenderEnum::MISTER);
         $this->president->method('getGivenName')->willReturn('Joe');
         $this->president->method('getName')->willReturn('Dalton');
         $this->accessRepo
             ->expects(self::once())
             ->method('findByOrganizationAndMission')
-            ->with($this->organization, FunctionEnum::PRESIDENT()->getValue())
+            ->with($this->organization, FunctionEnum::PRESIDENT)
             ->willReturn([$this->presidentAccess]);
         $this->presidentAccess->method('getPerson')->willReturn($this->president);
         $this->cmf->method('getParameters')->willReturn($this->cmfParameters);
@@ -205,7 +209,7 @@ class LicenceCmfExporterTest extends TestCase
         $exporter = $this->makeExporterMock('getFileType');
 
         $this->assertEquals(
-            'LICENCE_CMF',
+            FileTypeEnum::LICENCE_CMF,
             $this->invokeMethod($exporter, 'getFileType')
         );
     }

+ 3 - 2
tests/Unit/Service/Export/Model/LicenceCmfTest.php

@@ -3,6 +3,7 @@
 namespace App\Tests\Unit\Service\Export\Model;
 
 use App\Entity\Core\File;
+use App\Enum\Person\GenderEnum;
 use App\Service\Export\Model\LicenceCmf;
 use PHPUnit\Framework\TestCase;
 
@@ -57,7 +58,7 @@ class LicenceCmfTest extends TestCase
             ->setLogo($logo)
             ->setQrCode($qrCode)
             ->setPersonId(2)
-            ->setPersonGender('MR')
+            ->setPersonGender(GenderEnum::MISTER)
             ->setPersonFirstName('Don Diego')
             ->setPersonLastName('De la Vega')
             ->setPersonAvatar($avatar);
@@ -72,7 +73,7 @@ class LicenceCmfTest extends TestCase
         $this->assertEquals($logo, $model->getLogo());
         $this->assertEquals($qrCode, $model->getQrCode());
         $this->assertEquals(2, $model->getPersonId());
-        $this->assertEquals('MR', $model->getPersonGender());
+        $this->assertEquals(GenderEnum::MISTER, $model->getPersonGender());
         $this->assertEquals('Don Diego', $model->getPersonFirstName());
         $this->assertEquals('De la Vega', $model->getPersonLastName());
         $this->assertEquals($avatar, $model->getPersonAvatar());

+ 5 - 4
tests/Unit/Service/File/FileManagerTest.php

@@ -12,6 +12,7 @@ use App\Entity\Core\File;
 use App\Entity\Organization\Organization;
 use App\Enum\Core\FileHostEnum;
 use App\Enum\Core\FileTypeEnum;
+use App\Enum\Core\FileVisibilityEnum;
 use App\Service\File\Exception\FileNotFoundException;
 use App\Service\File\Factory\ImageFactory;
 use App\Service\File\FileManager;
@@ -97,10 +98,10 @@ class FileManagerTest extends TestCase
 
         $owner = $this->createMock(Organization::class);
         $filename = "example_file.txt";
-        $fileType = FileTypeEnum::NONE(); // Update with your specific enum type
+        $fileType = FileTypeEnum::NONE; // Update with your specific enum type
         $createdBy = $this->createMock(Access::class);
         $isTemporary = false;
-        $visibility = 'NOBODY';
+        $visibility = FileVisibilityEnum::NOBODY;
         $mimeType = null;
         $flushFile = true;
 
@@ -134,11 +135,11 @@ class FileManagerTest extends TestCase
 
         $owner = $this->createMock(Organization::class);
         $filename = "example_file.txt";
-        $fileType = FileTypeEnum::NONE(); // Update with your specific enum type
+        $fileType = FileTypeEnum::NONE; // Update with your specific enum type
         $content = "Some content";
         $author = $this->createMock(Access::class);
         $isTemporary = false;
-        $visibility = 'NOBODY';
+        $visibility = FileVisibilityEnum::NOBODY;
         $mimeType = null;
 
         $this->localStorage

+ 27 - 25
tests/Unit/Service/File/Storage/LocalStorageTest.php

@@ -6,8 +6,10 @@ use App\Entity\Access\Access;
 use App\Entity\Core\File;
 use App\Entity\Organization\Organization;
 use App\Entity\Person\Person;
+use App\Enum\Booking\VisibilityEnum;
 use App\Enum\Core\FileStatusEnum;
 use App\Enum\Core\FileTypeEnum;
+use App\Enum\Core\FileVisibilityEnum;
 use App\Repository\Access\AccessRepository;
 use App\Service\File\Factory\ImageFactory;
 use App\Service\File\Storage\LocalStorage;
@@ -27,7 +29,7 @@ use RuntimeException;
 class TestableLocalStorage extends LocalStorage {
     public const FS_KEY = parent::FS_KEY;
 
-    public function getPrefix(mixed $owner, bool $isTemporary, string $type = null): string {
+    public function getPrefix(mixed $owner, bool $isTemporary, FileTypeEnum $type = null): string {
         return parent::getPrefix($owner, $isTemporary, $type);
     }
     #[Pure] public function getOrganizationAndPersonFromOwner(mixed $owner): array {
@@ -118,13 +120,13 @@ class LocalStorageTest extends TestCase
 
         $owner = $this->getMockBuilder(Organization::class)->getMock();
 
-        $fileStorage->method('getPrefix')->with($owner, false, FileTypeEnum::LICENCE_CMF()->getValue())->willReturn('foo');
+        $fileStorage->method('getPrefix')->with($owner, false, FileTypeEnum::LICENCE_CMF)->willReturn('foo');
 
         $this->filesystem->method('listKeys')->with('foo')->willReturn(['foo/a.txt', 'foo/b.pdf']);
 
         $this->assertEquals(
             ['foo/a.txt', 'foo/b.pdf'],
-            $fileStorage->listByOwner($owner, FileTypeEnum::LICENCE_CMF())
+            $fileStorage->listByOwner($owner, FileTypeEnum::LICENCE_CMF)
         );
     }
 
@@ -165,10 +167,10 @@ class LocalStorageTest extends TestCase
         $file = $fileStorage->prepareFile(
             $owner,
             'file.ext',
-            FileTypeEnum::LICENCE_CMF(),
+            FileTypeEnum::LICENCE_CMF,
             $author,
             true,
-            'ONLY_ORGANIZATION',
+            FileVisibilityEnum::ONLY_ORGANIZATION,
             'application/pdf'
         );
 
@@ -176,9 +178,9 @@ class LocalStorageTest extends TestCase
         $this->assertEquals(null, $file->getPerson());
         $this->assertEquals('file.ext', $file->getName());
         $this->assertEquals(null, $file->getSlug());
-        $this->assertEquals(FileTypeEnum::LICENCE_CMF()->getValue(), $file->getType());
+        $this->assertEquals(FileTypeEnum::LICENCE_CMF, $file->getType());
         $this->assertTrue($file->getIsTemporaryFile());
-        $this->assertEquals('ONLY_ORGANIZATION', $file->getVisibility());
+        $this->assertEquals(FileVisibilityEnum::ONLY_ORGANIZATION, $file->getVisibility());
         $this->assertEquals('application/pdf', $file->getMimeType());
         $this->assertEquals(123, $file->getCreatedBy());
 
@@ -201,14 +203,14 @@ class LocalStorageTest extends TestCase
 
         $this->fileUtils->method('guessMimeTypeFromFilename')->with('file.txt')->willReturn('text/plain');
 
-        $file = $fileStorage->prepareFile($owner, 'file.txt', FileTypeEnum::NONE(), $author);
+        $file = $fileStorage->prepareFile($owner, 'file.txt', FileTypeEnum::NONE, $author);
 
         $this->assertEquals(null, $file->getOrganization());
         $this->assertEquals($owner, $file->getPerson());
         $this->assertEquals('file.txt', $file->getName());
-        $this->assertEquals(FileTypeEnum::NONE()->getValue(), $file->getType());
+        $this->assertEquals(FileTypeEnum::NONE, $file->getType());
         $this->assertFalse($file->getIsTemporaryFile());
-        $this->assertEquals('NOBODY', $file->getVisibility());
+        $this->assertEquals(FileVisibilityEnum::NOBODY, $file->getVisibility());
         $this->assertEquals('text/plain', $file->getMimeType());
     }
 
@@ -232,10 +234,10 @@ class LocalStorageTest extends TestCase
         $fileStorage->prepareFile(
             $owner,
             'file.txt',
-            FileTypeEnum::NONE(),
+            FileTypeEnum::NONE,
             $author,
             false,
-            'NOBODY',
+            FileVisibilityEnum::NOBODY,
             'text/plain',
             false
         );
@@ -258,11 +260,11 @@ class LocalStorageTest extends TestCase
         $file->method('getPerson')->willReturn(null);
         $file->method('getIsTemporaryFile')->willReturn(false);
         $file->method('getSlug')->willReturn(null);
-        $file->method('getType')->willReturn(FileTypeEnum::NONE()->getValue());
+        $file->method('getType')->willReturn(FileTypeEnum::NONE);
 
         $fileStorage
             ->method('getPrefix')
-            ->with($organization, false, FileTypeEnum::NONE()->getValue())
+            ->with($organization, false, FileTypeEnum::NONE)
             ->willReturn('prefix/');
 
         $content = '123456789';
@@ -275,7 +277,7 @@ class LocalStorageTest extends TestCase
             ->willReturn($size);
 
         $file->expects(self::once())->method('setSize')->with($size)->willReturnSelf();
-        $file->expects(self::once())->method('setStatus')->with(FileStatusEnum::READY()->getValue())->willReturnSelf();
+        $file->expects(self::once())->method('setStatus')->with(FileStatusEnum::READY)->willReturnSelf();
         $file->expects(self::once())
             ->method('setSlug')
             ->with(self::matchesRegularExpression('/^prefix\/\w{16,24}\/foo.txt/'))
@@ -311,7 +313,7 @@ class LocalStorageTest extends TestCase
         $file->method('getPerson')->willReturn($person);
         $file->method('getIsTemporaryFile')->willReturn(true);
         $file->method('getSlug')->willReturn($key);
-        $file->method('getType')->willReturn(FileTypeEnum::NONE()->getValue());
+        $file->method('getType')->willReturn(FileTypeEnum::NONE);
 
         $fileStorage->expects(self::never())->method('getPrefix');
 
@@ -327,7 +329,7 @@ class LocalStorageTest extends TestCase
         $this->filesystem->method('has')->with($key)->willReturn(true);
 
         $file->expects(self::once())->method('setSize')->with($size)->willReturnSelf();
-        $file->expects(self::once())->method('setStatus')->with(FileStatusEnum::READY()->getValue())->willReturnSelf();
+        $file->expects(self::once())->method('setStatus')->with(FileStatusEnum::READY)->willReturnSelf();
         $file->expects(self::never())->method('setSlug');
         $file->expects(self::never())->method('setCreateDate');
         $file->expects(self::never())->method('setCreatedBy');
@@ -359,7 +361,7 @@ class LocalStorageTest extends TestCase
         $file->method('getPerson')->willReturn($person);
         $file->method('getIsTemporaryFile')->willReturn(true);
         $file->method('getSlug')->willReturn($key);
-        $file->method('getType')->willReturn(FileTypeEnum::NONE()->getValue());
+        $file->method('getType')->willReturn(FileTypeEnum::NONE);
 
         $this->filesystem->expects(self::never())->method('write');
         $this->entityManager->expects(self::never())->method('flush');
@@ -391,7 +393,7 @@ class LocalStorageTest extends TestCase
         $file->method('getPerson')->willReturn($person);
         $file->method('getIsTemporaryFile')->willReturn(true);
         $file->method('getSlug')->willReturn(null);
-        $file->method('getType')->willReturn(FileTypeEnum::NONE()->getValue());
+        $file->method('getType')->willReturn(FileTypeEnum::NONE);
 
         $this->accessRepository
             ->expects(self::once())
@@ -402,7 +404,7 @@ class LocalStorageTest extends TestCase
         $fileStorage
             ->expects(self::once())
             ->method('getPrefix')
-            ->with($access, true, FileTypeEnum::NONE()->getValue())
+            ->with($access, true, FileTypeEnum::NONE)
             ->willReturn('prefix/');
 
         $content = '1';
@@ -442,7 +444,7 @@ class LocalStorageTest extends TestCase
         $fileStorage
             ->expects(self::once())
             ->method('prepareFile')
-            ->with($organization, 'foo.txt', FileTypeEnum::NONE(), $author, true, 'ONLY_ORGANIZATION', 'mime/type')
+            ->with($organization, 'foo.txt', FileTypeEnum::NONE, $author, true, FileVisibilityEnum::ONLY_ORGANIZATION, 'mime/type')
             ->willReturn($file);
 
         $fileStorage
@@ -454,11 +456,11 @@ class LocalStorageTest extends TestCase
         $fileStorage->makeFile(
             $organization,
             'foo.txt',
-            FileTypeEnum::NONE(),
+            FileTypeEnum::NONE,
             '...',
             $author,
             true,
-            'ONLY_ORGANIZATION',
+            FileVisibilityEnum::ONLY_ORGANIZATION,
             'mime/type');
     }
 
@@ -474,7 +476,7 @@ class LocalStorageTest extends TestCase
         $file = $this->getMockBuilder(File::class)->getMock();
         $file->method('getSlug')->willReturn('key');
 
-        $file->expects(self::once())->method('setStatus')->with(FileStatusEnum::DELETED()->getValue())->willReturnSelf();
+        $file->expects(self::once())->method('setStatus')->with(FileStatusEnum::DELETED)->willReturnSelf();
         $file->expects(self::once())->method('setSize')->with(0)->willReturnSelf();
         $file->expects(self::once())->method('setUpdatedBy')->with(123)->willReturnSelf();
 
@@ -583,7 +585,7 @@ class LocalStorageTest extends TestCase
         $organization = $this->getMockBuilder(Organization::class)->getMock();
         $organization->method('getId')->willReturn(1);
 
-        $prefix = $fileStorage->getPrefix($organization, false, FileTypeEnum::LICENCE_CMF()->getValue());
+        $prefix = $fileStorage->getPrefix($organization, false, FileTypeEnum::LICENCE_CMF);
 
         $this->assertEquals('organization/1/licence_cmf', $prefix);
     }

+ 7 - 7
tests/Unit/Service/Mailer/Builder/AbstractBuilderTest.php

@@ -86,7 +86,7 @@ class AbstractBuilderTest extends TestCase
      */
     public function testAddRecipient(){
         $abstractBuilder = $this->makeAbstractBuilderMock('addRecipient');
-        $sendType = EmailSendingTypeEnum::TO()->getValue();
+        $sendType = EmailSendingTypeEnum::TO;
 
         //Access Target
         $person = $this->getMockBuilder(Person::class)->getMock();
@@ -94,7 +94,7 @@ class AbstractBuilderTest extends TestCase
         $this->access->method('getPerson')->willReturn($person);
 
         $email = new \App\Service\Mailer\Email();
-        $abstractBuilder->addRecipient($email, $this->access, $sendType, ContactPointTypeEnum::PRINCIPAL()->getValue());
+        $abstractBuilder->addRecipient($email, $this->access, $sendType, ContactPointTypeEnum::PRINCIPAL);
 
         /** @var EmailRecipient $emailRecipient */
         $emailRecipient = $email->getEmailRecipients()->first();
@@ -107,7 +107,7 @@ class AbstractBuilderTest extends TestCase
         $organization->method('getName')->willReturn('Test');
 
         $email = new \App\Service\Mailer\Email();
-        $abstractBuilder->addRecipient($email, $organization, $sendType, ContactPointTypeEnum::PRINCIPAL()->getValue());
+        $abstractBuilder->addRecipient($email, $organization, $sendType, ContactPointTypeEnum::PRINCIPAL);
 
         /** @var EmailRecipient $emailRecipient */
         $emailRecipient = $email->getEmailRecipients()->first();
@@ -117,12 +117,12 @@ class AbstractBuilderTest extends TestCase
         //Custom Target
         $custom = "foo.bar@opentalent.fr";
         $email = new \App\Service\Mailer\Email();
-        $abstractBuilder->addRecipient($email, $custom, $sendType, ContactPointTypeEnum::PRINCIPAL()->getValue());
+        $abstractBuilder->addRecipient($email, $custom, $sendType, ContactPointTypeEnum::PRINCIPAL);
 
         /** @var EmailRecipient $emailRecipient */
         $emailRecipient = $email->getEmailRecipients()->first();
         $this->assertEquals($custom, $emailRecipient->getEmailAddress());
-        $this->assertEquals(ReportMessageStatusEnum::DELIVERED()->getValue(), $emailRecipient->getSendStatus());
+        $this->assertEquals(ReportMessageStatusEnum::DELIVERED, $emailRecipient->getSendStatus());
     }
 
     /**
@@ -136,7 +136,7 @@ class AbstractBuilderTest extends TestCase
         $emailRecipient = new EmailRecipient();
         $abstractBuilder->setMailToRecipient([$contactPoint], $emailRecipient);
 
-        $this->assertEquals(ReportMessageStatusEnum::MISSING()->getValue(), $emailRecipient->getSendStatus());
+        $this->assertEquals(ReportMessageStatusEnum::MISSING, $emailRecipient->getSendStatus());
     }
 
     /**
@@ -151,7 +151,7 @@ class AbstractBuilderTest extends TestCase
         $abstractBuilder->method('getFirstContactPointWithEmail')->willReturn($contactPoint);
         $abstractBuilder->setMailToRecipient([$contactPoint], $emailRecipient);
 
-        $this->assertEquals(ReportMessageStatusEnum::DELIVERED()->getValue(), $emailRecipient->getSendStatus());
+        $this->assertEquals(ReportMessageStatusEnum::DELIVERED, $emailRecipient->getSendStatus());
         $this->assertEquals('foo.bar@opentalent.fr', $emailRecipient->getEmailAddress());
     }
 

+ 11 - 11
tests/Unit/Service/Mailer/MailerTest.php

@@ -135,7 +135,7 @@ class MailerTest extends TestCase
 
         $emailsCollection = $mailer->main($mailerModel);
 
-        $this->assertEquals(MessageStatusEnum::NO_RECIPIENT()->getValue(), $email->getEmailEntity()->getStatus());
+        $this->assertEquals(MessageStatusEnum::NO_RECIPIENT, $email->getEmailEntity()->getStatus());
 
         $this->assertInstanceOf(Email::class, $emailsCollection->first());
     }
@@ -191,7 +191,7 @@ class MailerTest extends TestCase
 
         $mailer->send($email);
 
-        $this->assertEquals(MessageStatusEnum::SEND()->getValue(), $email->getEmailEntity()->getStatus());
+        $this->assertEquals(MessageStatusEnum::SEND, $email->getEmailEntity()->getStatus());
     }
 
     /**
@@ -235,16 +235,16 @@ class MailerTest extends TestCase
         $mailer = $this->makeMailerMock('getDeliveredAndUndelivered');
 
         $emailRecipient = $this->getMockBuilder(EmailRecipient::class)->disableOriginalConstructor()->getMock();
-        $emailRecipient->method('getSendStatus')->willReturn(ReportMessageStatusEnum::MISSING()->getValue());
+        $emailRecipient->method('getSendStatus')->willReturn(ReportMessageStatusEnum::MISSING);
         $emailRecipient2 = $this->getMockBuilder(EmailRecipient::class)->disableOriginalConstructor()->getMock();
-        $emailRecipient2->method('getSendStatus')->willReturn(ReportMessageStatusEnum::DELIVERED()->getValue());
+        $emailRecipient2->method('getSendStatus')->willReturn(ReportMessageStatusEnum::DELIVERED);
         $email = $this->getMockBuilder(Email::class)->disableOriginalConstructor()->getMock();
         $email->method('getEmailRecipients')->willReturn(new ArrayCollection([$emailRecipient, $emailRecipient2]));
 
         $emailRecipient3 = $this->getMockBuilder(EmailRecipient::class)->disableOriginalConstructor()->getMock();
-        $emailRecipient3->method('getSendStatus')->willReturn(ReportMessageStatusEnum::DELIVERED()->getValue());
+        $emailRecipient3->method('getSendStatus')->willReturn(ReportMessageStatusEnum::DELIVERED);
         $emailRecipient4 = $this->getMockBuilder(EmailRecipient::class)->disableOriginalConstructor()->getMock();
-        $emailRecipient4->method('getSendStatus')->willReturn(ReportMessageStatusEnum::MISSING()->getValue());
+        $emailRecipient4->method('getSendStatus')->willReturn(ReportMessageStatusEnum::MISSING);
         $email2 = $this->getMockBuilder(Email::class)->disableOriginalConstructor()->getMock();
         $email2->method('getEmailRecipients')->willReturn(new ArrayCollection([$emailRecipient3, $emailRecipient4]));
 
@@ -286,16 +286,16 @@ class MailerTest extends TestCase
         $emailRecipient = $this->getMockBuilder(EmailRecipient::class)->disableOriginalConstructor()->getMock();
         $emailRecipient->method('getEmailAddress')->willReturn('foo.bar@opentalent.fr');
         $emailRecipient->method('getName')->willReturn('Will Farel');
-        $emailRecipient->method('getSendType')->willReturn(EmailSendingTypeEnum::TO()->getValue());
+        $emailRecipient->method('getSendType')->willReturn(EmailSendingTypeEnum::TO);
         $emailRecipient->method('getAccess')->willReturn($access);
-        $emailRecipient->method('getSendStatus')->willReturn(ReportMessageStatusEnum::DELIVERED()->getValue());
+        $emailRecipient->method('getSendStatus')->willReturn(ReportMessageStatusEnum::DELIVERED);
 
         $report = $mailer->createReport($emailRecipient);
 
         $this->assertInstanceOf(ReportEmail::class, $report);
         $this->assertEquals('foo.bar@opentalent.fr', $report->getAddressEmail());
         $this->assertEquals($access, $report->getAccess());
-        $this->assertEquals(ReportMessageStatusEnum::DELIVERED()->getValue(), $report->getStatus());
+        $this->assertEquals(ReportMessageStatusEnum::DELIVERED, $report->getStatus());
     }
 
     /**
@@ -414,12 +414,12 @@ class MailerTest extends TestCase
         $emailRecipient = $this->getMockBuilder(EmailRecipient::class)->disableOriginalConstructor()->getMock();
         $emailRecipient->method('getEmailAddress')->willReturn('foo.bar@opentalent.fr');
         $emailRecipient->method('getName')->willReturn('Will Farel');
-        $emailRecipient->method('getSendType')->willReturn(EmailSendingTypeEnum::TO()->getValue());
+        $emailRecipient->method('getSendType')->willReturn(EmailSendingTypeEnum::TO);
 
         $emailRecipientBBC = $this->getMockBuilder(EmailRecipient::class)->disableOriginalConstructor()->getMock();
         $emailRecipientBBC->method('getEmailAddress')->willReturn('foo.bar@opentalent.fr.bbc');
         $emailRecipientBBC->method('getName')->willReturn('Will Farel');
-        $emailRecipientBBC->method('getSendType')->willReturn(EmailSendingTypeEnum::BBC()->getValue());
+        $emailRecipientBBC->method('getSendType')->willReturn(EmailSendingTypeEnum::BBC);
 
         $email = $this->getMockBuilder(Email::class)->disableOriginalConstructor()->getMock();
         $email->method('getEmailRecipients')->willReturn(new ArrayCollection([$emailRecipient, $emailRecipientBBC]));

+ 4 - 3
tests/Unit/Service/Network/TreeTest.php

@@ -2,6 +2,7 @@
 namespace App\Tests\Unit\Service\Network;
 
 use App\Entity\Organization\Organization;
+use App\Enum\Organization\PrincipalTypeEnum;
 use App\Repository\Network\NetworkOrganizationRepository;
 use App\Service\Network\Tree;
 use PHPUnit\Framework\TestCase;
@@ -59,15 +60,15 @@ class TreeTest extends TestCase
 
         $organization1 = $this->getMockBuilder(Organization::class)->getMock();
         $organization1->method('getId')->willReturn(2);
-        $organization1->method('getPrincipalType')->willReturn('REGIONAL_FEDERATION');
+        $organization1->method('getPrincipalType')->willReturn(PrincipalTypeEnum::REGIONAL_FEDERATION);
 
         $organization2 = $this->getMockBuilder(Organization::class)->getMock();
         $organization2->method('getId')->willReturn(3);
-        $organization2->method('getPrincipalType')->willReturn('NATIONAL_FEDERATION');
+        $organization2->method('getPrincipalType')->willReturn(PrincipalTypeEnum::NATIONAL_FEDERATION);
 
         $organization3 = $this->getMockBuilder(Organization::class)->getMock();
         $organization3->method('getId')->willReturn(4);
-        $organization3->method('getPrincipalType')->willReturn('DEPARTEMENTAL_FEDERATION');
+        $organization3->method('getPrincipalType')->willReturn(PrincipalTypeEnum::DEPARTEMENTAL_FEDERATION);
 
         $organizations = [
             $organization2,

+ 12 - 12
tests/Unit/Service/Network/UtilsTest.php

@@ -29,7 +29,7 @@ class UtilsTest extends TestCase
         $networkUtils
             ->expects(self::once())
             ->method('doesOrganizationBelongToTheNetwork')
-            ->with($organization, NetworkEnum::CMF())
+            ->with($organization, NetworkEnum::CMF)
             ->willReturn(true);
 
         $result = $networkUtils->isCmf($organization);
@@ -50,7 +50,7 @@ class UtilsTest extends TestCase
         $networkUtils
             ->expects(self::once())
             ->method('doesOrganizationBelongToTheNetwork')
-            ->with($organization, NetworkEnum::CMF())
+            ->with($organization, NetworkEnum::CMF)
             ->willReturn(false);
 
         $result = $networkUtils->isCmf($organization);
@@ -71,7 +71,7 @@ class UtilsTest extends TestCase
         $networkUtils
             ->expects(self::once())
             ->method('doesOrganizationBelongToTheNetwork')
-            ->with($organization, NetworkEnum::CMF(), true)
+            ->with($organization, NetworkEnum::CMF, true)
             ->willReturn(false);
 
         $result = $networkUtils->isCMFAndActiveNow($organization);
@@ -91,13 +91,13 @@ class UtilsTest extends TestCase
         $organization = $this->getMockBuilder(Organization::class)->getMock();
 
         $network1 = $this->getMockBuilder(Network::class)->getMock();
-        $network1->method('getId')->willReturn(NetworkEnum::CMF()->getValue());
+        $network1->method('getId')->willReturn(NetworkEnum::CMF->value);
 
         $networkOrganization1 = $this->getMockBuilder(NetworkOrganization::class)->getMock();
         $networkOrganization1->method('getNetwork')->willReturn($network1);
 
         $network2 = $this->getMockBuilder(Network::class)->getMock();
-        $network2->method('getId')->willReturn(NetworkEnum::FFEC()->getValue());
+        $network2->method('getId')->willReturn(NetworkEnum::FFEC->value);
 
         $networkOrganization2 = $this->getMockBuilder(NetworkOrganization::class)->getMock();
         $networkOrganization2->method('getNetwork')->willReturn($network2);
@@ -109,7 +109,7 @@ class UtilsTest extends TestCase
 
         $networkUtils->expects(self::never())->method('isNetworkOrganizationActiveNow');
 
-        $result = $networkUtils->doesOrganizationBelongToTheNetwork($organization, NetworkEnum::FFEC());
+         $result = $networkUtils->doesOrganizationBelongToTheNetwork($organization, NetworkEnum::FFEC);
 
         $this->assertTrue($result);
     }
@@ -127,13 +127,13 @@ class UtilsTest extends TestCase
         $organization = $this->getMockBuilder(Organization::class)->getMock();
 
         $network1 = $this->getMockBuilder(Network::class)->getMock();
-        $network1->method('getId')->willReturn(NetworkEnum::CMF()->getValue());
+        $network1->method('getId')->willReturn(NetworkEnum::CMF->value);
 
         $networkOrganization1 = $this->getMockBuilder(NetworkOrganization::class)->getMock();
         $networkOrganization1->method('getNetwork')->willReturn($network1);
 
         $network2 = $this->getMockBuilder(Network::class)->getMock();
-        $network2->method('getId')->willReturn(NetworkEnum::FFEC()->getValue());
+        $network2->method('getId')->willReturn(NetworkEnum::FFEC->value);
 
         $networkOrganization2 = $this->getMockBuilder(NetworkOrganization::class)->getMock();
         $networkOrganization2->method('getNetwork')->willReturn($network2);
@@ -145,7 +145,7 @@ class UtilsTest extends TestCase
 
         $networkUtils->expects(self::once())->method('isNetworkOrganizationActiveNow')->with($networkOrganization2)->willReturn(true);
 
-        $result = $networkUtils->doesOrganizationBelongToTheNetwork($organization, NetworkEnum::FFEC(), true);
+        $result = $networkUtils->doesOrganizationBelongToTheNetwork($organization, NetworkEnum::FFEC, true);
 
         $this->assertTrue($result);
     }
@@ -163,13 +163,13 @@ class UtilsTest extends TestCase
         $organization = $this->getMockBuilder(Organization::class)->getMock();
 
         $network1 = $this->getMockBuilder(Network::class)->getMock();
-        $network1->method('getId')->willReturn(NetworkEnum::CMF()->getValue());
+        $network1->method('getId')->willReturn(NetworkEnum::CMF->value);
 
         $networkOrganization1 = $this->getMockBuilder(NetworkOrganization::class)->getMock();
         $networkOrganization1->method('getNetwork')->willReturn($network1);
 
         $network2 = $this->getMockBuilder(Network::class)->getMock();
-        $network2->method('getId')->willReturn(NetworkEnum::FFEC()->getValue());
+        $network2->method('getId')->willReturn(NetworkEnum::FFEC->value);
 
         $networkOrganization2 = $this->getMockBuilder(NetworkOrganization::class)->getMock();
         $networkOrganization2->method('getNetwork')->willReturn($network2);
@@ -181,7 +181,7 @@ class UtilsTest extends TestCase
 
         $networkUtils->expects(self::never())->method('isNetworkOrganizationActiveNow');
 
-        $result = $networkUtils->doesOrganizationBelongToTheNetwork($organization, NetworkEnum::CFBF());
+        $result = $networkUtils->doesOrganizationBelongToTheNetwork($organization, NetworkEnum::CFBF);
 
         $this->assertFalse($result);
     }

+ 9 - 9
tests/Unit/Service/NotifierTest.php

@@ -13,7 +13,7 @@ use Doctrine\ORM\EntityManagerInterface;
 use PHPUnit\Framework\TestCase;
 
 class TestableNotifier extends Notifier {
-    public function createNotification(Access $access, string $name, string $type, array $message, string $link = null): Notification {
+    public function createNotification(Access $access, string $name, NotificationTypeEnum $type, array $message, string $link = null): Notification {
         return parent::createNotification($access, $name, $type, $message, $link);
     }
 }
@@ -46,7 +46,7 @@ class NotifierTest extends TestCase
         $notification = $notifier->createNotification(
             $access,
             'test',
-            NotificationTypeEnum::MESSAGE()->getValue(),
+            NotificationTypeEnum::MESSAGE,
             ['message'],
             'link'
         );
@@ -54,7 +54,7 @@ class NotifierTest extends TestCase
         $this->assertEquals('test', $notification->getName());
         $this->assertEquals($access, $notification->getRecipientAccess());
         $this->assertEquals($organization, $notification->getRecipientOrganization());
-        $this->assertEquals(NotificationTypeEnum::MESSAGE()->getValue(), $notification->getType());
+        $this->assertEquals(NotificationTypeEnum::MESSAGE, $notification->getType());
         $this->assertEquals(['message'], $notification->getMessage());
         $this->assertEquals('link', $notification->getLink());
         $this->assertInstanceOf(\DateTime::class, $notification->getCreateDate());
@@ -78,14 +78,14 @@ class NotifierTest extends TestCase
         $notifier
             ->expects(self::once())
             ->method('createNotification')
-            ->with($access, 'test', NotificationTypeEnum::MESSAGE()->getValue(), ['message'], null)
+            ->with($access, 'test', NotificationTypeEnum::MESSAGE, ['message'], null)
             ->willReturn($notification);
 
         $this->em->expects(self::once())->method('persist')->with($notification);
         $this->em->expects(self::once())->method('flush');
         $this->mercureHub->expects(self::once())->method('publishCreate')->with(1, $notification);
 
-        $returned = $notifier->notify($access, 'test', NotificationTypeEnum::MESSAGE()->getValue(), ['message']);
+        $returned = $notifier->notify($access, 'test', NotificationTypeEnum::MESSAGE, ['message']);
 
         $this->assertEquals($notification, $returned);
     }
@@ -108,7 +108,7 @@ class NotifierTest extends TestCase
         $notifier
             ->expects(self::once())
             ->method('notify')
-            ->with($access, 'export', NotificationTypeEnum::FILE()->getValue(), ['fileName' => 'foo.txt'], '/api/files/1/download');
+            ->with($access, 'export', NotificationTypeEnum::FILE, ['fileName' => 'foo.txt'], '/api/files/1/download');
 
         $notifier->notifyExport($access, $file);
     }
@@ -128,7 +128,7 @@ class NotifierTest extends TestCase
         $notifier
             ->expects(self::once())
             ->method('notify')
-            ->with($access, 'message', NotificationTypeEnum::MESSAGE()->getValue(), ['a message']);
+            ->with($access, 'message', NotificationTypeEnum::MESSAGE, ['a message']);
 
         $notifier->notifyMessage($access, ['a message']);
     }
@@ -148,7 +148,7 @@ class NotifierTest extends TestCase
         $notifier
             ->expects(self::once())
             ->method('notify')
-            ->with($access, 'message', NotificationTypeEnum::SYSTEM()->getValue(), ['a message']);
+            ->with($access, 'message', NotificationTypeEnum::SYSTEM, ['a message']);
 
         $notifier->notifySystem($access, ['a message']);
     }
@@ -168,7 +168,7 @@ class NotifierTest extends TestCase
         $notifier
             ->expects(self::once())
             ->method('notify')
-            ->with($access, 'test', NotificationTypeEnum::ERROR()->getValue(), ['a message']);
+            ->with($access, 'test', NotificationTypeEnum::ERROR, ['a message']);
 
         $notifier->notifyError($access, 'test', ['a message']);
     }

+ 6 - 6
tests/Unit/Service/OnChange/Organization/OnOrganizationChangeTest.php

@@ -29,13 +29,13 @@ class OnOrganizationChangeTest extends TestCase
             ->willReturnSelf();
 
         $previousOrganization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock();
-        $previousOrganization->expects(self::once())->method('getLegalStatus')->willReturn('ASSOCIATION_LAW_1901');
+        $previousOrganization->expects(self::once())->method('getLegalStatus')->willReturn(LegalEnum::ASSOCIATION_LAW_1901);
 
         $context = $this->getMockBuilder(OnChangeContext::class)->disableOriginalConstructor()->getMock();
         $context->method('previousData')->willReturn($previousOrganization);
 
         $organization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock();
-        $organization->expects(self::once())->method('getLegalStatus')->willReturn('ASSOCIATION_LAW_1901');
+        $organization->expects(self::once())->method('getLegalStatus')->willReturn(LegalEnum::ASSOCIATION_LAW_1901);
 
         $onOrganizationChange->beforeChange($organization, $context);
     }
@@ -57,13 +57,13 @@ class OnOrganizationChangeTest extends TestCase
             ->willReturnSelf();
 
         $previousOrganization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock();
-        $previousOrganization->expects(self::once())->method('getLegalStatus')->willReturn('ASSOCIATION_LAW_1901');
+        $previousOrganization->expects(self::once())->method('getLegalStatus')->willReturn(LegalEnum::ASSOCIATION_LAW_1901);
 
         $context = $this->getMockBuilder(OnChangeContext::class)->disableOriginalConstructor()->getMock();
         $context->method('previousData')->willReturn($previousOrganization);
 
         $organization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock();
-        $organization->expects(self::once())->method('getLegalStatus')->willReturn('LOCAL_AUTHORITY');
+        $organization->expects(self::once())->method('getLegalStatus')->willReturn(LegalEnum::LOCAL_AUTHORITY);
 
         $onOrganizationChange->beforeChange($organization, $context);
     }
@@ -81,7 +81,7 @@ class OnOrganizationChangeTest extends TestCase
             ->getMock();
 
         $organization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock();
-        $organization->method('getLegalStatus')->willReturn(LegalEnum::ASSOCIATION_LAW_1901()->getValue());
+        $organization->method('getLegalStatus')->willReturn(LegalEnum::ASSOCIATION_LAW_1901);
 
         $parameters = $this->getMockBuilder(Parameters::class)->disableOriginalConstructor()->getMock();
         $organization->method('getParameters')->willReturn($parameters);
@@ -108,7 +108,7 @@ class OnOrganizationChangeTest extends TestCase
             ->getMock();
 
         $organization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock();
-        $organization->method('getLegalStatus')->willReturn(LegalEnum::COMMERCIAL_SOCIETY()->getValue());
+        $organization->method('getLegalStatus')->willReturn(LegalEnum::COMMERCIAL_SOCIETY);
 
         $parameters = $this->getMockBuilder(Parameters::class)->disableOriginalConstructor()->getMock();
         $organization->method('getParameters')->willReturn($parameters);

+ 6 - 6
tests/Unit/Service/OnChange/Organization/OnParametersChangeTest.php

@@ -116,14 +116,14 @@ class OnParametersChangeTest extends TestCase
         $musicalDate = new \DateTime('2022-01-01');
 
         $previousParameters = $this->getMockBuilder(Parameters::class)->getMock();
-        $previousParameters->method('getAdvancedEducationNotationType')->willReturn('BY_EDUCATION');
+        $previousParameters->method('getAdvancedEducationNotationType')->willReturn(AdvancedEducationNotationTypeEnum::BY_EDUCATION);
         $previousParameters->method('getMusicalDate')->willReturn($musicalDate);
 
         $context = $this->getMockBuilder(OnChangeContext::class)->disableOriginalConstructor()->getMock();
         $context->method('previousData')->willReturn($previousParameters);
 
         $parameters = $this->getMockBuilder(Parameters::class)->getMock();
-        $parameters->method('getAdvancedEducationNotationType')->willReturn('SOMETHING_ELSE');
+        $parameters->method('getAdvancedEducationNotationType')->willReturn(AdvancedEducationNotationTypeEnum::BY_TEACHER);
         $parameters->method('getMusicalDate')->willReturn(new \DateTime('2023-01-01'));
 
         // Both mocked methods should be called once here
@@ -148,7 +148,7 @@ class OnParametersChangeTest extends TestCase
         $musicalDate = new \DateTime('2022-01-01');
 
         $previousParameters = $this->getMockBuilder(Parameters::class)->getMock();
-        $previousParameters->method('getAdvancedEducationNotationType')->willReturn('BY_EDUCATION');
+        $previousParameters->method('getAdvancedEducationNotationType')->willReturn(AdvancedEducationNotationTypeEnum::BY_EDUCATION);
         $previousParameters->method('getMusicalDate')->willReturn($musicalDate);
 
         $context = $this->getMockBuilder(OnChangeContext::class)->disableOriginalConstructor()->getMock();
@@ -156,7 +156,7 @@ class OnParametersChangeTest extends TestCase
 
         $parameters = $this->getMockBuilder(Parameters::class)->getMock();
         $parameters->method('getId')->willReturn(1);
-        $parameters->method('getAdvancedEducationNotationType')->willReturn('BY_EDUCATION');
+        $parameters->method('getAdvancedEducationNotationType')->willReturn(AdvancedEducationNotationTypeEnum::BY_EDUCATION);
         $parameters->method('getMusicalDate')->willReturn($musicalDate);
 
         // None of the mocked methods should be called again here
@@ -339,7 +339,7 @@ class OnParametersChangeTest extends TestCase
 
         $parameters = $this->getMockBuilder(Parameters::class)->getMock();
         $parameters->method('getOrganization')->willReturn($organization);
-        $parameters->method('getAdvancedEducationNotationType')->willReturn(AdvancedEducationNotationTypeEnum::BY_TEACHER()->getValue());
+        $parameters->method('getAdvancedEducationNotationType')->willReturn(AdvancedEducationNotationTypeEnum::BY_TEACHER);
 
         $educationCurriculum->expects(self::once())->method('setEducationNotationConfig')->with(null);
 
@@ -367,7 +367,7 @@ class OnParametersChangeTest extends TestCase
 
         $parameters = $this->getMockBuilder(Parameters::class)->getMock();
         $parameters->method('getOrganization')->willReturn($organization);
-        $parameters->method('getAdvancedEducationNotationType')->willReturn(AdvancedEducationNotationTypeEnum::BY_EDUCATION()->getValue());
+        $parameters->method('getAdvancedEducationNotationType')->willReturn(AdvancedEducationNotationTypeEnum::BY_EDUCATION);
 
         $teacher->expects(self::once())->method('setEducationNotationConfig')->with(null);
 

+ 17 - 8
tests/Unit/Service/Organization/OrganizationProfileCreatorTest.php

@@ -8,7 +8,9 @@ use App\Entity\Network\NetworkOrganization;
 use App\Entity\Organization\Organization;
 use App\Entity\Organization\Parameters;
 use App\Entity\Organization\Settings;
+use App\Enum\Organization\LegalEnum;
 use App\Enum\Organization\PrincipalTypeEnum;
+use App\Enum\Organization\SettingsProductEnum;
 use App\Service\Network\Tree;
 use App\Service\Organization\OrganizationProfileCreator;
 use App\Service\Organization\Utils as OrganizationUtils;
@@ -46,11 +48,10 @@ class OrganizationProfileCreatorTest extends TestCase
         $this->module->method('getOrganizationModules')->with($organization)->willReturn($modules);
         $organizationProfile->expects(self::once())->method('setModules')->with($modules);
 
-        $product = "product";
         $settings = $this->getMockBuilder(Settings::class)->getMock();
-        $settings->method('getProduct')->willReturn($product);
+        $settings->method('getProduct')->willReturn(SettingsProductEnum::ARTIST);
         $organization->method('getSettings')->willReturn($settings);
-        $organizationProfile->expects(self::once())->method('setProduct')->with($product);
+        $organizationProfile->expects(self::once())->method('setProduct')->with(SettingsProductEnum::ARTIST);
 
         $parametersId = 101;
         $parameters = $this->getMockBuilder(Parameters::class)->getMock();
@@ -58,14 +59,14 @@ class OrganizationProfileCreatorTest extends TestCase
         $organization->method('getParameters')->willReturn($parameters);
         $organizationProfile->expects(self::once())->method('setParametersId')->with($parametersId);
 
-        $organization->method('getLegalStatus')->willReturn('foo');
-        $organizationProfile->expects(self::once())->method('setLegalStatus')->with('foo');
+        $organization->method('getLegalStatus')->willReturn(LegalEnum::ASSOCIATION_LAW_1901);
+        $organizationProfile->expects(self::once())->method('setLegalStatus')->with(LegalEnum::ASSOCIATION_LAW_1901);
 
         $organization->method('getNetworkOrganizationChildren')->willReturn(new ArrayCollection([1, 2, 3]));
         $organizationProfile->expects(self::once())->method('setHasChildren')->with(true);
 
         $parameters->method('getShowAdherentList')->willReturn(true);
-        $organization->method('getPrincipalType')->willReturn(PrincipalTypeEnum::LOCAL_FEDERATION()->getValue());
+        $organization->method('getPrincipalType')->willReturn(PrincipalTypeEnum::LOCAL_FEDERATION);
         $organizationProfile->expects(self::once())->method('setShowAdherentList')->with(true);
 
         $network1 = $this->getMockBuilder(Network::class)->getMock();
@@ -127,11 +128,15 @@ class OrganizationProfileCreatorTest extends TestCase
         $organizationProfile = $this->getMockBuilder(OrganizationProfile::class)->getMock();
         $organizationProfileCreator->method('createLightOrganizationProfile')->with($organization)->willReturn($organizationProfile);
 
+        $settings = $this->getMockBuilder(Settings::class)->getMock();
+        $settings->method('getProduct')->willReturn(SettingsProductEnum::ARTIST);
+        $organization->method('getSettings')->willReturn($settings);
+
         $parameters = $this->getMockBuilder(Parameters::class)->getMock();
         $organization->method('getParameters')->willReturn($parameters);
 
         $parameters->method('getShowAdherentList')->willReturn(true);
-        $organization->method('getPrincipalType')->willReturn(PrincipalTypeEnum::ARTISTIC_EDUCATION_ONLY()->getValue());
+        $organization->method('getPrincipalType')->willReturn(PrincipalTypeEnum::ARTISTIC_EDUCATION_ONLY);
         $organizationProfile->expects(self::once())->method('setShowAdherentList')->with(false);
 
         $organization->method('getNetworkOrganizations')->willReturn(new ArrayCollection([]));
@@ -156,11 +161,15 @@ class OrganizationProfileCreatorTest extends TestCase
         $organizationProfile = $this->getMockBuilder(OrganizationProfile::class)->getMock();
         $organizationProfileCreator->method('createLightOrganizationProfile')->with($organization)->willReturn($organizationProfile);
 
+        $settings = $this->getMockBuilder(Settings::class)->getMock();
+        $settings->method('getProduct')->willReturn(SettingsProductEnum::ARTIST);
+        $organization->method('getSettings')->willReturn($settings);
+
         $parameters = $this->getMockBuilder(Parameters::class)->getMock();
         $organization->method('getParameters')->willReturn($parameters);
 
         $parameters->method('getShowAdherentList')->willReturn(false);
-        $organization->method('getPrincipalType')->willReturn(PrincipalTypeEnum::LOCAL_FEDERATION()->getValue());
+        $organization->method('getPrincipalType')->willReturn(PrincipalTypeEnum::LOCAL_FEDERATION);
         $organizationProfile->expects(self::once())->method('setShowAdherentList')->with(false);
 
         $organization->method('getNetworkOrganizations')->willReturn(new ArrayCollection([]));

+ 23 - 23
tests/Unit/Service/Organization/UtilsTest.php

@@ -34,18 +34,18 @@ class UtilsTest extends TestCase
 
         // Each cal to 'isStructure' provoke 2 calls on getProduct
         $settings->method('getProduct')->willReturnOnConsecutiveCalls(
-            SettingsProductEnum::ARTIST()->getValue(),
-            SettingsProductEnum::ARTIST()->getValue(),
-            SettingsProductEnum::ARTIST_PREMIUM()->getValue(),
-            SettingsProductEnum::ARTIST_PREMIUM()->getValue(),
-            SettingsProductEnum::SCHOOL()->getValue(),
-            SettingsProductEnum::SCHOOL()->getValue(),
-            SettingsProductEnum::SCHOOL_PREMIUM()->getValue(),
-            SettingsProductEnum::SCHOOL_PREMIUM()->getValue(),
-            SettingsProductEnum::MANAGER()->getValue(),
-            SettingsProductEnum::MANAGER()->getValue(),
-            SettingsProductEnum::MANAGER_PREMIUM()->getValue(),
-            SettingsProductEnum::MANAGER_PREMIUM()->getValue(),
+            SettingsProductEnum::ARTIST,
+            SettingsProductEnum::ARTIST,
+            SettingsProductEnum::ARTIST_PREMIUM,
+            SettingsProductEnum::ARTIST_PREMIUM,
+            SettingsProductEnum::SCHOOL,
+            SettingsProductEnum::SCHOOL,
+            SettingsProductEnum::SCHOOL_PREMIUM,
+            SettingsProductEnum::SCHOOL_PREMIUM,
+            SettingsProductEnum::MANAGER,
+            SettingsProductEnum::MANAGER,
+            SettingsProductEnum::MANAGER_PREMIUM,
+            SettingsProductEnum::MANAGER_PREMIUM,
         );
 
         $this->assertTrue($organizationUtils->isStructure($organization));
@@ -68,12 +68,12 @@ class UtilsTest extends TestCase
         $organization->method('getSettings')->willReturn($settings);
 
         $settings->method('getProduct')->willReturnOnConsecutiveCalls(
-            SettingsProductEnum::ARTIST()->getValue(),
-            SettingsProductEnum::ARTIST_PREMIUM()->getValue(),
-            SettingsProductEnum::SCHOOL()->getValue(),
-            SettingsProductEnum::SCHOOL_PREMIUM()->getValue(),
-            SettingsProductEnum::MANAGER()->getValue(),
-            SettingsProductEnum::MANAGER_PREMIUM()->getValue(),
+            SettingsProductEnum::ARTIST,
+            SettingsProductEnum::ARTIST_PREMIUM,
+            SettingsProductEnum::SCHOOL,
+            SettingsProductEnum::SCHOOL_PREMIUM,
+            SettingsProductEnum::MANAGER,
+            SettingsProductEnum::MANAGER_PREMIUM,
         );
 
         $this->assertFalse($organizationUtils->isManager($organization));
@@ -93,7 +93,7 @@ class UtilsTest extends TestCase
 
         $organization = $this->getMockBuilder(Organization::class)->getMock();
 
-        $organizationUtils->expects(self::once())->method('isOrganizationIdEqualTo')->with($organization, OrganizationIdsEnum::_2IOS());
+        $organizationUtils->expects(self::once())->method('isOrganizationIdEqualTo')->with($organization, OrganizationIdsEnum::_2IOS);
 
         $organizationUtils->is2iosOrganization($organization);
     }
@@ -107,7 +107,7 @@ class UtilsTest extends TestCase
 
         $organization = $this->getMockBuilder(Organization::class)->getMock();
 
-        $organizationUtils->expects(self::once())->method('isOrganizationIdEqualTo')->with($organization, OrganizationIdsEnum::CMF());
+        $organizationUtils->expects(self::once())->method('isOrganizationIdEqualTo')->with($organization, OrganizationIdsEnum::CMF);
 
         $organizationUtils->isOrganizationCMF($organization);
     }
@@ -121,10 +121,10 @@ class UtilsTest extends TestCase
         $organizationUtils = $this->getMockBuilder(TestableOrganizationUtils::class)->setMethodsExcept(['isOrganizationIdEqualTo'])->getMock();
 
         $organization = $this->getMockBuilder(Organization::class)->getMock();
-        $organization->method('getId')->willReturnOnConsecutiveCalls(123, OrganizationIdsEnum::_2IOS()->getValue());
+        $organization->method('getId')->willReturnOnConsecutiveCalls(123, OrganizationIdsEnum::_2IOS->value);
 
-        $this->assertFalse($organizationUtils->isOrganizationIdEqualTo($organization, OrganizationIdsEnum::_2IOS()));
-        $this->assertTrue($organizationUtils->isOrganizationIdEqualTo($organization, OrganizationIdsEnum::_2IOS()));
+        $this->assertFalse($organizationUtils->isOrganizationIdEqualTo($organization, OrganizationIdsEnum::_2IOS));
+        $this->assertTrue($organizationUtils->isOrganizationIdEqualTo($organization, OrganizationIdsEnum::_2IOS));
     }
 
     /**

+ 5 - 4
tests/Unit/Service/Security/ModuleTest.php

@@ -4,6 +4,7 @@ namespace App\Tests\Unit\Service\Security;
 
 use App\Entity\Organization\Organization;
 use App\Entity\Organization\Settings;
+use App\Enum\Organization\SettingsProductEnum;
 use App\Service\Cotisation\Utils as CotisationUtils;
 use App\Service\Security\Module;
 use App\Service\Utils\ConfigUtils;
@@ -49,7 +50,7 @@ class ModuleTest extends TestCase
         $module->expects(self::once())->method('getModulesByConditions')->willReturn(['CotisationCall']);
 
         $settings = $this->getMockBuilder(Settings::class)->disableOriginalConstructor()->getMock();
-        $settings->expects(self::once())->method('getProduct')->willReturn('school');
+        $settings->expects(self::once())->method('getProduct')->willReturn(SettingsProductEnum::SCHOOL);
 
         $organization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock();
         $organization->expects(self::once())->method('getSettings')->willReturn($settings);
@@ -145,7 +146,7 @@ class ModuleTest extends TestCase
             ['artist' => ['modules' => ['foo']]]
         );
 
-        $this->assertEquals(['foo'], $module->getModulesByProductConfiguration('artist')) ;
+        $this->assertEquals(['foo'], $module->getModulesByProductConfiguration(SettingsProductEnum::ARTIST)) ;
     }
 
     /**
@@ -164,7 +165,7 @@ class ModuleTest extends TestCase
 
         $this->assertEqualsCanonicalizing(
             ['foo', 'bar'],
-            $module->getModulesByProductConfiguration('artist-premium')
+            $module->getModulesByProductConfiguration(SettingsProductEnum::ARTIST_PREMIUM)
         ) ;
     }
 
@@ -184,7 +185,7 @@ class ModuleTest extends TestCase
         $this->expectException(AccessDeniedHttpException::class);
         $this->expectExceptionMessage('The product artist_premium does not exist !');
 
-        $module->getModulesByProductConfiguration('artist-premium');
+        $module->getModulesByProductConfiguration(SettingsProductEnum::ARTIST_PREMIUM);
     }
 
     /**

+ 2 - 2
tests/Unit/Service/Utils/EnvironnementTest.php

@@ -12,11 +12,11 @@ class EnvironnementTest extends TestCase
     public function testGet(): void {
         $environnement = new Environnement();
 
-        $_ENV[EnvironnementVarEnum::APP_ENV()->getValue()] = 'foo';
+        $_ENV[EnvironnementVarEnum::APP_ENV->value] = 'foo';
 
         $this->assertEquals(
             'foo',
-            $environnement->get(EnvironnementVarEnum::APP_ENV()->getValue())
+            $environnement->get(EnvironnementVarEnum::APP_ENV->value)
         );
     }