Prechádzať zdrojové kódy

fix error on dolibarr switch client to prospect

Olivier Massot 10 mesiacov pred
rodič
commit
c6f16d855c

+ 4 - 2
src/ApiResources/Profile/AccessProfile.php

@@ -302,7 +302,8 @@ class AccessProfile implements ApiResourcesInterface
     }
 
     /**
-     * return required for PHP Stan
+     * return required for PHP Stan.
+     *
      * @return bool[]
      */
     public function getHistorical(): array
@@ -311,7 +312,8 @@ class AccessProfile implements ApiResourcesInterface
     }
 
     /**
-     * param require for PHP Stan
+     * param require for PHP Stan.
+     *
      * @param bool[] $historical
      *
      * @return $this

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

@@ -843,7 +843,7 @@ class OrganizationFactory
         }
 
         try {
-            $this->switchDolibarrSocietyToProspect($organization);
+            $this->switchDolibarrSocietyToProspect($organizationDeletionRequest->getOrganizationId());
         } catch (\Exception $e) {
             $this->logger->critical('An error happened while updating the Dolibarr society, please proceed manually.');
             $this->logger->debug($e);
@@ -903,8 +903,8 @@ class OrganizationFactory
         $this->typo3Service->hardDeleteSite($organizationId);
     }
 
-    protected function switchDolibarrSocietyToProspect(Organization $organization): void
+    protected function switchDolibarrSocietyToProspect(int $organizationId): void
     {
-        $this->dolibarrApiService->switchSocietyToProspect($organization->getId());
+        $this->dolibarrApiService->switchSocietyToProspect($organizationId);
     }
 }

+ 4 - 7
tests/Unit/Service/Organization/OrganizationFactoryTest.php

@@ -158,9 +158,9 @@ class TestableOrganizationFactory extends OrganizationFactory
         parent::deleteTypo3Website($organizationId);
     }
 
-    public function switchDolibarrSocietyToProspect(Organization $organization): void
+    public function switchDolibarrSocietyToProspect(int $organizationId): void
     {
-        parent::switchDolibarrSocietyToProspect($organization);
+        parent::switchDolibarrSocietyToProspect($organizationId);
     }
 
     public function getFutureOrphanPersons(Organization $organization): array
@@ -1971,7 +1971,7 @@ class OrganizationFactoryTest extends TestCase
         );
 
         $organizationFactory->expects(self::once())->method('deleteTypo3Website')->with(123);
-        $organizationFactory->expects(self::once())->method('switchDolibarrSocietyToProspect')->with($organization);
+        $organizationFactory->expects(self::once())->method('switchDolibarrSocietyToProspect')->with(123);
 
         $this->fileManager->expects(self::once())->method('deleteOrganizationFiles')->with(123);
 
@@ -2183,14 +2183,11 @@ class OrganizationFactoryTest extends TestCase
     {
         $organizationFactory = $this->getOrganizationFactoryMockFor('switchDolibarrSocietyToProspect');
 
-        $organization = $this->getMockBuilder(Organization::class)->getMock();
-        $organization->method('getId')->willReturn(123);
-
         $this->dolibarrApiService
             ->expects(self::once())
             ->method('switchSocietyToProspect')
             ->with(123);
 
-        $organizationFactory->switchDolibarrSocietyToProspect($organization);
+        $organizationFactory->switchDolibarrSocietyToProspect(123);
     }
 }