Olivier Massot 10 月之前
父节点
当前提交
b3a89c1869
共有 31 个文件被更改,包括 186 次插入185 次删除
  1. 8 6
      src/ApiResources/Organization/OrganizationDeletionRequest.php
  2. 1 0
      src/Entity/Access/Access.php
  3. 5 2
      src/Entity/Person/Person.php
  4. 6 9
      src/Message/Handler/OrganizationDeletionHandler.php
  5. 2 1
      src/Message/Message/OrganizationDeletion.php
  6. 0 1
      src/Service/Cron/Job/CleanTempFiles.php
  7. 2 8
      src/Service/File/FileManager.php
  8. 2 8
      src/Service/File/Storage/ApiLegacyStorage.php
  9. 17 25
      src/Service/File/Storage/LocalStorage.php
  10. 5 5
      src/Service/Organization/OrganizationFactory.php
  11. 1 3
      src/Service/Organization/Utils.php
  12. 8 12
      src/Service/Rest/ApiRequestInterface.php
  13. 13 9
      src/Service/Rest/ApiRequestService.php
  14. 2 1
      src/Service/Security/InternalRequestsService.php
  15. 1 1
      src/Service/Typo3/Typo3Service.php
  16. 1 0
      src/Service/Utils/UrlBuilder.php
  17. 1 1
      src/State/Processor/Export/LicenceCmf/ExportRequestProcessor.php
  18. 3 3
      src/State/Processor/Organization/OrganizationCreationRequestProcessor.php
  19. 5 6
      src/State/Processor/Organization/OrganizationDeletionRequestProcessor.php
  20. 42 31
      tests/Unit/Service/Cron/Job/CleanDbTest.php
  21. 19 15
      tests/Unit/Service/Cron/Job/CleanTempFilesTest.php
  22. 14 8
      tests/Unit/Service/Doctrine/FiltersConfigurationServiceTest.php
  23. 2 4
      tests/Unit/Service/File/FileManagerTest.php
  24. 9 7
      tests/Unit/Service/File/Storage/ApiLegacyStorageTest.php
  25. 7 4
      tests/Unit/Service/File/Storage/LocalStorageTest.php
  26. 2 2
      tests/Unit/Service/Organization/OrganizationFactoryTest.php
  27. 0 1
      tests/Unit/Service/Organization/UtilsTest.php
  28. 2 4
      tests/Unit/Service/Rest/ApiRequestServiceTest.php
  29. 1 2
      tests/Unit/Service/Security/InternalRequestsServiceTest.php
  30. 4 4
      tests/Unit/Service/Typo3/SubdomainServiceTest.php
  31. 1 2
      tests/Unit/Service/Utils/UrlBuilderTest.php

+ 8 - 6
src/ApiResources/Organization/OrganizationDeletionRequest.php

@@ -9,7 +9,7 @@ use App\State\Processor\Organization\OrganizationDeletionRequestProcessor;
 use Symfony\Component\Validator\Constraints as Assert;
 
 /**
- * Requête de création d'une nouvelle organisation
+ * Requête de création d'une nouvelle organisation.
  */
 #[ApiResource(
     operations: [
@@ -36,20 +36,17 @@ class OrganizationDeletionRequest
 
     /**
      * A quelle adresse email notifier la création de l'organisation, ou d'éventuelles erreurs ?
-     * @var string|null
      */
     #[Assert\Email(message: 'The email {{ value }} is not a valid email.')]
     private ?string $sendConfirmationEmailAt = null;
 
     /**
-     * Statut de l'opération
-     * @var string
+     * Statut de l'opération.
      */
     private string $status = self::STATUS_PENDING;
 
     /**
-     * For testing purposes only
-     * @var bool
+     * For testing purposes only.
      */
     private bool $async = true;
 
@@ -61,6 +58,7 @@ class OrganizationDeletionRequest
     public function setId(int $id): self
     {
         $this->id = $id;
+
         return $this;
     }
 
@@ -72,6 +70,7 @@ class OrganizationDeletionRequest
     public function setOrganizationId(int $organizationId): self
     {
         $this->organizationId = $organizationId;
+
         return $this;
     }
 
@@ -83,6 +82,7 @@ class OrganizationDeletionRequest
     public function setSendConfirmationEmailAt(?string $sendConfirmationEmailAt): self
     {
         $this->sendConfirmationEmailAt = $sendConfirmationEmailAt;
+
         return $this;
     }
 
@@ -94,6 +94,7 @@ class OrganizationDeletionRequest
     public function setStatus(string $status): self
     {
         $this->status = $status;
+
         return $this;
     }
 
@@ -105,6 +106,7 @@ class OrganizationDeletionRequest
     public function setAsync(bool $async): self
     {
         $this->async = $async;
+
         return $this;
     }
 }

+ 1 - 0
src/Entity/Access/Access.php

@@ -507,6 +507,7 @@ class Access implements UserInterface, PasswordAuthenticatedUserInterface
     public function setLoginEnabled(bool $loginEnabled): self
     {
         $this->loginEnabled = $loginEnabled;
+
         return $this;
     }
 

+ 5 - 2
src/Entity/Person/Person.php

@@ -48,7 +48,7 @@ class Person implements UserInterface, PasswordAuthenticatedUserInterface
     /**
      * @var array<mixed>|null
      */
-    #[ORM\Column(type: "array", nullable: true)]
+    #[ORM\Column(type: 'array', nullable: true)]
     private ?array $roles = [];
 
     #[ORM\Column(nullable: true)]
@@ -113,7 +113,7 @@ class Person implements UserInterface, PasswordAuthenticatedUserInterface
     private Collection $documentWishes;
 
     /** @var array<string, string> */
-    #[ORM\Column(type: "json", nullable: true)]
+    #[ORM\Column(type: 'json', nullable: true)]
     private array $confidentiality = [];
 
     #[Pure]
@@ -162,6 +162,7 @@ class Person implements UserInterface, PasswordAuthenticatedUserInterface
     public function setEnabled(bool $enabled): self
     {
         $this->enabled = $enabled;
+
         return $this;
     }
 
