Browse Source

fix unit tests

Olivier Massot 1 năm trước cách đây
mục cha
commit
2652853135
1 tập tin đã thay đổi với 13 bổ sung0 xóa
  1. 13 0
      tests/Unit/Service/Dolibarr/DolibarrSyncServiceTest.php

+ 13 - 0
tests/Unit/Service/Dolibarr/DolibarrSyncServiceTest.php

@@ -34,6 +34,7 @@ use App\Service\Rest\Operation\CreateOperation;
 use App\Service\Rest\Operation\DeleteOperation;
 use App\Service\Rest\Operation\UpdateOperation;
 use App\Service\Utils\ArrayUtils;
+use App\Service\Utils\DatesUtils;
 use Doctrine\Common\Collections\ArrayCollection;
 use libphonenumber\PhoneNumber;
 use libphonenumber\PhoneNumberUtil;
@@ -165,6 +166,11 @@ class DolibarrSyncServiceTest extends TestCase
         $this->logger->method('error')->willReturnSelf();
     }
 
+    public function tearDown(): void
+    {
+        DatesUtils::clearFakeDatetime();
+    }
+
     private function getMockForMethod(string $method)
     {
         $dolibarrSyncService = $this->getMockBuilder(TestableDolibarrSyncService::class)
@@ -581,6 +587,8 @@ class DolibarrSyncServiceTest extends TestCase
             }
         };
 
+        DatesUtils::setFakeDatetime('2024-01-01T00:00:00+00:00');
+
         $operations = $dolibarrSyncService->scan($progressionCallback);
 
         $this->assertCount(8, $operations);
@@ -596,6 +604,7 @@ class DolibarrSyncServiceTest extends TestCase
                 'parent : `0` => `12098`',
                 'array_options.options_2iopen_software_opentalent : `Opentalent Artist` => `Opentalent School`',
                 "array_options.options_2iopeninfoopentalent : `` => `Nombre d'élèves : 1\nNombre d'adhérents : 2\nNombre d'accès admin : 1`",
+                'array_options.options_2iopen_last_sync_date : (new) => `2024-01-01T00:00:00+00:00`',
                 'status : `0` => `1`',
             ],
             $operations[0]->getChangeLog()
@@ -612,6 +621,7 @@ class DolibarrSyncServiceTest extends TestCase
                 'phone_mobile : `+33682980000` => `0607080910`',
                 'poste : `Secrétaire` => `Président`',
                 'array_options.options_2iopen_person_id : `` => `100`',
+                'array_options.options_2iopen_last_sync_date : (new) => `2024-01-01T00:00:00+00:00`',
             ],
             $operations[1]->getChangeLog()
         );
@@ -620,6 +630,7 @@ class DolibarrSyncServiceTest extends TestCase
             [
                 '[PUT contacts/4]',
                 'statut : `1` => `0`',
+                'array_options.options_2iopen_last_sync_date : (new) => `2024-01-01T00:00:00+00:00`',
             ],
             $operations[2]->getChangeLog()
         );
@@ -651,6 +662,7 @@ class DolibarrSyncServiceTest extends TestCase
                 'zip : (new) => ``',
                 '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`",
+                'array_options.options_2iopen_last_sync_date : (new) => `2024-01-01T00:00:00+00:00`',
             ],
             $operations[5]->getChangeLog()
         );
@@ -667,6 +679,7 @@ class DolibarrSyncServiceTest extends TestCase
                 'poste : (new) => `Président(e)`',
                 'statut : (new) => `1`',
                 'array_options.options_2iopen_person_id : (new) => `200`',
+                'array_options.options_2iopen_last_sync_date : (new) => `2024-01-01T00:00:00+00:00`',
                 'socid : (new) => `2`',
             ],
             $operations[6]->getChangeLog()