Explorar o código

rename all references to Api1 by ApiLegacy

Olivier Massot %!s(int64=3) %!d(string=hai) anos
pai
achega
a8f6a2a552

+ 1 - 1
.env.docker

@@ -11,7 +11,7 @@ CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)|local.admin.openta
 ###< nelmio/cors-bundle ###
 
 ###> api v1 ###
-API1_BASE_URL=http://nginx/
+API_LEG_BASE_URL=http://nginx/
 ###< files management ###
 
 ###> BlackFire configuration ###

+ 1 - 1
.env.preprod

@@ -11,7 +11,7 @@ CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)$
 ###< nelmio/cors-bundle ###
 
 ###> api v1 ###
-API1_BASE_URL=https://api.preprod.opentalent.fr/api
+API_LEG_BASE_URL=https://api.preprod.opentalent.fr/api
 ###< files management ###
 
 ###> typo3 client ###

+ 1 - 1
.env.prod

@@ -13,7 +13,7 @@ CORS_ALLOW_ORIGIN=^https?://(localhost|127\.0\.0\.1)(:[0-9]+)$
 ###< nelmio/cors-bundle ###
 
 ###> api v1 ###
-API1_BASE_URL=https://api.opentalent.fr/api
+API_LEG_BASE_URL=https://api.opentalent.fr/api
 ###< files management ###
 
 ###> BlackFire configuration ###

+ 1 - 1
.env.test

@@ -3,7 +3,7 @@ APP_DEBUG=1
 ###< symfony/framework-bundle ###
 
 ###> api v1 ###
-API1_BASE_URL=https://api.test.opentalent.fr/api
+API_LEG_BASE_URL=https://api.test.opentalent.fr/api
 ###< files management ###
 
 # define your env variables for the test env here

+ 2 - 2
config/packages/framework.yaml

@@ -36,5 +36,5 @@ framework:
                 base_uri: '%env(MOBYT_API_BASE_URI)%'
                 headers:
                     Content-Type: 'application/json'
-            api1_client:
-                base_uri: '%env(API1_BASE_URL)%'
+            apiLegacyClient:
+                base_uri: '%env(API_LEG_BASE_URL)%'

+ 1 - 1
config/services.yaml

@@ -9,7 +9,7 @@ services:
         autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
         bind:
             $opentalentConfig: '%kernel.project_dir%%env(OPENTALENT_CONFIG)%'
-            $api1BaseUrl: '%env(API1_BASE_URL)%'
+            $apiLegacyBaseUrl: '%env(API_LEG_BASE_URL)%'
             $internalFilesUploadUri: '%env(INTERNAL_FILES_DOWNLOAD_URI)%'
             $bindfileBufferFile: '%env(BIND_FILE_BUFFER_FILE)%'
             $contextAwareDataPersister: '@api_platform.doctrine.orm.data_persister'

+ 3 - 3
src/DataProvider/Core/DownloadRequestDataProvider.php

@@ -8,7 +8,7 @@ use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
 use App\ApiResources\DownloadRequest;
 use App\Enum\Core\FileStatusEnum;
 use App\Repository\Core\FileRepository;
-use App\Service\Storage\Api1Storage;
+use App\Service\Storage\ApiLegacyStorage;
 use App\Service\Storage\LocalStorage;
 use Symfony\Component\HttpFoundation\HeaderUtils;
 use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -22,7 +22,7 @@ final class DownloadRequestDataProvider implements ItemDataProviderInterface, Re
     public function __construct(
         private FileRepository $fileRepository,
         private LocalStorage   $localStorage,
-        private Api1Storage    $api1Storage
+        private ApiLegacyStorage $apiLegacyStorage
     )
     {}
 
@@ -42,7 +42,7 @@ final class DownloadRequestDataProvider implements ItemDataProviderInterface, Re
         }
 
         // Storage depends on the file's host :
-        $storage = $file->getHost() === 'ap2i' ? $this->localStorage : $this->api1Storage;
+        $storage = $file->getHost() === 'ap2i' ? $this->localStorage : $this->apiLegacyStorage;
 
         // Serves the file :
         // @see https://symfony.com/doc/current/components/http_foundation.html#serving-files

