|
|
@@ -71,6 +71,11 @@ class TestableDolibarrSyncService extends DolibarrSyncService
|
|
|
return parent::getOrganizationPostalAddress($organization);
|
|
|
}
|
|
|
|
|
|
+ public function getOrganizationBillingPostalAddress(Organization $organization): ?AddressPostal
|
|
|
+ {
|
|
|
+ return parent::getOrganizationBillingPostalAddress($organization);
|
|
|
+ }
|
|
|
+
|
|
|
public function getOrganizationPhone(Organization $organization): ?string
|
|
|
{
|
|
|
return parent::getOrganizationPhone($organization);
|
|
|
@@ -194,6 +199,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
|
|
|
$organizationData1 = [
|
|
|
'fullAddress' => '1 Rue Azerty',
|
|
|
+ 'fullBillingAddress' => '2 Rue Ascii',
|
|
|
'addressOwner' => 'Mr Keyboard',
|
|
|
'postalCode' => '01110',
|
|
|
'city' => 'ByteCity',
|
|
|
@@ -338,7 +344,20 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
],
|
|
|
];
|
|
|
|
|
|
- $dolibarrSocietyContacts1 = [$contactData1, $obsoleteContactData, $obsoleteContactData2];
|
|
|
+ $billingContactData = [
|
|
|
+ 'id' => '5',
|
|
|
+ 'lastname' => 'Service facturation',
|
|
|
+ 'firstname' => null,
|
|
|
+ 'address' => '',
|
|
|
+ 'zip' => '',
|
|
|
+ 'town' => '',
|
|
|
+ 'statut' => '1',
|
|
|
+ 'array_options' => [
|
|
|
+ 'options_2iopen_person_id' => null,
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+
|
|
|
+ $dolibarrSocietyContacts1 = [$contactData1, $obsoleteContactData, $obsoleteContactData2, $billingContactData];
|
|
|
$dolibarrSocietyContacts2 = [];
|
|
|
|
|
|
// ----- Setup Mocks -----
|
|
|
@@ -402,24 +421,37 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
->method('sanitizeDolibarrData')
|
|
|
->willReturnCallback(function ($args) { return $args; });
|
|
|
|
|
|
- $addressPostal = $this->getMockBuilder(AddressPostal::class)->getMock();
|
|
|
+ $mainPostalAddress = $this->getMockBuilder(AddressPostal::class)->getMock();
|
|
|
+ $mainPostalAddress->method('getStreetAddress')->willReturn($organizationData1['fullAddress']);
|
|
|
+ $mainPostalAddress->method('getAddressOwner')->willReturn($organizationData1['addressOwner']);
|
|
|
+ $mainPostalAddress->method('getPostalCode')->willReturn($organizationData1['postalCode']);
|
|
|
+ $mainPostalAddress->method('getAddressCity')->willReturn($organizationData1['city']);
|
|
|
+
|
|
|
+ $billingPostalAddress = $this->getMockBuilder(AddressPostal::class)->getMock();
|
|
|
+ $billingPostalAddress->method('getStreetAddress')->willReturn($organizationData1['fullBillingAddress']);
|
|
|
+ $billingPostalAddress->method('getAddressOwner')->willReturn($organizationData1['addressOwner']);
|
|
|
+ $billingPostalAddress->method('getPostalCode')->willReturn($organizationData1['postalCode']);
|
|
|
+ $billingPostalAddress->method('getAddressCity')->willReturn($organizationData1['city']);
|
|
|
|
|
|
$dolibarrSyncService
|
|
|
->expects(self::exactly(2))
|
|
|
->method('getOrganizationPostalAddress')
|
|
|
->willReturnMap([
|
|
|
- [$organization1, $addressPostal],
|
|
|
+ [$organization1, $mainPostalAddress],
|
|
|
+ [$organization2, null],
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $dolibarrSyncService
|
|
|
+ ->expects(self::exactly(1))
|
|
|
+ ->method('getOrganizationBillingPostalAddress')
|
|
|
+ ->willReturnMap([
|
|
|
+ [$organization1, $billingPostalAddress],
|
|
|
[$organization2, null],
|
|
|
]);
|
|
|
|
|
|
$this->addressPostalUtils
|
|
|
->method('getFullStreetAddress')
|
|
|
- ->with($addressPostal)
|
|
|
- ->willReturn($organizationData1['fullAddress']);
|
|
|
-
|
|
|
- $addressPostal->method('getAddressOwner')->willReturn($organizationData1['addressOwner']);
|
|
|
- $addressPostal->method('getPostalCode')->willReturn($organizationData1['postalCode']);
|
|
|
- $addressPostal->method('getAddressCity')->willReturn($organizationData1['city']);
|
|
|
+ ->willReturnCallback(function ($a) { return $a->getStreetAddress(); });
|
|
|
|
|
|
$dolibarrSyncService
|
|
|
->expects(self::exactly(2))
|
|
|
@@ -471,7 +503,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
]);
|
|
|
|
|
|
$this->arrayUtils
|
|
|
- ->expects(self::exactly(3))
|
|
|
+ ->expects(self::exactly(4))
|
|
|
->method('getChanges')
|
|
|
->willReturnCallback(
|
|
|
function (array $initialArray, array $newArray, bool $recursive = false, ?callable $callback = null) {
|
|
|
@@ -583,7 +615,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
|
|
|
$operations = $dolibarrSyncService->scan($progressionCallback);
|
|
|
|
|
|
- $this->assertCount(8, $operations);
|
|
|
+ $this->assertCount(9, $operations);
|
|
|
|
|
|
$this->assertEqualsCanonicalizing(
|
|
|
[
|
|
|
@@ -626,18 +658,28 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
|
|
|
$this->assertEqualsCanonicalizing(
|
|
|
[
|
|
|
- '[DELETE /thirdparties/1/categories/68]',
|
|
|
+ '[PUT contacts/5]',
|
|
|
+ 'address : `` => `2 Rue Ascii`',
|
|
|
+ 'town : `` => `ByteCity`',
|
|
|
+ 'zip : `` => `01110`',
|
|
|
],
|
|
|
$operations[3]->getChangeLog()
|
|
|
);
|
|
|
|
|
|
$this->assertEqualsCanonicalizing(
|
|
|
[
|
|
|
- '[POST /thirdparties/1/categories/67]',
|
|
|
+ '[DELETE /thirdparties/1/categories/68]',
|
|
|
],
|
|
|
$operations[4]->getChangeLog()
|
|
|
);
|
|
|
|
|
|
+ $this->assertEqualsCanonicalizing(
|
|
|
+ [
|
|
|
+ '[POST /thirdparties/1/categories/67]',
|
|
|
+ ],
|
|
|
+ $operations[5]->getChangeLog()
|
|
|
+ );
|
|
|
+
|
|
|
$this->assertEqualsCanonicalizing(
|
|
|
[
|
|
|
'[PUT thirdparties/2]',
|
|
|
@@ -652,7 +694,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
'array_options.options_2iopen_software_opentalent : (new) => `Opentalent Artist`',
|
|
|
"array_options.options_2iopeninfoopentalent : (new) => `Nombre d'adhérents : 0\nNombre d'accès admin : 2`",
|
|
|
],
|
|
|
- $operations[5]->getChangeLog()
|
|
|
+ $operations[6]->getChangeLog()
|
|
|
);
|
|
|
|
|
|
$this->assertEqualsCanonicalizing(
|
|
|
@@ -669,14 +711,14 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
'array_options.options_2iopen_person_id : (new) => `200`',
|
|
|
'socid : (new) => `2`',
|
|
|
],
|
|
|
- $operations[6]->getChangeLog()
|
|
|
+ $operations[7]->getChangeLog()
|
|
|
);
|
|
|
|
|
|
$this->assertEqualsCanonicalizing(
|
|
|
[
|
|
|
'[DELETE /thirdparties/2/categories/67]',
|
|
|
],
|
|
|
- $operations[7]->getChangeLog()
|
|
|
+ $operations[8]->getChangeLog()
|
|
|
);
|
|
|
|
|
|
$this->assertCount(0, $progressionCallbackExpectedCalls);
|