Преглед изворни кода

refactor resource creator services

Olivier Massot пре 3 година
родитељ
комит
40793c1790

+ 6 - 0
src/ApiResources/Public/FederationStructure.php

@@ -0,0 +1,6 @@
+<?php
+
+class FederationStructure
+{
+
+}

+ 2 - 2
src/DataProvider/Dolibarr/DolibarrAccountDataProvider.php

@@ -6,7 +6,7 @@ namespace App\DataProvider\Dolibarr;
 use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
 use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
 use App\ApiResources\Dolibarr\DolibarrAccount;
-use App\Service\Dolibarr\DolibarrAccountCreator;
+use App\Service\ApiResourceBuilder\Dolibarr\DolibarrAccountBuilder;
 
 /**
  * Custom provider pour les DolibarrAccounts récupérés via l'api dolibarr
@@ -16,7 +16,7 @@ final class DolibarrAccountDataProvider implements ItemDataProviderInterface, Re
 {
 
     public function __construct(
-        private DolibarrAccountCreator $dolibarrAccountCreator,
+        private DolibarrAccountBuilder $dolibarrAccountCreator,
     )
     {}
 

+ 2 - 2
src/DataProvider/Mobyt/MobytUserStatusDataProvider.php

@@ -6,7 +6,7 @@ namespace App\DataProvider\Mobyt;
 use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
 use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
 use App\ApiResources\Mobyt\MobytUserStatus;
-use App\Service\Mobyt\MobytUserStatusCreator;
+use App\Service\ApiResourceBuilder\Mobyt\MobytUserStatusBuilder;
 
 /**
  * Custom provider pour les MobytUserStatus récupérés via l'api Mobyt
@@ -15,7 +15,7 @@ use App\Service\Mobyt\MobytUserStatusCreator;
 final class MobytUserStatusDataProvider implements ItemDataProviderInterface, RestrictedDataProviderInterface
 {
     public function __construct(
-        private MobytUserStatusCreator $mobytUserStatusCreator,
+        private MobytUserStatusBuilder $mobytUserStatusCreator,
     )
     {}
 

+ 11 - 0
src/DataProvider/Public/FederationStructureDataProvider.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace App\DataProvider\Public;
+
+use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
+use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
+
+class FederationStructure implements ItemDataProviderInterface, RestrictedDataProviderInterface
+{
+
+}

+ 3 - 2
src/Service/Dolibarr/DolibarrAccountCreator.php → src/Service/ApiResourceBuilder/Dolibarr/DolibarrAccountBuilder.php

@@ -1,14 +1,15 @@
 <?php
 declare(strict_types=1);
 
-namespace App\Service\Dolibarr;
+namespace App\Service\ApiResourceBuilder\Dolibarr;
 
 use App\ApiResources\Dolibarr\DolibarrAccount;
 use App\ApiResources\Dolibarr\DolibarrBill;
 use App\ApiResources\Dolibarr\DolibarrContract;
 use App\ApiResources\Dolibarr\DolibarrContractLine;
+use App\Service\Dolibarr\DolibarrApiService;
 
-class DolibarrAccountCreator
+class DolibarrAccountBuilder
 {
     public const PRODUCT_MAPPING = [
         1 => 'PRODUCT_ARTIST',   # OT Artist

+ 3 - 2
src/Service/Mobyt/MobytUserStatusCreator.php → src/Service/ApiResourceBuilder/Mobyt/MobytUserStatusBuilder.php

@@ -1,11 +1,12 @@
 <?php
 
-namespace App\Service\Mobyt;
+namespace App\Service\ApiResourceBuilder\Mobyt;
 
 use App\ApiResources\Mobyt\MobytUserStatus;
 use App\Repository\Organization\OrganizationRepository;
+use App\Service\Mobyt\MobytService;
 
-class MobytUserStatusCreator
+class MobytUserStatusBuilder
 {
     public function __construct(
         private MobytService $mobytService,

+ 6 - 0
src/Service/ApiResourceBuilder/Public/FederationStructureBuilder.php

@@ -0,0 +1,6 @@
+<?php
+
+class FederationStructureBuilder
+{
+
+}

+ 1 - 1
src/Validator/Organization/Parameters/MobytCredentialsValidator.php

@@ -34,4 +34,4 @@ class MobytCredentialsValidator extends ConstraintValidator
                 ->addViolation();
         }
     }
-}
+}

+ 13 - 13
tests/Service/Dolibarr/DolibarrAccountCreatorTest.php

@@ -5,7 +5,7 @@ namespace App\Tests\Service\Dolibarr;
 use App\ApiResources\Dolibarr\DolibarrAccount;
 use App\ApiResources\Dolibarr\DolibarrBill;
 use App\ApiResources\Dolibarr\DolibarrContract;
-use App\Service\Dolibarr\DolibarrAccountCreator;
+use App\Service\ApiResourceBuilder\Dolibarr\DolibarrAccountBuilder;
 use App\Service\Dolibarr\DolibarrApiService;
 use PHPUnit\Framework\TestCase;
 
@@ -20,11 +20,11 @@ class DolibarrAccountCreatorTest extends TestCase
     }
 
     /**
-     * @see DolibarrAccountCreator::getDolibarrAccount()
+     * @see DolibarrAccountBuilder::getDolibarrAccount()
      */
     public function testGetDolibarrAccount(): void
     {
-        $dolibarrAccountCreator = $this->getMockBuilder(DolibarrAccountCreator::class)
+        $dolibarrAccountCreator = $this->getMockBuilder(DolibarrAccountBuilder::class)
             ->setConstructorArgs([$this->dolibarrApiService])
             ->setMethodsExcept(['getDolibarrAccount'])
             ->getMock();
@@ -83,11 +83,11 @@ class DolibarrAccountCreatorTest extends TestCase
     }
 
     /**
-     * @see DolibarrAccountCreator::createDolibarrAccount()
+     * @see DolibarrAccountBuilder::createDolibarrAccount()
      */
     public function testCreateDolibarrAccount(): void
     {
-        $dolibarrAccountCreator = $this->getMockBuilder(DolibarrAccountCreator::class)
+        $dolibarrAccountCreator = $this->getMockBuilder(DolibarrAccountBuilder::class)
             ->setConstructorArgs([$this->dolibarrApiService])
             ->setMethodsExcept(['createDolibarrAccount'])
             ->getMock();
@@ -104,11 +104,11 @@ class DolibarrAccountCreatorTest extends TestCase
     }
 
     /**
-     * @see DolibarrAccountCreator::createDolibarrAccount()
+     * @see DolibarrAccountBuilder::createDolibarrAccount()
      */
     public function testCreateDolibarrAccountWithProduct(): void
     {
-        $dolibarrAccountCreator = $this->getMockBuilder(DolibarrAccountCreator::class)
+        $dolibarrAccountCreator = $this->getMockBuilder(DolibarrAccountBuilder::class)
             ->setConstructorArgs([$this->dolibarrApiService])
             ->setMethodsExcept(['createDolibarrAccount'])
             ->getMock();
@@ -122,11 +122,11 @@ class DolibarrAccountCreatorTest extends TestCase
     }
 
     /**
-     * @see DolibarrAccountCreator::createDolibarrContract()
+     * @see DolibarrAccountBuilder::createDolibarrContract()
      */
     public function testCreateDolibarrContract(): void
     {
-        $dolibarrAccountCreator = $this->getMockBuilder(DolibarrAccountCreator::class)
+        $dolibarrAccountCreator = $this->getMockBuilder(DolibarrAccountBuilder::class)
             ->setConstructorArgs([$this->dolibarrApiService])
             ->setMethodsExcept(['createDolibarrContract'])
             ->getMock();
@@ -149,11 +149,11 @@ class DolibarrAccountCreatorTest extends TestCase
     }
 
     /**
-     * @see DolibarrAccountCreator::createDolibarrContractLine()
+     * @see DolibarrAccountBuilder::createDolibarrContractLine()
      */
     public function testCreateDolibarrContractLine(): void
     {
-        $dolibarrAccountCreator = $this->getMockBuilder(DolibarrAccountCreator::class)
+        $dolibarrAccountCreator = $this->getMockBuilder(DolibarrAccountBuilder::class)
             ->setConstructorArgs([$this->dolibarrApiService])
             ->setMethodsExcept(['createDolibarrContractLine'])
             ->getMock();
@@ -178,12 +178,12 @@ class DolibarrAccountCreatorTest extends TestCase
     }
 
     /**
-     * @see DolibarrAccountCreator::createDolibarrBill()
+     * @see DolibarrAccountBuilder::createDolibarrBill()
      */
     public function testCreateDolibarrBill(): void
     {
 
-        $dolibarrAccountCreator = $this->getMockBuilder(DolibarrAccountCreator::class)
+        $dolibarrAccountCreator = $this->getMockBuilder(DolibarrAccountBuilder::class)
             ->setConstructorArgs([$this->dolibarrApiService])
             ->setMethodsExcept(['createDolibarrBill'])
             ->getMock();

+ 2 - 2
tests/Service/Dolibarr/DolibarrSyncServiceTest.php

@@ -21,9 +21,9 @@ use App\Enum\Organization\SettingsProductEnum;
 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\Core\AddressPostalUtils;
 use App\Service\Rest\Operation\BaseRestOperation;
 use App\Service\Rest\Operation\CreateOperation;
 use App\Service\Rest\Operation\DeleteOperation;
@@ -36,9 +36,9 @@ use PHPUnit\Framework\MockObject\MockObject;
 use PHPUnit\Framework\TestCase;
 use Psr\Log\LoggerInterface;
 use RuntimeException;
+use Symfony\Component\HttpClient\Exception\ServerException;
 use Symfony\Contracts\HttpClient\ResponseInterface;
 use Symfony\Contracts\Translation\TranslatorInterface;
-use Symfony\Component\HttpClient\Exception\ServerException;
 
 class TestableDolibarrSyncService extends DolibarrSyncService {
     public function getDolibarrSocietiesIndex(): array { return parent::getDolibarrSocietiesIndex(); }

+ 7 - 7
tests/Service/Mobyt/MobytUserStatusCreatorTest.php

@@ -6,7 +6,7 @@ use App\Entity\Organization\Organization;
 use App\Entity\Organization\Parameters;
 use App\Repository\Organization\OrganizationRepository;
 use App\Service\Mobyt\MobytService;
-use App\Service\Mobyt\MobytUserStatusCreator;
+use App\Service\ApiResourceBuilder\Mobyt\MobytUserStatusBuilder;
 use PHPUnit\Framework\TestCase;
 
 class MobytUserStatusCreatorTest extends TestCase
@@ -25,11 +25,11 @@ class MobytUserStatusCreatorTest extends TestCase
     }
 
     /**
-     * @see MobytUserStatusCreator::getUserStatus()
+     * @see MobytUserStatusBuilder::getUserStatus()
      */
     public function testGetUserStatus(): void
     {
-        $mobytUserStatusCreator = $this->getMockBuilder(MobytUserStatusCreator::class)
+        $mobytUserStatusCreator = $this->getMockBuilder(MobytUserStatusBuilder::class)
             ->setConstructorArgs([$this->mobytService, $this->organizationRepository])
             ->setMethodsExcept(['getUserStatus'])
             ->getMock();
@@ -81,11 +81,11 @@ class MobytUserStatusCreatorTest extends TestCase
     }
 
     /**
-     * @see MobytUserStatusCreator::getUserStatus()
+     * @see MobytUserStatusBuilder::getUserStatus()
      */
     public function testGetUserStatusInvalidOrganization(): void
     {
-        $mobytUserStatusCreator = $this->getMockBuilder(MobytUserStatusCreator::class)
+        $mobytUserStatusCreator = $this->getMockBuilder(MobytUserStatusBuilder::class)
             ->setConstructorArgs([$this->mobytService, $this->organizationRepository])
             ->setMethodsExcept(['getUserStatus'])
             ->getMock();
@@ -105,11 +105,11 @@ class MobytUserStatusCreatorTest extends TestCase
     }
 
     /**
-     * @see MobytUserStatusCreator::getUserStatus()
+     * @see MobytUserStatusBuilder::getUserStatus()
      */
     public function testGetUserStatusMissingAuthInformation(): void
     {
-        $mobytUserStatusCreator = $this->getMockBuilder(MobytUserStatusCreator::class)
+        $mobytUserStatusCreator = $this->getMockBuilder(MobytUserStatusBuilder::class)
             ->setConstructorArgs([$this->mobytService, $this->organizationRepository])
             ->setMethodsExcept(['getUserStatus'])
             ->getMock();