@@ -623,11 +624,13 @@ class Person implements UserInterface, PasswordAuthenticatedUserInterface
 
     /**
      * @param array<string, string> $confidentiality
+     *
      * @return $this
      */
     public function setConfidentiality(array $confidentiality): self
     {
         $this->confidentiality = $confidentiality;
+
         return $this;
     }
 }

+ 6 - 9
src/Message/Handler/OrganizationDeletionHandler.php

@@ -4,7 +4,6 @@ declare(strict_types=1);
 
 namespace App\Message\Handler;
 
-use App\Message\Message\OrganizationCreation;
 use App\Message\Message\OrganizationDeletion;
 use App\Service\Organization\OrganizationFactory;
 use Symfony\Component\Mailer\MailerInterface;
@@ -12,7 +11,6 @@ use Symfony\Component\Messenger\Attribute\AsMessageHandler;
 use Symfony\Component\Mime\Address;
 use Symfony\Component\Mime\Email as SymfonyEmail;
 use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
-use Throwable;
 
 #[AsMessageHandler(priority: 1)]
 class OrganizationDeletionHandler
@@ -20,11 +18,12 @@ class OrganizationDeletionHandler
     public function __construct(
         private readonly OrganizationFactory $organizationFactory,
         private readonly MailerInterface $symfonyMailer,
-        private readonly string $opentalentMailReport
-    ) {}
+        private readonly string $opentalentMailReport,
+    ) {
+    }
 
     /**
-     * @throws Throwable
+     * @throws \Throwable
      * @throws TransportExceptionInterface
      * @throws \Symfony\Component\Mailer\Exception\TransportExceptionInterface
      */
@@ -37,13 +36,11 @@ class OrganizationDeletionHandler
             $this->organizationFactory->delete($organizationCreationRequest);
 
             $mail['subject'] = 'Organization deleted';
