|
|
@@ -99,6 +99,17 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
$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
|
|
|
*
|
|
|
@@ -106,12 +117,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
*/
|
|
|
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 -----
|
|
|
$orgId1 = 10;
|
|
|
@@ -575,11 +581,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
*/
|
|
|
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]];
|
|
|
|
|
|
@@ -622,11 +624,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
* @see DolibarrSyncService::run()
|
|
|
*/
|
|
|
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'];
|
|
|
|
|
|
@@ -643,11 +641,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
*/
|
|
|
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
|
|
|
->expects($this->once())
|
|
|
@@ -685,11 +679,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
*/
|
|
|
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
|
|
|
->expects($this->once())
|
|
|
@@ -716,11 +706,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
*/
|
|
|
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 = [
|
|
|
['id' => 1, 'array_options' => ['options_2iopen_person_id' => 101]],
|
|
|
@@ -740,11 +726,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
*/
|
|
|
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 = [
|
|
|
['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
|
|
|
{
|
|
|
- $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 = [
|
|
|
['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
|
|
|
{
|
|
|
- $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 = [
|
|
|
['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
|
|
|
{
|
|
|
- $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' => '']]);
|
|
|
|
|
|
@@ -841,11 +811,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
*/
|
|
|
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);
|
|
|
$this->assertEquals(null, $result);
|
|
|
@@ -856,11 +822,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
*/
|
|
|
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();
|
|
|
$organizationAddressPostal1 = $this->getMockBuilder(OrganizationAddressPostal::class)->getMock();
|
|
|
@@ -891,11 +853,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
*/
|
|
|
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->expects($this->once())
|
|
|
@@ -913,11 +871,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
*/
|
|
|
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();
|
|
|
$contactPoint2 = $this->getMockBuilder(ContactPoint::class)->getMock();
|
|
|
@@ -949,12 +903,9 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
/**
|
|
|
* @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();
|
|
|
$contactPoint2 = $this->getMockBuilder(ContactPoint::class)->getMock();
|
|
|
@@ -989,11 +940,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
* @see DolibarrSyncService::getOrganizationPhone()
|
|
|
*/
|
|
|
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
|
|
|
@@ -1013,11 +960,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
* @see DolibarrSyncService::getOrganizationEmail()
|
|
|
*/
|
|
|
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();
|
|
|
$contactPoint2 = $this->getMockBuilder(ContactPoint::class)->getMock();
|
|
|
@@ -1047,11 +990,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
* @see DolibarrSyncService::getOrganizationEmail()
|
|
|
*/
|
|
|
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
|
|
|
@@ -1069,11 +1008,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
* @see DolibarrSyncService::getOrganizationNetworkId()
|
|
|
*/
|
|
|
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();
|
|
|
$network = $this->getMockBuilder(Network::class)->getMock();
|
|
|
@@ -1092,11 +1027,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
* @see DolibarrSyncService::getOrganizationNetworkId()
|
|
|
*/
|
|
|
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->method('getId')->willReturn(3);
|
|
|
@@ -1125,11 +1056,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
* @see DolibarrSyncService::getOrganizationNetworkId()
|
|
|
*/
|
|
|
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();
|
|
|
$network = $this->getMockBuilder(Network::class)->getMock();
|
|
|
@@ -1149,11 +1076,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
* @see DolibarrSyncService::countWithMission()
|
|
|
*/
|
|
|
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 = [
|
|
|
123 => [FunctionEnum::PRESIDENT()->getValue(), FunctionEnum::TEACHER()->getValue()],
|
|
|
@@ -1190,11 +1113,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
* @see DolibarrSyncService::getPersonContact()
|
|
|
*/
|
|
|
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();
|
|
|
|
|
|
@@ -1224,11 +1143,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
* @see DolibarrSyncService::formatContactPosition()
|
|
|
*/
|
|
|
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(
|
|
|
[
|
|
|
@@ -1304,11 +1219,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
* @see DolibarrSyncService::formatPhoneNumber()
|
|
|
*/
|
|
|
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();
|
|
|
$phoneNumber = $phoneUtil->parse('01 02 03 04 05', "FR");
|
|
|
@@ -1322,11 +1233,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
* @see DolibarrSyncService::validateResponse()
|
|
|
*/
|
|
|
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->method('toArray')->willReturn(['a' => 1]);
|
|
|
@@ -1345,11 +1252,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
* @see DolibarrSyncService::validateResponse()
|
|
|
*/
|
|
|
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->method('toArray')->willReturn(['a' => 1]);
|
|
|
@@ -1375,11 +1278,7 @@ class DolibarrSyncServiceTest extends TestCase
|
|
|
* @see DolibarrSyncService::validateResponse()
|
|
|
*/
|
|
|
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->method('getInfo')->willReturnMap([
|