|
|
@@ -17,6 +17,7 @@ use App\Enum\Access\RoleEnum;
|
|
|
use App\Enum\Core\ContactPointTypeEnum;
|
|
|
use App\Enum\Network\NetworkEnum;
|
|
|
use App\Enum\Organization\AddressPostalOrganizationTypeEnum;
|
|
|
+use App\Enum\Organization\LegalEnum;
|
|
|
use App\Enum\Organization\SettingsProductEnum;
|
|
|
use App\Repository\Access\AccessRepository;
|
|
|
use App\Repository\Access\FunctionTypeRepository;
|
|
|
@@ -53,6 +54,7 @@ class TestableDolibarrSyncService extends DolibarrSyncService {
|
|
|
public function getPersonContact(Person $person): ?ContactPoint { return parent::getPersonContact($person); }
|
|
|
public function formatContactPosition(array $missions, ?string $gender = 'X'): string { return parent::formatContactPosition($missions, $gender); }
|
|
|
public function formatPhoneNumber(PhoneNumber $phoneNumber): string { return parent::formatPhoneNumber($phoneNumber); }
|
|
|
+ public function getExpectedTagsFor(Organization $organization) { return parent::getExpectedTagsFor($organization); }
|
|
|
public function validateResponse(ResponseInterface $response, BaseRestOperation $operation): void { parent::validateResponse($response, $operation); }
|
|
|
}
|
|
|
|
|
|
@@ -133,7 +135,8 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
'email' => 'foo@bar.net',
|
|
|
'phone' => '0102030405',
|
|
|
'networkId' => NetworkEnum::CMF()->getValue(),
|
|
|
- 'product' => SettingsProductEnum::SCHOOL()->getValue()
|
|
|
+ 'product' => SettingsProductEnum::SCHOOL()->getValue(),
|
|
|
+ 'legalStatus' => LegalEnum::LOCAL_AUTHORITY()
|
|
|
];
|
|
|
|
|
|
$orgId2 = 20;
|
|
|
@@ -145,7 +148,8 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
'email' => null,
|
|
|
'phone' => null,
|
|
|
'networkId' => null,
|
|
|
- 'product' => SettingsProductEnum::ARTIST()->getValue()
|
|
|
+ 'product' => SettingsProductEnum::ARTIST()->getValue(),
|
|
|
+ 'legalStatus' => LegalEnum::ASSOCIATION_LAW_1901()
|
|
|
];
|
|
|
|
|
|
$orgId3 = 30;
|
|
|
@@ -485,6 +489,16 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
["Organization 30 not found in the Opentalent DB"],
|
|
|
);
|
|
|
|
|
|
+ // Tags
|
|
|
+ $this->dolibarrApiService->method('getSocietyTagsIds')->willReturnMap([
|
|
|
+ [$socId1, [1, 68]],
|
|
|
+ [$socId2, [3, 67]]
|
|
|
+ ]);
|
|
|
+ $dolibarrSyncService->method('getExpectedTagsFor')->willReturnMap([
|
|
|
+ [$organization1, [67]],
|
|
|
+ [$organization2, []]
|
|
|
+ ]);
|
|
|
+
|
|
|
// Expected progression callback triggers
|
|
|
$progressionCallbackExpectedCalls = [[1, 3], [2, 3], [3, 3]];
|
|
|
$progressionCallback = static function ($i, $total) use (&$progressionCallbackExpectedCalls) {
|
|
|
@@ -499,7 +513,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
|
|
|
$operations = $dolibarrSyncService->scan($progressionCallback);
|
|
|
|
|
|
- $this->assertCount(5, $operations);
|
|
|
+ $this->assertCount(8, $operations);
|
|
|
|
|
|
$this->assertEqualsCanonicalizing(
|
|
|
[
|
|
|
@@ -533,10 +547,27 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
);
|
|
|
|
|
|
$this->assertEqualsCanonicalizing(
|
|
|
- ['[PUT contacts/4]', 'statut : `1` => `0`'],
|
|
|
+ [
|
|
|
+ '[PUT contacts/4]',
|
|
|
+ 'statut : `1` => `0`'
|
|
|
+ ],
|
|
|
$operations[2]->getChangeLog()
|
|
|
);
|
|
|
|
|
|
+ $this->assertEqualsCanonicalizing(
|
|
|
+ [
|
|
|
+ '[DELETE /thirdparties/1/categories/68]'
|
|
|
+ ],
|
|
|
+ $operations[3]->getChangeLog()
|
|
|
+ );
|
|
|
+
|
|
|
+ $this->assertEqualsCanonicalizing(
|
|
|
+ [
|
|
|
+ '[POST /thirdparties/1/categories/67]'
|
|
|
+ ],
|
|
|
+ $operations[4]->getChangeLog()
|
|
|
+ );
|
|
|
+
|
|
|
$this->assertEqualsCanonicalizing(
|
|
|
[
|
|
|
'[PUT thirdparties/2]',
|
|
|
@@ -550,7 +581,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
'zip : (new) => ``',
|
|
|
'array_options.options_2iopeninfoopentalent : (new) => `Nombre d\'accès admin : 2`',
|
|
|
],
|
|
|
- $operations[3]->getChangeLog()
|
|
|
+ $operations[5]->getChangeLog()
|
|
|
);
|
|
|
|
|
|
$this->assertEqualsCanonicalizing(
|
|
|
@@ -567,7 +598,14 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
'array_options.options_2iopen_person_id : (new) => `200`',
|
|
|
'socid : (new) => `2`'
|
|
|
],
|
|
|
- $operations[4]->getChangeLog()
|
|
|
+ $operations[6]->getChangeLog()
|
|
|
+ );
|
|
|
+
|
|
|
+ $this->assertEqualsCanonicalizing(
|
|
|
+ [
|
|
|
+ '[DELETE /thirdparties/2/categories/67]'
|
|
|
+ ],
|
|
|
+ $operations[7]->getChangeLog()
|
|
|
);
|
|
|
|
|
|
$this->assertCount(0, $progressionCallbackExpectedCalls);
|
|
|
@@ -1229,6 +1267,63 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ public function testGetExpectedTagsFor()
|
|
|
+ {
|
|
|
+ $dolibarrSyncService = $this->getMockForMethod('getExpectedTagsFor');
|
|
|
+
|
|
|
+ $organization1 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
+ $organization1->method('getLegalStatus')->willReturn(LegalEnum::ASSOCIATION_LAW_1901()->getValue());
|
|
|
+ $settings1 = $this->getMockBuilder(Settings::class)->getMock();
|
|
|
+ $settings1->method('getProduct')->willReturn(SettingsProductEnum::SCHOOL()->getValue());
|
|
|
+ $organization1->method('getSettings')->willReturn($settings1);
|
|
|
+
|
|
|
+ $organization2 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
+ $organization2->method('getLegalStatus')->willReturn(LegalEnum::ASSOCIATION_LAW_1901()->getValue());
|
|
|
+ $settings2 = $this->getMockBuilder(Settings::class)->getMock();
|
|
|
+ $settings2->method('getProduct')->willReturn(SettingsProductEnum::SCHOOL_PREMIUM()->getValue());
|
|
|
+ $organization2->method('getSettings')->willReturn($settings2);
|
|
|
+
|
|
|
+ $organization3 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
+ $organization3->method('getLegalStatus')->willReturn(LegalEnum::LOCAL_AUTHORITY()->getValue());
|
|
|
+ $settings3 = $this->getMockBuilder(Settings::class)->getMock();
|
|
|
+ $settings3->method('getProduct')->willReturn(SettingsProductEnum::SCHOOL()->getValue());
|
|
|
+ $organization3->method('getSettings')->willReturn($settings3);
|
|
|
+
|
|
|
+ $organization4 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
+ $organization4->method('getLegalStatus')->willReturn(LegalEnum::LOCAL_AUTHORITY()->getValue());
|
|
|
+ $settings4 = $this->getMockBuilder(Settings::class)->getMock();
|
|
|
+ $settings4->method('getProduct')->willReturn(SettingsProductEnum::SCHOOL_PREMIUM()->getValue());
|
|
|
+ $organization4->method('getSettings')->willReturn($settings4);
|
|
|
+
|
|
|
+ $organization5 = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
+ $organization5->method('getLegalStatus')->willReturn(LegalEnum::LOCAL_AUTHORITY()->getValue());
|
|
|
+ $settings5 = $this->getMockBuilder(Settings::class)->getMock();
|
|
|
+ $settings5->method('getProduct')->willReturn(SettingsProductEnum::ARTIST()->getValue());
|
|
|
+ $organization5->method('getSettings')->willReturn($settings5);
|
|
|
+
|
|
|
+ $this->assertEquals(
|
|
|
+ $dolibarrSyncService->getExpectedTagsFor($organization1),
|
|
|
+ [67]
|
|
|
+ );
|
|
|
+ $this->assertEquals(
|
|
|
+ $dolibarrSyncService->getExpectedTagsFor($organization2),
|
|
|
+ [69]
|
|
|
+ );
|
|
|
+ $this->assertEquals(
|
|
|
+ $dolibarrSyncService->getExpectedTagsFor($organization3),
|
|
|
+ [68]
|
|
|
+ );
|
|
|
+ $this->assertEquals(
|
|
|
+ $dolibarrSyncService->getExpectedTagsFor($organization4),
|
|
|
+ [70]
|
|
|
+ );
|
|
|
+ $this->assertEquals(
|
|
|
+ $dolibarrSyncService->getExpectedTagsFor($organization5),
|
|
|
+ []
|
|
|
+ );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @see DolibarrSyncService::validateResponse()
|
|
|
*/
|