-            $mail['content'] = 'The organization n° ' . $organizationCreationRequest->getOrganizationId() . ' has been deleted successfully.';
-
+            $mail['content'] = 'The organization n° '.$organizationCreationRequest->getOrganizationId().' has been deleted successfully.';
         } catch (\Exception $e) {
             $mail['subject'] = 'Organization deletion : an error occured';
-            $mail['content'] = 'An error occured while deleting the new organization : \n' . $e->getMessage();
+            $mail['content'] = 'An error occured while deleting the new organization : \n'.$e->getMessage();
             throw $e;
-
         } finally {
             if ($organizationCreationRequest->getSendConfirmationEmailAt() !== null) {
                 $symfonyMail = (new SymfonyEmail())

+ 2 - 1
src/Message/Message/OrganizationDeletion.php

@@ -12,7 +12,7 @@ use App\ApiResources\Organization\OrganizationDeletionRequest;
 class OrganizationDeletion
 {
     public function __construct(
-        private OrganizationDeletionRequest $organizationDeletionRequest
+        private OrganizationDeletionRequest $organizationDeletionRequest,
     ) {
     }
 
@@ -24,6 +24,7 @@ class OrganizationDeletion
     public function setOrganizationDeletionRequest(OrganizationDeletionRequest $organizationDeletionRequest): self
     {
         $this->organizationDeletionRequest = $organizationDeletionRequest;
+
         return $this;
     }
 }

+ 0 - 1
src/Service/Cron/Job/CleanTempFiles.php

@@ -10,7 +10,6 @@ use App\Service\Cron\BaseCronJob;
 use App\Service\File\Storage\LocalStorage;
 use App\Service\Utils\DatesUtils;
 use Doctrine\DBAL\Connection;
-use Doctrine\DBAL\ConnectionException;
 use Doctrine\ORM\QueryBuilder;
 use JetBrains\PhpStorm\Pure;
 

+ 2 - 8
src/Service/File/FileManager.php

@@ -144,10 +144,7 @@ class FileManager
 
     /**
      * Permanently delete the organization's files from each storage, and remove any reference
-     * in the DB
-     *
-     * @param int $organizationId
-     * @return void
+     * in the DB.
      */
     public function deleteOrganizationFiles(int $organizationId): void
     {
@@ -160,10 +157,7 @@ class FileManager
 
     /**
      * Permanently delete the person's files from each storage, and remove any reference
-     * * in the DB
- *
-     * @param int $personId
-     * @return void
+     * * in the DB.
      */
     public function deletePersonFiles(int $personId): void
     {

+ 2 - 8
src/Service/File/Storage/ApiLegacyStorage.php

@@ -58,10 +58,7 @@ class ApiLegacyStorage implements FileStorageInterface
     }
 
     /**
-     * Permanently delete the entire file storage of the given Organization
-     *
-     * @param int $organizationId
-     * @return void
+     * Permanently delete the entire file storage of the given Organization.
      */
     public function deleteOrganizationFiles(int $organizationId): void
     {
@@ -70,10 +67,7 @@ class ApiLegacyStorage implements FileStorageInterface
     }
 
     /**
-     * Permanently delete the entire file storage of the given Person
-     *
-     * @param int $personId
-     * @return void
+     * Permanently delete the entire file storage of the given Person.
      */
     public function deletePersonFiles(int $personId): void
     {

+ 17 - 25
src/Service/File/Storage/LocalStorage.php

@@ -47,15 +47,15 @@ class LocalStorage implements FileStorageInterface
     protected FilesystemInterface $filesystem;
 
     public function __construct(
-        protected readonly FilesystemMap          $filesystemMap,
+        protected readonly FilesystemMap $filesystemMap,
         protected readonly EntityManagerInterface $entityManager,
-        protected readonly AccessRepository       $accessRepository,
-        protected readonly DataManager            $dataManager,
-        protected readonly CacheManager           $cacheManager,
-        protected readonly ImageFactory           $imageFactory,
-        protected readonly FileUtils              $fileUtils,
-        protected readonly UrlBuilder             $urlBuilder,
-        protected readonly string                 $fileStorageDir
+        protected readonly AccessRepository $accessRepository,
+        protected readonly DataManager $dataManager,
+        protected readonly CacheManager $cacheManager,
+        protected readonly ImageFactory $imageFactory,
+        protected readonly FileUtils $fileUtils,
+        protected readonly UrlBuilder $urlBuilder,
+        protected readonly string $fileStorageDir,
     ) {
         $this->filesystem = $filesystemMap->get(static::FS_KEY);
     }
@@ -296,38 +296,30 @@ class LocalStorage implements FileStorageInterface
     }
 
     /**
-     * Permanently delete the entire file storage of the given Organization
-     *
-     * @param int $organizationId
-     * @return void
+     * Permanently delete the entire file storage of the given Organization.
      */
     public function deleteOrganizationFiles(int $organizationId): void
     {
-        $this->rrmDir('organization/' . $organizationId);
-        $this->rrmDir('temp/organization/' . $organizationId);
+        $this->rrmDir('organization/'.$organizationId);
+        $this->rrmDir('temp/organization/'.$organizationId);
     }
 
     /**
-     * Permanently delete the entire file storage of the given Person
-     *
-     * @param int $personId
-     * @return void
+     * Permanently delete the entire file storage of the given Person.
      */
     public function deletePersonFiles(int $personId): void
     {
-        $this->rrmDir('person/' . $personId);
-        $this->rrmDir('temp/person/' . $personId);
+        $this->rrmDir('person/'.$personId);
+        $this->rrmDir('temp/person/'.$personId);
     }
 
     /**
-     * Supprime récursivement un répertoire
+     * Supprime récursivement un répertoire.
      *
      * (Au moment du développement, Gaufrette ne permet pas la suppression de répertoires)
-     *
-     * @param string $dirKey
-     * @return void
      */
-    protected function rrmDir(string $dirKey): void {
+    protected function rrmDir(string $dirKey): void
+    {
         if (!$this->filesystem->isDirectory($dirKey)) {
             throw new \RuntimeException('Directory `'.$dirKey.'` does not exist');
         }

+ 5 - 5
src/Service/Organization/OrganizationFactory.php

@@ -38,8 +38,8 @@ use App\Service\Typo3\BindFileService;
 use App\Service\Typo3\SubdomainService;
 use App\Service\Typo3\Typo3Service;
 use App\Service\Utils\DatesUtils;
-use App\Service\Utils\UrlBuilder;
 use App\Service\Utils\SecurityUtils;
+use App\Service\Utils\UrlBuilder;
 use Doctrine\ORM\EntityManagerInterface;
 use Elastica\Param;
 use libphonenumber\NumberParseException;
@@ -759,7 +759,7 @@ class OrganizationFactory
     protected function updateAdminassosDb(Organization $organization): void
     {
         $response = $this->apiLegacyRequestService->get(
-            UrlBuilder::concatPath('/_internal/request/adminassos/create/organization/', [(string)$organization->getId()])
+            UrlBuilder::concatPath('/_internal/request/adminassos/create/organization/', [(string) $organization->getId()])
         );
 
         if ($response->getStatusCode() !== Response::HTTP_OK) {
@@ -798,7 +798,7 @@ class OrganizationFactory
 
         $organization = $this->organizationRepository->find($organizationDeletionRequest->getOrganizationId());
         if (!$organization) {
-            throw new \RuntimeException("No organization was found for id : " . $organizationDeletionRequest->getOrganizationId());
+            throw new \RuntimeException('No organization was found for id : '.$organizationDeletionRequest->getOrganizationId());
         }
 
         $this->logger->info(
@@ -862,7 +862,7 @@ class OrganizationFactory
             try {
                 $this->fileManager->deletePersonFiles($personId);
             } catch (\Exception $e) {
-                $this->logger->critical("An error happened while deleting the person's files, please proceed manually (id=" . $personId . ").");
+                $this->logger->critical("An error happened while deleting the person's files, please proceed manually (id=".$personId.').');
                 $this->logger->debug($e);
                 $withError = true;
             }
@@ -882,7 +882,6 @@ class OrganizationFactory
      * Supprime tous les Access d'une organisation, ainsi que la Person
      * rattachée (si celle-ci n'est pas liée à d'autres Access).
      *
-     * @param Organization $organization
      * @return array<Person>
      */
     protected function getFutureOrphanPersons(Organization $organization): array
@@ -895,6 +894,7 @@ class OrganizationFactory
                 $orphans[] = $person;
             }
         }
+
         return $orphans;
     }
 

+ 1 - 3
src/Service/Organization/Utils.php

@@ -293,10 +293,8 @@ class Utils
     }
 
     /**
-     * Retourne le premier NetworkOrganization actif de la structure
+     * Retourne le premier NetworkOrganization actif de la structure.
      *
-     * @param Organization $organization
-     * @return NetworkOrganization|null
      * @throws \Exception
      */
     public function getActiveNetworkOrganization(Organization $organization): ?NetworkOrganization

+ 8 - 12
src/Service/Rest/ApiRequestInterface.php

@@ -47,28 +47,24 @@ interface ApiRequestInterface
     /**
      * Sends a POST request and returns the response.
      *
-     * @param string $path
-     * @param array<mixed>| string $body
-     * @param array<mixed> $parameters
-     * @param array<mixed> $options
+     * @param array<mixed>|string $body
+     * @param array<mixed>        $parameters
+     * @param array<mixed>        $options
      *
-     * @return ResponseInterface
      * @throws HttpException
      */
-    public function post(string $path, array | string $body, array $parameters = [], array $options = []): ResponseInterface;
+    public function post(string $path, array|string $body, array $parameters = [], array $options = []): ResponseInterface;
 
     /**
      * Sends a PUT request and returns the response.
      *
-     * @param string $path
-     * @param array<mixed> | string $body
-     * @param array<mixed> $parameters
-     * @param array<mixed> $options
+     * @param array<mixed>|string $body
+     * @param array<mixed>        $parameters
+     * @param array<mixed>        $options
      *
-     * @return ResponseInterface
      * @throws HttpException
      */
-    public function put(string $path, array | string $body, array $parameters = [], array $options = []): ResponseInterface;
+    public function put(string $path, array|string $body, array $parameters = [], array $options = []): ResponseInterface;
 
     /**
      * Sends a DELETE request and returns the response.

+ 13 - 9
src/Service/Rest/ApiRequestService.php

@@ -72,15 +72,17 @@ class ApiRequestService implements ApiRequestInterface
     }
 
     /**
-     * Complète les options en y ajoutant le body
+     * Complète les options en y ajoutant le body.
      *
-     * @param array<mixed> $options
+     * @param array<mixed>        $options
      * @param array<mixed>|string $body
+     *
      * @return array<mixed>
      */
-    protected function addBodyOption(array $options, array | string $body): array
+    protected function addBodyOption(array $options, array|string $body): array
     {
         $option = is_array($body) ? ['json' => $body] : ['body' => $body];
+
         return array_merge($options, $option);
     }
 
@@ -88,14 +90,15 @@ class ApiRequestService implements ApiRequestInterface
      * Sends a POST request and returns the response.
      *
      * @param array<mixed>|string $body
-     * @param array<mixed> $parameters
-     * @param array<mixed> $options
+     * @param array<mixed>        $parameters
+     * @param array<mixed>        $options
      *
      * @throws HttpException
      */
-    public function post(string $path, array | string $body, array $parameters = [], array $options = []): ResponseInterface
+    public function post(string $path, array|string $body, array $parameters = [], array $options = []): ResponseInterface
     {
         $options = $this->addBodyOption($options, $body);
+
         return $this->request('POST', $path, $parameters, $options);
     }
 
@@ -103,14 +106,15 @@ class ApiRequestService implements ApiRequestInterface
      * Sends a PUT request and returns the response.
      *
      * @param array<mixed>|string $body
-     * @param array<mixed> $parameters
-     * @param array<mixed> $options
+     * @param array<mixed>        $parameters
+     * @param array<mixed>        $options
      *
      * @throws HttpException
      */
-    public function put(string $path, array | string $body, array $parameters = [], array $options = []): ResponseInterface
+    public function put(string $path, array|string $body, array $parameters = [], array $options = []): ResponseInterface
     {
         $options = $this->addBodyOption($options, $body);
+
         return $this->request('PUT', $path, $parameters, $options);
     }
 

+ 2 - 1
src/Service/Security/InternalRequestsService.php

@@ -26,7 +26,7 @@ class InternalRequestsService
 
     public function __construct(
         readonly private string $internalRequestsToken,
-        private Security $security
+        private Security $security,
     ) {
     }
 
@@ -60,6 +60,7 @@ class InternalRequestsService
         if (!$user instanceof UserInterface) {
             return false;
         }
+
         return $user->getSuperAdminAccess();
     }
 

+ 1 - 1
src/Service/Typo3/Typo3Service.php

@@ -26,7 +26,7 @@ class Typo3Service
      *
      * @throws TransportExceptionInterface
      */
-    protected function sendCommand(string $route, array $parameters, array $headers=[]): ResponseInterface
+    protected function sendCommand(string $route, array $parameters, array $headers = []): ResponseInterface
     {
         $url = UrlBuilder::concat(
             '/typo3',

+ 1 - 0
src/Service/Utils/UrlBuilder.php

@@ -25,6 +25,7 @@ class UrlBuilder
         foreach ($tails as $tail) {
             $url = rtrim($url, '/').'/'.ltrim(strval($tail), '/');
         }
+
         return $url;
     }
 

+ 1 - 1
src/State/Processor/Export/LicenceCmf/ExportRequestProcessor.php

@@ -10,11 +10,11 @@ use ApiPlatform\State\ProcessorInterface;
 use App\ApiResources\Export\ExportRequest;
 use App\Entity\Access\Access;
 use App\Message\Message\Export;
+use App\Service\Network\Utils as NetworkUtils;
 use App\Service\ServiceIterator\ExporterIterator;
 use Symfony\Bundle\SecurityBundle\Security;
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\Messenger\MessageBusInterface;
-use App\Service\Network\Utils as NetworkUtils;
 
 class ExportRequestProcessor implements ProcessorInterface
 {

+ 3 - 3
src/State/Processor/Organization/OrganizationCreationRequestProcessor.php

@@ -4,11 +4,11 @@ declare(strict_types=1);
 
 namespace App\State\Processor\Organization;
 
-use App\Entity\Access\Access;
 use ApiPlatform\Metadata\Operation;
 use ApiPlatform\Metadata\Post;
 use ApiPlatform\State\ProcessorInterface;
 use App\ApiResources\Organization\OrganizationCreationRequest;
+use App\Entity\Access\Access;
 use App\Message\Message\OrganizationCreation;
 use App\Service\Organization\OrganizationFactory;
 use App\Service\Utils\DatesUtils;
@@ -27,8 +27,8 @@ class OrganizationCreationRequestProcessor implements ProcessorInterface
 
     /**
      * @param OrganizationCreationRequest $data
-     * @param mixed[]       $uriVariables
-     * @param mixed[]       $context
+     * @param mixed[]                     $uriVariables
+     * @param mixed[]                     $context
      *
      * @throws \Exception
      */

+ 5 - 6
src/State/Processor/Organization/OrganizationDeletionRequestProcessor.php

@@ -4,13 +4,10 @@ declare(strict_types=1);
 
 namespace App\State\Processor\Organization;
 
-use ApiPlatform\Metadata\Delete;
 use ApiPlatform\Metadata\Operation;
 use ApiPlatform\Metadata\Post;
 use ApiPlatform\State\ProcessorInterface;
-use App\ApiResources\Organization\OrganizationCreationRequest;
 use App\ApiResources\Organization\OrganizationDeletionRequest;
-use App\Message\Message\OrganizationCreation;
 use App\Message\Message\OrganizationDeletion;
 use App\Service\Organization\OrganizationFactory;
 use Symfony\Component\HttpFoundation\Response;
@@ -21,12 +18,13 @@ class OrganizationDeletionRequestProcessor implements ProcessorInterface
     public function __construct(
         private readonly MessageBusInterface $messageBus,
         private readonly OrganizationFactory $organizationFactory,
-    ) {}
+    ) {
+    }
 
     /**
      * @param OrganizationDeletionRequest $data
-     * @param mixed[]       $uriVariables
-     * @param mixed[]       $context
+     * @param mixed[]                     $uriVariables
+     * @param mixed[]                     $context
      *
      * @throws \Exception
      */
@@ -50,6 +48,7 @@ class OrganizationDeletionRequestProcessor implements ProcessorInterface
             // For testing purposes only
             $this->organizationFactory->delete($organizationDeletionRequest);
         }
+
         return $organizationDeletionRequest;
     }
 }

+ 42 - 31
tests/Unit/Service/Cron/Job/CleanDbTest.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace App\Tests\Unit\Service\Cron\Job;
@@ -12,25 +13,29 @@ use PHPUnit\Framework\MockObject\MockObject;
 use PHPUnit\Framework\TestCase;
 use Psr\Log\LoggerInterface;
 
-class TestableCleanDb extends CleanDb {
-    public function purgeDb(bool $commit = true): void {
+class TestableCleanDb extends CleanDb
+{
+    public function purgeDb(bool $commit = true): void
+    {
         parent::purgeDb($commit);
     }
 
-    public function purgeAuditTables(\DateTime $maxDate): int {
+    public function purgeAuditTables(\DateTime $maxDate): int
+    {
         return parent::purgeAuditTables($maxDate);
     }
 
-    public function purgeMessages(\DateTime $maxDate): int {
+    public function purgeMessages(\DateTime $maxDate): int
+    {
         return parent::purgeMessages($maxDate);
     }
 
-    public function purgeNotifications(\DateTime $maxDate): int {
+    public function purgeNotifications(\DateTime $maxDate): int
+    {
         return parent::purgeNotifications($maxDate);
     }
 }
 
-
 class CleanDbTest extends TestCase
 {
     private CronUIInterface|MockObject $ui;
@@ -45,7 +50,8 @@ class CleanDbTest extends TestCase
         $this->connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock();
     }
 
-    private function getMockFor(string $method): MockObject | TestableCleanDb {
+    private function getMockFor(string $method): MockObject|TestableCleanDb
+    {
         $cleanDb = $this->getMockBuilder(TestableCleanDb::class)
             ->setConstructorArgs([$this->connection])
             ->setMethodsExcept([$method, 'setUI', 'setLoggerInterface'])
@@ -74,7 +80,8 @@ class CleanDbTest extends TestCase
         $cleanDb->execute();
     }
 
-    public function testPurgeDb(): void {
+    public function testPurgeDb(): void
+    {
         DatesUtils::setFakeDatetime('2022-01-08 00:00:00');
 
         $maxDate = DatesUtils::new();
@@ -85,7 +92,6 @@ class CleanDbTest extends TestCase
 
         $cleanDb = $this->getMockFor('purgeDb');
 
-
         $this->connection->expects($this->once())->method('beginTransaction');
         $this->connection->expects($this->once())->method('setAutoCommit')->with(false);
         $this->connection->expects($this->once())->method('commit');
@@ -100,7 +106,8 @@ class CleanDbTest extends TestCase
         $cleanDb->purgeDb();
     }
 
-    public function testPurgeDbNoCommit(): void {
+    public function testPurgeDbNoCommit(): void
+    {
         DatesUtils::setFakeDatetime('2022-01-08 00:00:00');
 
         $maxDate = DatesUtils::new();
@@ -125,7 +132,8 @@ class CleanDbTest extends TestCase
         $cleanDb->purgeDb(false);
     }
 
-    public function testPurgeDbWithError(): void {
+    public function testPurgeDbWithError(): void
+    {
         DatesUtils::setFakeDatetime('2022-01-08 00:00:00');
 
         $maxDate = DatesUtils::new();
@@ -148,7 +156,8 @@ class CleanDbTest extends TestCase
         $cleanDb->purgeDb(false);
     }
 
-    public function testPurgeAuditTables(): void {
+    public function testPurgeAuditTables(): void
+    {
         $maxDateAudit = DatesUtils::new('2022-06-30 00:00:00');
         $maxDateAudit->sub(new \DateInterval('P180D'));
 
@@ -172,19 +181,19 @@ class CleanDbTest extends TestCase
             ->method('prepare')
             ->willReturnMap([
                 [
-                    "DELETE a, r 
+                    'DELETE a, r 
                      FROM opentalent.Audit_table1 a
                      INNER JOIN opentalent.revisions r ON r.id = a.rev
-                     WHERE r.timestamp < :maxDate;",
-                    $stmt1
+                     WHERE r.timestamp < :maxDate;',
+                    $stmt1,
                 ],
                 [
-                    "DELETE a, r 
+                    'DELETE a, r 
                      FROM opentalent.Audit_table2 a
                      INNER JOIN opentalent.revisions r ON r.id = a.rev
-                     WHERE r.timestamp < :maxDate;",
-                    $stmt2
-                ]
+                     WHERE r.timestamp < :maxDate;',
+                    $stmt2,
+                ],
             ]);
 
         $stmt1
@@ -202,7 +211,8 @@ class CleanDbTest extends TestCase
         $this->assertEquals(200, $cleanDb->purgeAuditTables($maxDateAudit));
     }
 
-    public function testPurgeMessages(): void {
+    public function testPurgeMessages(): void
+    {
         $maxDate = DatesUtils::new('2022-03-02');
         $maxDate->sub(new \DateInterval('P60D'));
 
@@ -216,18 +226,18 @@ class CleanDbTest extends TestCase
             ->method('prepare')
             ->willReturnMap([
                 [
-                    "DELETE r
+                    'DELETE r
                 FROM opentalent.Message m
                 inner join opentalent.ReportMessage r on r.message_id = m.id
-                where (m.dateSent < :maxDate or (m.dateSent is null and m.createDate < :maxDate)) and m.isSystem = true and m.id > 0;",
-                    $stmt1
+                where (m.dateSent < :maxDate or (m.dateSent is null and m.createDate < :maxDate)) and m.isSystem = true and m.id > 0;',
+                    $stmt1,
                 ],
                 [
-                    "DELETE
+                    'DELETE
                 FROM opentalent.Message
-                where (dateSent < :maxDate or (dateSent is null and createDate < :maxDate)) and isSystem = true and id > 0;",
-                    $stmt2
-                ]
+                where (dateSent < :maxDate or (dateSent is null and createDate < :maxDate)) and isSystem = true and id > 0;',
+                    $stmt2,
+                ],
             ]);
 
         $stmt1
@@ -245,7 +255,8 @@ class CleanDbTest extends TestCase
         $this->assertEquals(200, $cleanDb->purgeMessages($maxDate));
     }
 
-    public function testPurgeNotifications(): void {
+    public function testPurgeNotifications(): void
+    {
         $maxDate = DatesUtils::new('2022-03-02');
         $maxDate->sub(new \DateInterval('P60D'));
 
@@ -263,14 +274,14 @@ class CleanDbTest extends TestCase
                 FROM opentalent.Information i
                 inner join opentalent.NotificationUser u on u.notification_id = i.id
                 where i.createDate < :maxDate and i.discr = 'notification';",
-                    $stmt1
+                    $stmt1,
                 ],
                 [
                     "DELETE
                 FROM opentalent.Information
                 where createDate < :maxDate and discr = 'notification';",
-                    $stmt2
-                ]
+                    $stmt2,
+                ],
             ]);
 
         $stmt1

+ 19 - 15
tests/Unit/Service/Cron/Job/CleanTempFilesTest.php

@@ -55,7 +55,7 @@ class CleanTempFilesTest extends TestCase
         $this->storage = $this->getMockBuilder(LocalStorage::class)->disableOriginalConstructor()->getMock();
     }
 
-    private function getMockFor(string $method): MockObject | TestableCleanTempFile
+    private function getMockFor(string $method): MockObject|TestableCleanTempFile
     {
         $cleanTempFiles = $this->getMockBuilder(TestableCleanTempFile::class)
             ->setConstructorArgs([$this->connection, $this->fileRepository, $this->storage])
@@ -161,7 +161,8 @@ class CleanTempFilesTest extends TestCase
         $this->assertEquals([], $result);
     }
 
-    public function testDeleteFiles(): void {
+    public function testDeleteFiles(): void
+    {
         $cleanTempFiles = $this->getMockFor('deleteFiles');
 
         $file1 = $this->getMockBuilder(File::class)->getMock();
@@ -214,7 +215,8 @@ class CleanTempFilesTest extends TestCase
         $cleanTempFiles->deleteFiles($files);
     }
 
-    public function testDeleteFilesWithNonBlockingErrors(): void {
+    public function testDeleteFilesWithNonBlockingErrors(): void
+    {
         $cleanTempFiles = $this->getMockFor('deleteFiles');
 
         $file1 = $this->getMockBuilder(File::class)->getMock();
@@ -240,12 +242,12 @@ class CleanTempFilesTest extends TestCase
             ->expects(self::exactly(2))
             ->method('hardDelete')
             ->willReturnCallback(function ($file) {
-               switch ($file->getId()) {
-                   case 1:
-                       throw new \RuntimeException('Some error');
-                   case 2:
-                       throw new \InvalidArgumentException('Some other error');
-               }
+                switch ($file->getId()) {
+                    case 1:
+                        throw new \RuntimeException('Some error');
+                    case 2:
+                        throw new \InvalidArgumentException('Some other error');
+                }
             });
 
         $this->connection->expects($this->never())->method('commit');
@@ -268,7 +270,8 @@ class CleanTempFilesTest extends TestCase
         $cleanTempFiles->deleteFiles($files);
     }
 
-    public function testDeleteFilesWithBlockingError(): void {
+    public function testDeleteFilesWithBlockingError(): void
+    {
         $cleanTempFiles = $this->getMockFor('deleteFiles');
 
         $file1 = $this->getMockBuilder(File::class)->getMock();
@@ -291,10 +294,10 @@ class CleanTempFilesTest extends TestCase
             ->expects(self::exactly(1))
             ->method('hardDelete')
             ->willReturnCallback(function ($file) {
-               switch ($file->getId()) {
-                   case 1:
-                       throw new \Exception('Some unknown error');
-               }
+                switch ($file->getId()) {
+                    case 1:
+                        throw new \Exception('Some unknown error');
+                }
             });
 
         $this->connection->expects($this->never())->method('commit');
@@ -310,7 +313,8 @@ class CleanTempFilesTest extends TestCase
         $cleanTempFiles->deleteFiles($files);
     }
 
-    public function testGetQueryConditions(): void {
+    public function testGetQueryConditions(): void
+    {
         DatesUtils::setFakeDatetime('2022-01-08 00:00:00');
 
         $cleanTempFiles = $this->getMockFor('getQueryConditions');

+ 14 - 8
tests/Unit/Service/Doctrine/FiltersConfigurationServiceTest.php

@@ -19,12 +19,12 @@ class TestableFiltersConfigurationService extends FiltersConfigurationService
         return parent::getFilters();
     }
 
-    public function setPreviousTimeConstraintState(bool | null $value): void
+    public function setPreviousTimeConstraintState(?bool $value): void
     {
         $this->previousTimeConstraintState = $value;
     }
 
-    public function getPreviousTimeConstraintState(): bool | null
+    public function getPreviousTimeConstraintState(): ?bool
     {
         return $this->previousTimeConstraintState;
     }
@@ -98,7 +98,8 @@ class FiltersConfigurationServiceTest extends TestCase
         $filterConfigurationService->configureTimeConstraintFilters($accessId);
     }
 
-    public function testSuspendTimeConstraintFilters(): void {
+    public function testSuspendTimeConstraintFilters(): void
+    {
         $filterConfigurationService = $this->getSUTMockForMethod('suspendTimeConstraintFilters');
 
         $filterCollection = $this->getMockBuilder(FilterCollection::class)->disableOriginalConstructor()->getMock();
@@ -122,7 +123,8 @@ class FiltersConfigurationServiceTest extends TestCase
         );
     }
 
-    public function testSuspendTimeConstraintFiltersAlreadySuspended(): void {
+    public function testSuspendTimeConstraintFiltersAlreadySuspended(): void
+    {
         $filterConfigurationService = $this->getSUTMockForMethod('suspendTimeConstraintFilters');
 
         $filterConfigurationService->setPreviousTimeConstraintState(true);
@@ -133,7 +135,8 @@ class FiltersConfigurationServiceTest extends TestCase
         $filterConfigurationService->suspendTimeConstraintFilters();
     }
 
-    public function testSuspendTimeConstraintFiltersAlreadyDisabled(): void {
+    public function testSuspendTimeConstraintFiltersAlreadyDisabled(): void
+    {
         $filterConfigurationService = $this->getSUTMockForMethod('suspendTimeConstraintFilters');
 
         $filterCollection = $this->getMockBuilder(FilterCollection::class)->disableOriginalConstructor()->getMock();
@@ -150,7 +153,8 @@ class FiltersConfigurationServiceTest extends TestCase
         );
     }
 
-    public function testRestoreTimeConstraintFilters(): void {
+    public function testRestoreTimeConstraintFilters(): void
+    {
         $filterConfigurationService = $this->getSUTMockForMethod('restoreTimeConstraintFilters');
 
         $filterConfigurationService->setPreviousTimeConstraintState(true);
@@ -175,7 +179,8 @@ class FiltersConfigurationServiceTest extends TestCase
         );
     }
 
-    public function testRestoreTimeConstraintFiltersNotSuspended(): void {
+    public function testRestoreTimeConstraintFiltersNotSuspended(): void
+    {
         $filterConfigurationService = $this->getSUTMockForMethod('restoreTimeConstraintFilters');
 
         $this->expectException(\RuntimeException::class);
@@ -184,7 +189,8 @@ class FiltersConfigurationServiceTest extends TestCase
         $filterConfigurationService->restoreTimeConstraintFilters();
     }
 
-    public function testRestoreTimeConstraintFiltersNotEnabled(): void {
+    public function testRestoreTimeConstraintFiltersNotEnabled(): void
+    {
         $filterConfigurationService = $this->getSUTMockForMethod('restoreTimeConstraintFilters');
 
         $filterConfigurationService->setPreviousTimeConstraintState(true);

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

@@ -8,14 +8,11 @@ use ApiPlatform\Metadata\Get;
 use App\Entity\Access\Access;
 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\Repository\Core\FileRepository;
-use App\Service\File\Exception\FileNotFoundException;
 use App\Service\File\Factory\ImageFactory;
 use App\Service\File\FileManager;
-use App\Service\File\Storage\ApiLegacyStorage;
 use App\Service\File\Storage\FileStorageInterface;
 use App\Service\File\Storage\LocalStorage;
 use App\Service\ServiceIterator\StorageIterator;
@@ -55,7 +52,8 @@ class FileManagerTest extends TestCase
             ->getMock();
     }
 
-    public function testGetStorageFor(): void {
+    public function testGetStorageFor(): void
+    {
         $fileManager = $this->getFileManagerMockFor('getStorageFor');
 
         $file = $this->getMockBuilder(File::class)->getMock();

+ 9 - 7
tests/Unit/Service/File/Storage/ApiLegacyStorageTest.php

@@ -13,20 +13,21 @@ use PHPUnit\Framework\TestCase;
 
 class ApiLegacyStorageTest extends TestCase
 {
-    private ApiLegacyRequestService | MockObject $apiLegacyRequestService;
-    private ApiLegacyRequestService | MockObject $dataManager;
-    private ApiLegacyRequestService | MockObject $urlBuilder;
+    private ApiLegacyRequestService|MockObject $apiLegacyRequestService;
+    private ApiLegacyRequestService|MockObject $dataManager;
+    private ApiLegacyRequestService|MockObject $urlBuilder;
 
-    public function setUp(): void {
+    public function setUp(): void
+    {
         $this->apiLegacyRequestService = $this->getMockBuilder(ApiLegacyRequestService::class)
             ->disableOriginalConstructor()
             ->getMock();
         $this->dataManager = $this->getMockBuilder(DataManager::class)->disableOriginalConstructor()->getMock();
         $this->urlBuilder = $this->getMockBuilder(UrlBuilder::class)->disableOriginalConstructor()->getMock();
-
     }
 
-    public function getApiLegacyStorageMockFor(string $methodName): ApiLegacyStorage|MockObject {
+    public function getApiLegacyStorageMockFor(string $methodName): ApiLegacyStorage|MockObject
+    {
         return $this
             ->getMockBuilder(ApiLegacyStorage::class)
             ->setConstructorArgs([$this->apiLegacyRequestService, $this->dataManager, $this->urlBuilder, 'url', 'publicUrl'])
@@ -102,7 +103,8 @@ class ApiLegacyStorageTest extends TestCase
         );
     }
 
-    public function testSupport(): void {
+    public function testSupport(): void
+    {
         $apiLegacyStorage = $this->getApiLegacyStorageMockFor('support');
 
         $file1 = $this->getMockBuilder(File::class)->getMock();

+ 7 - 4
tests/Unit/Service/File/Storage/LocalStorageTest.php

@@ -40,7 +40,8 @@ class TestableLocalStorage extends LocalStorage
         return parent::getOrganizationAndPersonFromOwner($owner);
     }
 
-    public function getFilterFromSizeAndConfig(string $size, bool $configExist): string {
+    public function getFilterFromSizeAndConfig(string $size, bool $configExist): string
+    {
         return parent::getFilterFromSizeAndConfig($size, $configExist);
     }
 
@@ -89,7 +90,7 @@ class LocalStorageTest extends TestCase
                 $this->imageFactory,
                 $this->fileUtils,
                 $this->urlBuilder,
-                '/file/storage/dir/'
+                '/file/storage/dir/',
             ])
             ->setMethodsExcept([$methodName])
             ->getMock();
@@ -332,7 +333,8 @@ class LocalStorageTest extends TestCase
         );
     }
 
-    public function testGetFilterFromSizeAndConfig(): void {
+    public function testGetFilterFromSizeAndConfig(): void
+    {
         $fileStorage = $this->getMockForMethod('getFilterFromSizeAndConfig');
 
         $this->assertEquals(
@@ -770,7 +772,8 @@ class LocalStorageTest extends TestCase
         $fileStorage->deletePersonFiles(123);
     }
 
-    public function testSupport(): void {
+    public function testSupport(): void
+    {
         $apiLegacyStorage = $this->getMockForMethod('support');
 
         $file1 = $this->getMockBuilder(File::class)->getMock();

+ 2 - 2
tests/Unit/Service/Organization/OrganizationFactoryTest.php

@@ -228,7 +228,7 @@ class OrganizationFactoryTest extends TestCase
                     $this->organizationIdentificationRepository,
                     $this->apiLegacyRequestService,
                     $this->functionTypeRepository,
-                    $this->fileManager
+                    $this->fileManager,
                 ])
             ->setMethodsExcept(['setLoggerInterface', 'setPhoneNumberUtil', $methodName])
             ->getMock();
@@ -1923,6 +1923,7 @@ class OrganizationFactoryTest extends TestCase
             $organizationFactory->normalizeIdentificationField("C'est une phrase normalisée.")
         );
     }
+
     public function testDelete(): void
     {
         $organizationFactory = $this->getOrganizationFactoryMockFor('delete');
@@ -2109,7 +2110,6 @@ class OrganizationFactoryTest extends TestCase
             ->method('deleteOrganizationFiles')
             ->with(123)
             ->willThrowException(new \Exception('some error'));
-        ;
 
         $this->fileManager
             ->expects(self::exactly(3))

+ 0 - 1
tests/Unit/Service/Organization/UtilsTest.php

@@ -714,5 +714,4 @@ class UtilsTest extends TestCase
 
         $this->assertEquals(null, $result);
     }
-
 }

+ 2 - 4
tests/Unit/Service/Rest/ApiRequestServiceTest.php

@@ -9,15 +9,14 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
 use Symfony\Contracts\HttpClient\HttpClientInterface;
 use Symfony\Contracts\HttpClient\ResponseInterface;
 
-class TestableApiRequestService extends ApiRequestService {
+class TestableApiRequestService extends ApiRequestService
+{
     public function addBodyOption(array $options, array|string $body): array
     {
         return parent::addBodyOption($options, $body);
     }
 }
 
-
-
 class ApiRequestServiceTest extends TestCase
 {
     private HttpClientInterface $client;
@@ -146,7 +145,6 @@ class ApiRequestServiceTest extends TestCase
         );
     }
 
-
     public function testAddBodyOptionKeyExists()
     {
         $apiRequestService = $this->getMockBuilder(TestableApiRequestService::class)

+ 1 - 2
tests/Unit/Service/Security/InternalRequestsServiceTest.php

@@ -7,7 +7,6 @@ use App\Service\Security\InternalRequestsService;
 use PHPUnit\Framework\MockObject\MockObject;
 use PHPUnit\Framework\TestCase;
 use Symfony\Bundle\SecurityBundle\Security;
-use Symfony\Component\Security\Core\User\UserInterface;
 
 class TestableInternalRequestsService extends InternalRequestsService
 {
@@ -16,7 +15,7 @@ class TestableInternalRequestsService extends InternalRequestsService
         return parent::isInternalIp($clientIp);
     }
 
-    public function tokenIsValid(string|null $token): bool
+    public function tokenIsValid(?string $token): bool
     {
         return parent::tokenIsValid($token);
     }

+ 4 - 4
tests/Unit/Service/Typo3/SubdomainServiceTest.php

@@ -87,7 +87,8 @@ class SubdomainServiceTest extends TestCase
             ->getMock();
     }
 
-    public function testGetSubdomain(): void {
+    public function testGetSubdomain(): void
+    {
         $subdomainService = $this->makeSubdomainServiceMockFor('getSubdomain');
 
         $subdomain = $this->getMockBuilder(Subdomain::class)->getMock();
@@ -98,7 +99,6 @@ class SubdomainServiceTest extends TestCase
             $subdomain,
             $subdomainService->getSubdomain('abc')
         );
-
     }
 
     /**
@@ -402,8 +402,8 @@ class SubdomainServiceTest extends TestCase
         $subdomainService->expects(self::never())->method('updateTypo3Website');
         $subdomainService->expects(self::never())->method('sendConfirmationEmail');
 
-//        $parameters->expects(self::once())->method('setSubDomain')->with('sub');
-//        $parameters->expects(self::once())->method('setOtherWebsite')->with('https://sub.opentalent.fr');
+        //        $parameters->expects(self::once())->method('setSubDomain')->with('sub');
+        //        $parameters->expects(self::once())->method('setOtherWebsite')->with('https://sub.opentalent.fr');
 
         $this->expectException(\RuntimeException::class);
         $this->expectExceptionMessage('Can not activate a non-persisted subdomain');

+ 1 - 2
tests/Unit/Service/Utils/UrlBuilderTest.php

@@ -10,7 +10,7 @@ use PHPUnit\Framework\TestCase;
 
 class UrlBuilderTest extends TestCase
 {
-    private function getMockFor(string $methodName): UrlBuilder | MockObject
+    private function getMockFor(string $methodName): UrlBuilder|MockObject
     {
         return $this
             ->getMockBuilder(UrlBuilder::class)
@@ -19,7 +19,6 @@ class UrlBuilderTest extends TestCase
             ->getMock();
     }
 
-
     /**
      * @see UrlBuilder::concatPath()
      */