|
|
@@ -41,6 +41,7 @@ class TestableDolibarrSyncService extends DolibarrSyncService {
|
|
|
public function getOrganizationPostalAddress(Organization $organization): ?AddressPostal { return parent::getOrganizationPostalAddress($organization); }
|
|
|
public function getOrganizationPhone(Organization $organization): ?string { return parent::getOrganizationPhone($organization); }
|
|
|
public function getOrganizationEmail(Organization $organization): ?string { return parent::getOrganizationEmail($organization); }
|
|
|
+ public function getOrganizationNetworkId(Organization $organization): ?int { return parent::getOrganizationNetworkId($organization); }
|
|
|
public static function countWithMission(array $missions, array $members): int { return parent::countWithMission($missions, $members); }
|
|
|
public function getPersonContact(Person $person): ?ContactPoint { return parent::getPersonContact($person); }
|
|
|
public function formatContactPosition(array $missions, ?string $gender = 'X'): string { return parent::formatContactPosition($missions, $gender); }
|
|
|
@@ -176,7 +177,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
|
|
|
// Network
|
|
|
$network = $this->getMockBuilder(Network::class)->getMock();
|
|
|
- $network->method('getId')->willReturn(91295);
|
|
|
+ $network->method('getId')->willReturn(3);
|
|
|
$networkOrganization = $this->getMockBuilder(NetworkOrganization::class)->getMock();
|
|
|
$networkOrganization->method('getNetwork')->willReturn($network);
|
|
|
$organization->method('getNetworkOrganizations')->willReturn(new ArrayCollection([$networkOrganization]));
|
|
|
@@ -278,7 +279,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
'town : `CLUSES` => `Londres`',
|
|
|
'email : `` => `email@email.com`',
|
|
|
'phone : `+33678403010` => `+33102030405`',
|
|
|
- 'parent : `` => `5086`',
|
|
|
+ 'parent : `` => `711`',
|
|
|
"array_options.options_2iopeninfoopentalent : `` => `Nombre d'élèves : 1\nNombre d'adhérents : 3\nNombre d'accès admin : 1`"
|
|
|
],
|
|
|
$operations[0]->getChangeLog()
|
|
|
@@ -613,6 +614,66 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ public function testGetOrganizationNetworkId() {
|
|
|
+ $organization = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
+ $network = $this->getMockBuilder(Network::class)->getMock();
|
|
|
+ $network->method('getId')->willReturn(3);
|
|
|
+ $networkOrganization = $this->getMockBuilder(NetworkOrganization::class)->getMock();
|
|
|
+ $networkOrganization->method('getNetwork')->willReturn($network);
|
|
|
+ $organization->method('getNetworkOrganizations')->willReturn(new ArrayCollection([$networkOrganization]));
|
|
|
+
|
|
|
+ $syncService = $this->newDolibarrSyncService();
|
|
|
+
|
|
|
+ $this->assertEquals(
|
|
|
+ 3,
|
|
|
+ $syncService->getOrganizationNetworkId($organization)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testGetOrganizationNetworkIdWithMultipleResult() {
|
|
|
+ $organization = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
+
|
|
|
+ $network1 = $this->getMockBuilder(Network::class)->getMock();
|
|
|
+ $network1->method('getId')->willReturn(3);
|
|
|
+ $networkOrganization1 = $this->getMockBuilder(NetworkOrganization::class)->getMock();
|
|
|
+ $networkOrganization1->method('getNetwork')->willReturn($network1);
|
|
|
+ $networkOrganization1->method('getEndDate')->willReturn(new \DateTime('2000-01-01'));
|
|
|
+
|
|
|
+ $network2 = $this->getMockBuilder(Network::class)->getMock();
|
|
|
+ $network2->method('getId')->willReturn(4);
|
|
|
+ $networkOrganization2 = $this->getMockBuilder(NetworkOrganization::class)->getMock();
|
|
|
+ $networkOrganization2->method('getNetwork')->willReturn($network2);
|
|
|
+ $networkOrganization2->method('getEndDate')->willReturn(null);
|
|
|
+
|
|
|
+ $organization->method('getNetworkOrganizations')->willReturn(
|
|
|
+ new ArrayCollection([$networkOrganization1, $networkOrganization2])
|
|
|
+ );
|
|
|
+
|
|
|
+ $syncService = $this->newDolibarrSyncService();
|
|
|
+
|
|
|
+ $this->assertEquals(
|
|
|
+ 4,
|
|
|
+ $syncService->getOrganizationNetworkId($organization)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testGetOrganizationNetworkIdWithNoResult() {
|
|
|
+ $organization = $this->getMockBuilder(Organization::class)->getMock();
|
|
|
+ $network = $this->getMockBuilder(Network::class)->getMock();
|
|
|
+ $network->method('getId')->willReturn(3);
|
|
|
+ $networkOrganization = $this->getMockBuilder(NetworkOrganization::class)->getMock();
|
|
|
+ $networkOrganization->method('getNetwork')->willReturn($network);
|
|
|
+ $networkOrganization->method('getEndDate')->willReturn(new \DateTime('2000-01-01'));
|
|
|
+ $organization->method('getNetworkOrganizations')->willReturn(new ArrayCollection([$networkOrganization]));
|
|
|
+
|
|
|
+ $syncService = $this->newDolibarrSyncService();
|
|
|
+
|
|
|
+ $this->assertEquals(
|
|
|
+ null,
|
|
|
+ $syncService->getOrganizationNetworkId($organization)
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
public function testCountWithMission() {
|
|
|
$members = [
|
|
|
123 => [FunctionEnum::PRESIDENT()->getValue(), FunctionEnum::TEACHER()->getValue()],
|