+ 4 - 4
src/Service/Api1/Api1RequestService.php → src/Service/ApiLegacy/ApiLegacyRequestService.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Service\Api1;
+namespace App\Service\ApiLegacy;
 
 use App\Service\Rest\ApiRequestService;
 use JetBrains\PhpStorm\Pure;
@@ -14,12 +14,12 @@ use Symfony\Contracts\HttpClient\ResponseInterface;
 /**
  * Service d'appel à l'API opentalent V1
  */
-class Api1RequestService extends ApiRequestService
+class ApiLegacyRequestService extends ApiRequestService
 {
     #[Pure]
-    public function __construct(HttpClientInterface $api1_client, private Security $security)
+    public function __construct(HttpClientInterface $apiLegacyClient, private Security $security)
     {
-        parent::__construct($api1_client);
+        parent::__construct($apiLegacyClient);
     }
 
     /** @noinspection PhpPossiblePolymorphicInvocationInspection */

+ 4 - 4
src/Service/Storage/Api1Storage.php → src/Service/Storage/ApiLegacyStorage.php

@@ -3,7 +3,7 @@
 namespace App\Service\Storage;
 
 use App\Entity\Core\File;
-use App\Service\Api1\Api1RequestService;
+use App\Service\ApiLegacy\ApiLegacyRequestService;
 use App\Service\Utils\UrlBuilder;
 use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
 use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
@@ -14,10 +14,10 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
 /**
  * Read and write files into the Opentalent API v1 storage
  */
-class Api1Storage implements FileStorageInterface
+class ApiLegacyStorage implements FileStorageInterface
 {
     public function __construct(
-        private Api1RequestService $api1RequestService
+        private ApiLegacyRequestService $apiLegacyRequestService
     ) {}
 
     /**
@@ -28,6 +28,6 @@ class Api1Storage implements FileStorageInterface
      */
     public function read(File $file): string
     {
-        return $this->api1RequestService->getContent('api/files/' . $file->getId() .'/download');
+        return $this->apiLegacyRequestService->getContent('api/files/' . $file->getId() .'/download');
     }
 }

+ 19 - 19
tests/Service/Api1/Api1RequestServiceTest.php → tests/Service/ApiLegacy/ApiLegacyRequestServiceTest.php

@@ -1,9 +1,9 @@
 <?php /** @noinspection DuplicatedCode */
 
-namespace App\Test\Service\Api1;
+namespace App\Test\Service\ApiLegacy;
 
 use App\Entity\Access\Access;
-use App\Service\Api1\Api1RequestService;
+use App\Service\ApiLegacy\ApiLegacyRequestService;
 use PHPUnit\Framework\TestCase;
 use Symfony\Component\HttpKernel\Exception\HttpException;
 use Symfony\Component\Security\Core\Authentication\Token\NullToken;
@@ -13,22 +13,22 @@ use Symfony\Component\Security\Core\Security;
 use Symfony\Contracts\HttpClient\HttpClientInterface;
 use Symfony\Contracts\HttpClient\ResponseInterface;
 
-class Api1RequestServiceTest extends TestCase
+class ApiLegacyRequestServiceTest extends TestCase
 {
-    private HttpClientInterface $api1_client;
+    private HttpClientInterface $apiLegacyClient;
     private Security $security;
 
     public function setUp(): void
     {
-        $this->api1_client = $this->getMockBuilder(HttpClientInterface::class)->disableOriginalConstructor()->getMock();
+        $this->apiLegacyClient = $this->getMockBuilder(HttpClientInterface::class)->disableOriginalConstructor()->getMock();
         $this->security = $this->getMockBuilder(Security::class)->disableOriginalConstructor()->getMock();
     }
 
     public function testRequest(): void
     {
         $api1RequestService = $this
-            ->getMockBuilder(Api1RequestService::class)
-            ->setConstructorArgs([$this->api1_client, $this->security])
+            ->getMockBuilder(ApiLegacyRequestService::class)
+            ->setConstructorArgs([$this->apiLegacyClient, $this->security])
             ->setMethodsExcept(['request'])
             ->getMock();
 
@@ -53,7 +53,7 @@ class Api1RequestServiceTest extends TestCase
 
         $response = $this->getMockBuilder(ResponseInterface::class)->disableOriginalConstructor()->getMock();
 
-        $this->api1_client
+        $this->apiLegacyClient
             ->expects(self::once())
             ->method('request')
             ->with('GET', 'an/url', ['headers' => $expectedHeaders])
@@ -70,8 +70,8 @@ class Api1RequestServiceTest extends TestCase
     public function testRequestNoToken(): void
     {
         $api1RequestService = $this
-            ->getMockBuilder(Api1RequestService::class)
-            ->setConstructorArgs([$this->api1_client, $this->security])
+            ->getMockBuilder(ApiLegacyRequestService::class)
+            ->setConstructorArgs([$this->apiLegacyClient, $this->security])
             ->setMethodsExcept(['request'])
             ->getMock();
 
@@ -86,8 +86,8 @@ class Api1RequestServiceTest extends TestCase
     public function testRequestNullToken(): void
     {
         $api1RequestService = $this
-            ->getMockBuilder(Api1RequestService::class)
-            ->setConstructorArgs([$this->api1_client, $this->security])
+            ->getMockBuilder(ApiLegacyRequestService::class)
+            ->setConstructorArgs([$this->apiLegacyClient, $this->security])
             ->setMethodsExcept(['request'])
             ->getMock();
 
@@ -104,8 +104,8 @@ class Api1RequestServiceTest extends TestCase
     public function testRequestInvalidToken(): void
     {
         $api1RequestService = $this
-            ->getMockBuilder(Api1RequestService::class)
-            ->setConstructorArgs([$this->api1_client, $this->security])
+            ->getMockBuilder(ApiLegacyRequestService::class)
+            ->setConstructorArgs([$this->apiLegacyClient, $this->security])
             ->setMethodsExcept(['request'])
             ->getMock();
 
@@ -123,8 +123,8 @@ class Api1RequestServiceTest extends TestCase
     public function testRequestSwitchUser(): void
     {
         $api1RequestService = $this
-            ->getMockBuilder(Api1RequestService::class)
-            ->setConstructorArgs([$this->api1_client, $this->security])
+            ->getMockBuilder(ApiLegacyRequestService::class)
+            ->setConstructorArgs([$this->apiLegacyClient, $this->security])
             ->setMethodsExcept(['request'])
             ->getMock();
 
@@ -157,7 +157,7 @@ class Api1RequestServiceTest extends TestCase
 
         $response = $this->getMockBuilder(ResponseInterface::class)->disableOriginalConstructor()->getMock();
 
-        $this->api1_client
+        $this->apiLegacyClient
             ->expects(self::once())
             ->method('request')
             ->with('GET', 'an/url', ['headers' => $expectedHeaders])
@@ -169,8 +169,8 @@ class Api1RequestServiceTest extends TestCase
     public function testRequestSwitchInvalidUser(): void
     {
         $api1RequestService = $this
-            ->getMockBuilder(Api1RequestService::class)
-            ->setConstructorArgs([$this->api1_client, $this->security])
+            ->getMockBuilder(ApiLegacyRequestService::class)
+            ->setConstructorArgs([$this->apiLegacyClient, $this->security])
             ->setMethodsExcept(['request'])
             ->getMock();
 

+ 6 - 0
tests/Service/Storage/ApiLegacyStorageTest.php

@@ -0,0 +1,6 @@
+<?php
+
+class ApiLegacyStorageTest extends \PHPUnit\Framework\TestCase
+{
+
+}

+ 1 - 1
tests/Service/Storage/FileStorageTest.php → tests/Service/Storage/LocalStorageTest.php

@@ -28,7 +28,7 @@ class TestableLocalStorage extends LocalStorage {
 }
 
 
-class FileStorageTest extends TestCase
+class LocalStorageTest extends TestCase
 {
     private FilesystemMap $filesystemMap;
     private EntityManagerInterface $entityManager;