Browse Source

restore unit tests

Olivier Massot 3 years ago
parent
commit
21ddc30557
1 changed files with 41 additions and 142 deletions
  1. 41 142
      tests/Service/Dolibarr/DolibarrSyncServiceTest.php

+ 41 - 142
tests/Service/Dolibarr/DolibarrSyncServiceTest.php

@@ -99,6 +99,17 @@ class DolibarrSyncServiceTest extends TestCase
         $this->logger->method('error')->willReturnSelf();
         $this->logger->method('error')->willReturnSelf();
     }
     }
 
 
+    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])
+            ->setMethodsExcept([$method, 'setLoggerInterface'])
+            ->getMock();
+        $dolibarrSyncService->setLoggerInterface($this->logger);
+
+        return $dolibarrSyncService;
+    }
+
     /**
     /**
      * Full test of the scan method
      * Full test of the scan method
      *
      *
@@ -106,12 +117,7 @@ class DolibarrSyncServiceTest extends TestCase
      */
      */
     public function testScan(): void
     public function testScan(): void
     {
     {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['scan'])
-            ->getMock();
-
+        $dolibarrSyncService = $this->getMockForMethod('scan');
 
 
         // ----- Opentalent Organizations -----
         // ----- Opentalent Organizations -----
         $orgId1 = 10;
         $orgId1 = 10;
@@ -575,11 +581,7 @@ class DolibarrSyncServiceTest extends TestCase
      */
      */
     public function testExecute(): void
     public function testExecute(): void
     {
     {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['execute'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('execute');
 
 
         $progressionCallbackExpectedCalls = [[1, 3], [2, 3], [3, 3]];
         $progressionCallbackExpectedCalls = [[1, 3], [2, 3], [3, 3]];
 
 
@@ -622,11 +624,7 @@ class DolibarrSyncServiceTest extends TestCase
      * @see DolibarrSyncService::run()
      * @see DolibarrSyncService::run()
      */
      */
     public function testRun() {
     public function testRun() {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['run'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('run');
 
 
         $operations = ['operation1', 'operation2'];
         $operations = ['operation1', 'operation2'];
 
 
@@ -643,11 +641,7 @@ class DolibarrSyncServiceTest extends TestCase
      */
      */
     public function testGetDolibarrSocietiesIndex(): void
     public function testGetDolibarrSocietiesIndex(): void
     {
     {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['getDolibarrSocietiesIndex'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('getDolibarrSocietiesIndex');
 
 
         $this->dolibarrApiService
         $this->dolibarrApiService
             ->expects($this->once())
             ->expects($this->once())
@@ -685,11 +679,7 @@ class DolibarrSyncServiceTest extends TestCase
      */
      */
     public function testGetActiveMembersIndex(): void
     public function testGetActiveMembersIndex(): void
     {
     {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['getActiveMembersIndex'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('getActiveMembersIndex');
 
 
         $this->accessRepository
         $this->accessRepository
             ->expects($this->once())
             ->expects($this->once())
@@ -716,11 +706,7 @@ class DolibarrSyncServiceTest extends TestCase
      */
      */
     public function testFindDolibarrContactForById(): void
     public function testFindDolibarrContactForById(): void
     {
     {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['findDolibarrContactFor'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('findDolibarrContactFor');
 
 
         $contacts = [
         $contacts = [
             ['id' => 1, 'array_options' => ['options_2iopen_person_id' => 101]],
             ['id' => 1, 'array_options' => ['options_2iopen_person_id' => 101]],
@@ -740,11 +726,7 @@ class DolibarrSyncServiceTest extends TestCase
      */
      */
     public function testFindDolibarrContactForByName(): void
     public function testFindDolibarrContactForByName(): void
     {
     {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['findDolibarrContactFor'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('findDolibarrContactFor');
 
 
         $contacts = [
         $contacts = [
             ['id' => 1, 'firstname' => 'mister', 'lastname' => 'X', 'array_options' => ['options_2iopen_person_id' => null]],
             ['id' => 1, 'firstname' => 'mister', 'lastname' => 'X', 'array_options' => ['options_2iopen_person_id' => null]],
@@ -767,11 +749,7 @@ class DolibarrSyncServiceTest extends TestCase
      */
      */
     public function testFindDolibarrContactForByNameWithConflict(): void
     public function testFindDolibarrContactForByNameWithConflict(): void
     {
     {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['findDolibarrContactFor'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('findDolibarrContactFor');
 
 
         $contacts = [
         $contacts = [
             ['id' => 1, 'firstname' => 'mister', 'lastname' => 'X', 'array_options' => ['options_2iopen_person_id' => 1]],
             ['id' => 1, 'firstname' => 'mister', 'lastname' => 'X', 'array_options' => ['options_2iopen_person_id' => 1]],
@@ -795,11 +773,7 @@ class DolibarrSyncServiceTest extends TestCase
      */
      */
     public function testFindDolibarrContactNotFound(): void
     public function testFindDolibarrContactNotFound(): void
     {
     {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['findDolibarrContactFor'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('findDolibarrContactFor');
 
 
         $contacts = [
         $contacts = [
             ['id' => 1, 'firstname' => 'mister', 'lastname' => 'X', 'array_options' => ['options_2iopen_person_id' => 1]],
             ['id' => 1, 'firstname' => 'mister', 'lastname' => 'X', 'array_options' => ['options_2iopen_person_id' => 1]],
@@ -822,11 +796,7 @@ class DolibarrSyncServiceTest extends TestCase
      */
      */
     public function testSanitizeDolibarrData(): void
     public function testSanitizeDolibarrData(): void
     {
     {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['sanitizeDolibarrData'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('sanitizeDolibarrData');
 
 
         $result = $dolibarrSyncService->sanitizeDolibarrData(['a' => 'A', 'b' => '', 'c' => ['d' => 'D', 'e' => '']]);
         $result = $dolibarrSyncService->sanitizeDolibarrData(['a' => 'A', 'b' => '', 'c' => ['d' => 'D', 'e' => '']]);
 
 
@@ -841,11 +811,7 @@ class DolibarrSyncServiceTest extends TestCase
      */
      */
     public function testSanitizeDolibarrDataWithNull(): void
     public function testSanitizeDolibarrDataWithNull(): void
     {
     {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['sanitizeDolibarrData'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('sanitizeDolibarrData');
 
 
         $result = $dolibarrSyncService->sanitizeDolibarrData(null);
         $result = $dolibarrSyncService->sanitizeDolibarrData(null);
         $this->assertEquals(null, $result);
         $this->assertEquals(null, $result);
@@ -856,11 +822,7 @@ class DolibarrSyncServiceTest extends TestCase
      */
      */
     public function testGetOrganizationPostalAddress(): void
     public function testGetOrganizationPostalAddress(): void
     {
     {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['getOrganizationPostalAddress'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('getOrganizationPostalAddress');
 
 
         $organization = $this->getMockBuilder(Organization::class)->getMock();
         $organization = $this->getMockBuilder(Organization::class)->getMock();
         $organizationAddressPostal1 = $this->getMockBuilder(OrganizationAddressPostal::class)->getMock();
         $organizationAddressPostal1 = $this->getMockBuilder(OrganizationAddressPostal::class)->getMock();
@@ -891,11 +853,7 @@ class DolibarrSyncServiceTest extends TestCase
      */
      */
     public function testGetOrganizationPostalAddressNoResult(): void
     public function testGetOrganizationPostalAddressNoResult(): void
     {
     {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['getOrganizationPostalAddress'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('getOrganizationPostalAddress');
 
 
         $organization = $this->getMockBuilder(Organization::class)->getMock();
         $organization = $this->getMockBuilder(Organization::class)->getMock();
         $organization->expects($this->once())
         $organization->expects($this->once())
@@ -913,11 +871,7 @@ class DolibarrSyncServiceTest extends TestCase
      */
      */
     public function testGetOrganizationPhoneWithExistingPhone(): void
     public function testGetOrganizationPhoneWithExistingPhone(): void
     {
     {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['getOrganizationPhone'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('getOrganizationPhone');
 
 
         $contactPoint1 = $this->getMockBuilder(ContactPoint::class)->getMock();
         $contactPoint1 = $this->getMockBuilder(ContactPoint::class)->getMock();
         $contactPoint2 = $this->getMockBuilder(ContactPoint::class)->getMock();
         $contactPoint2 = $this->getMockBuilder(ContactPoint::class)->getMock();
@@ -949,12 +903,9 @@ class DolibarrSyncServiceTest extends TestCase
     /**
     /**
      * @see DolibarrSyncService::getOrganizationPhone()
      * @see DolibarrSyncService::getOrganizationPhone()
      */
      */
-    public function testGetOrganizationPhoneWithMobilePhone() {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['getOrganizationPhone'])
-            ->getMock();
+    public function testGetOrganizationPhoneWithMobilePhone()
+    {
+        $dolibarrSyncService = $this->getMockForMethod('getOrganizationPhone');
 
 
         $contactPoint1 = $this->getMockBuilder(ContactPoint::class)->getMock();
         $contactPoint1 = $this->getMockBuilder(ContactPoint::class)->getMock();
         $contactPoint2 = $this->getMockBuilder(ContactPoint::class)->getMock();
         $contactPoint2 = $this->getMockBuilder(ContactPoint::class)->getMock();
@@ -989,11 +940,7 @@ class DolibarrSyncServiceTest extends TestCase
      * @see DolibarrSyncService::getOrganizationPhone()
      * @see DolibarrSyncService::getOrganizationPhone()
      */
      */
     public function testGetOrganizationPhoneWithNoPhone() {
     public function testGetOrganizationPhoneWithNoPhone() {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['getOrganizationPhone'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('getOrganizationPhone');
 
 
         $organization = $this->getMockBuilder(Organization::class)->getMock();
         $organization = $this->getMockBuilder(Organization::class)->getMock();
         $organization
         $organization
@@ -1013,11 +960,7 @@ class DolibarrSyncServiceTest extends TestCase
      * @see DolibarrSyncService::getOrganizationEmail()
      * @see DolibarrSyncService::getOrganizationEmail()
      */
      */
     public function testGetOrganizationEmailWithExistingEmail() {
     public function testGetOrganizationEmailWithExistingEmail() {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['getOrganizationEmail'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('getOrganizationEmail');
 
 
         $contactPoint1 = $this->getMockBuilder(ContactPoint::class)->getMock();
         $contactPoint1 = $this->getMockBuilder(ContactPoint::class)->getMock();
         $contactPoint2 = $this->getMockBuilder(ContactPoint::class)->getMock();
         $contactPoint2 = $this->getMockBuilder(ContactPoint::class)->getMock();
@@ -1047,11 +990,7 @@ class DolibarrSyncServiceTest extends TestCase
      * @see DolibarrSyncService::getOrganizationEmail()
      * @see DolibarrSyncService::getOrganizationEmail()
      */
      */
     public function testGetOrganizationEmailWithNoEmail() {
     public function testGetOrganizationEmailWithNoEmail() {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['getOrganizationEmail'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('getOrganizationEmail');
 
 
         $organization = $this->getMockBuilder(Organization::class)->getMock();
         $organization = $this->getMockBuilder(Organization::class)->getMock();
         $organization
         $organization
@@ -1069,11 +1008,7 @@ class DolibarrSyncServiceTest extends TestCase
      * @see DolibarrSyncService::getOrganizationNetworkId()
      * @see DolibarrSyncService::getOrganizationNetworkId()
      */
      */
     public function testGetOrganizationNetworkId() {
     public function testGetOrganizationNetworkId() {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['getOrganizationNetworkId'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('getOrganizationNetworkId');
 
 
         $organization = $this->getMockBuilder(Organization::class)->getMock();
         $organization = $this->getMockBuilder(Organization::class)->getMock();
         $network = $this->getMockBuilder(Network::class)->getMock();
         $network = $this->getMockBuilder(Network::class)->getMock();
@@ -1092,11 +1027,7 @@ class DolibarrSyncServiceTest extends TestCase
      * @see DolibarrSyncService::getOrganizationNetworkId()
      * @see DolibarrSyncService::getOrganizationNetworkId()
      */
      */
     public function testGetOrganizationNetworkIdWithMultipleResult() {
     public function testGetOrganizationNetworkIdWithMultipleResult() {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['getOrganizationNetworkId'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('getOrganizationNetworkId');
 
 
         $network1 = $this->getMockBuilder(Network::class)->getMock();
         $network1 = $this->getMockBuilder(Network::class)->getMock();
         $network1->method('getId')->willReturn(3);
         $network1->method('getId')->willReturn(3);
@@ -1125,11 +1056,7 @@ class DolibarrSyncServiceTest extends TestCase
      * @see DolibarrSyncService::getOrganizationNetworkId()
      * @see DolibarrSyncService::getOrganizationNetworkId()
      */
      */
     public function testGetOrganizationNetworkIdWithNoResult() {
     public function testGetOrganizationNetworkIdWithNoResult() {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['getOrganizationNetworkId'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('getOrganizationNetworkId');
 
 
         $organization = $this->getMockBuilder(Organization::class)->getMock();
         $organization = $this->getMockBuilder(Organization::class)->getMock();
         $network = $this->getMockBuilder(Network::class)->getMock();
         $network = $this->getMockBuilder(Network::class)->getMock();
@@ -1149,11 +1076,7 @@ class DolibarrSyncServiceTest extends TestCase
      * @see DolibarrSyncService::countWithMission()
      * @see DolibarrSyncService::countWithMission()
      */
      */
     public function testCountWithMission() {
     public function testCountWithMission() {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['countWithMission'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('countWithMission');
 
 
         $members = [
         $members = [
             123 => [FunctionEnum::PRESIDENT()->getValue(), FunctionEnum::TEACHER()->getValue()],
             123 => [FunctionEnum::PRESIDENT()->getValue(), FunctionEnum::TEACHER()->getValue()],
@@ -1190,11 +1113,7 @@ class DolibarrSyncServiceTest extends TestCase
      * @see DolibarrSyncService::getPersonContact()
      * @see DolibarrSyncService::getPersonContact()
      */
      */
     public function testGetPersonContact() {
     public function testGetPersonContact() {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['getPersonContact'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('getPersonContact');
 
 
         $person = $this->getMockBuilder(Person::class)->getMock();
         $person = $this->getMockBuilder(Person::class)->getMock();
 
 
@@ -1224,11 +1143,7 @@ class DolibarrSyncServiceTest extends TestCase
      * @see DolibarrSyncService::formatContactPosition()
      * @see DolibarrSyncService::formatContactPosition()
      */
      */
     public function testFormatContactPosition() {
     public function testFormatContactPosition() {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['formatContactPosition'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('formatContactPosition');
 
 
         $this->translator->method('trans')->willReturnMap(
         $this->translator->method('trans')->willReturnMap(
             [
             [
@@ -1304,11 +1219,7 @@ class DolibarrSyncServiceTest extends TestCase
      * @see DolibarrSyncService::formatPhoneNumber()
      * @see DolibarrSyncService::formatPhoneNumber()
      */
      */
     public function testFormatPhoneNumber() {
     public function testFormatPhoneNumber() {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['formatPhoneNumber'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('formatPhoneNumber');
 
 
         $phoneUtil = PhoneNumberUtil::getInstance();
         $phoneUtil = PhoneNumberUtil::getInstance();
         $phoneNumber = $phoneUtil->parse('01 02 03 04 05', "FR");
         $phoneNumber = $phoneUtil->parse('01 02 03 04 05', "FR");
@@ -1322,11 +1233,7 @@ class DolibarrSyncServiceTest extends TestCase
      * @see DolibarrSyncService::validateResponse()
      * @see DolibarrSyncService::validateResponse()
      */
      */
     public function testValidateResponse(): void {
     public function testValidateResponse(): void {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['validateResponse'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('validateResponse');
 
 
         $response = $this->getMockBuilder(ResponseInterface::class)->getMock();
         $response = $this->getMockBuilder(ResponseInterface::class)->getMock();
         $response->method('toArray')->willReturn(['a' => 1]);
         $response->method('toArray')->willReturn(['a' => 1]);
@@ -1345,11 +1252,7 @@ class DolibarrSyncServiceTest extends TestCase
      * @see DolibarrSyncService::validateResponse()
      * @see DolibarrSyncService::validateResponse()
      */
      */
     public function testValidateResponseInvalid(): void {
     public function testValidateResponseInvalid(): void {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['validateResponse'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('validateResponse');
 
 
         $response = $this->getMockBuilder(ResponseInterface::class)->getMock();
         $response = $this->getMockBuilder(ResponseInterface::class)->getMock();
         $response->method('toArray')->willReturn(['a' => 1]);
         $response->method('toArray')->willReturn(['a' => 1]);
@@ -1375,11 +1278,7 @@ class DolibarrSyncServiceTest extends TestCase
      * @see DolibarrSyncService::validateResponse()
      * @see DolibarrSyncService::validateResponse()
      */
      */
     public function testValidateResponseRequestError(): void {
     public function testValidateResponseRequestError(): void {
-        $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
-            ->setConstructorArgs([$this->organizationRepository, $this->accessRepository, $this->functionTypeRepository,
-                $this->dolibarrApiService, $this->addressPostalUtils, $this->arrayUtils, $this->translator, $this->logger])
-            ->setMethodsExcept(['validateResponse'])
-            ->getMock();
+        $dolibarrSyncService = $this->getMockForMethod('validateResponse');
 
 
         $response = $this->getMockBuilder(ResponseInterface::class)->getMock();
         $response = $this->getMockBuilder(ResponseInterface::class)->getMock();
         $response->method('getInfo')->willReturnMap([
         $response->method('getInfo')->willReturnMap([