From 7521fc3006663a7bd5f02ba35963bd5f4023c34c Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Thu, 16 Nov 2023 10:56:47 +0100 Subject: [PATCH 1/3] =?UTF-8?q?:white=5Fcheck=5Fmark:=20N=C2=B06458=20Test?= =?UTF-8?q?s=20:=20remove=20processIsolation=20Was=20caused=20by=20cached?= =?UTF-8?q?=20User=20instances=20in=20UserRights=20+=20same=20login=20for?= =?UTF-8?q?=20each=20created=20User=20objects=20instances?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php | 2 ++ tests/php-unit-tests/unitary-tests/core/DBObjectTest.php | 5 +---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php b/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php index 1d9555813..5f5f15c8f 100644 --- a/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php +++ b/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php @@ -34,6 +34,7 @@ use TagSetFieldData; use Ticket; use URP_UserProfile; use User; +use UserRights; use utils; use VirtualHost; use VirtualMachine; @@ -134,6 +135,7 @@ abstract class ItopDataTestCase extends ItopTestCase // Leave the place clean \UserRights::Logoff(); + $this->SetNonPublicStaticProperty(UserRights::class, 'm_aCacheUsers', []); foreach ($this->aEventListeners as $sListenerId) { EventService::UnRegisterListener($sListenerId); diff --git a/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php b/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php index 32ac9fc85..bdcd7dee6 100644 --- a/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php +++ b/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php @@ -300,7 +300,6 @@ class DBObjectTest extends ItopDataTestCase /** * @covers DBObject::CheckChangedExtKeysValues() - * @runInSeparateProcess MetaModel::GetObject returning wrong values :( */ public function testCheckExtKeysSiloOnAttributeExternalKey() { @@ -378,7 +377,6 @@ class DBObjectTest extends ItopDataTestCase /** * @covers DBObject::CheckChangedExtKeysValues() - * @runInSeparateProcess MetaModel::GetObject returning wrong values :( */ public function testCheckExtKeysOnAttributeLinkedSetIndirect() { @@ -480,7 +478,6 @@ class DBObjectTest extends ItopDataTestCase /** * @covers DBObject::CheckChangedExtKeysValues() - * @runInSeparateProcess MetaModel::GetObject returning wrong values :( */ public function testCheckExtKeysSiloOnAttributeObjectKey() { @@ -534,7 +531,7 @@ class DBObjectTest extends ItopDataTestCase private function CreateDemoOrgUser(Organization $oDemoOrg, string $sProfileId): User { utils::GetConfig()->SetModuleSetting('authent-local', 'password_validation.pattern', ''); - $oUserWithAllowedOrgs = $this->CreateContactlessUser('demo_test_' . __CLASS__, $sProfileId); + $oUserWithAllowedOrgs = $this->CreateContactlessUser('demo_test_' . uniqid(__CLASS__, true), $sProfileId); /** @var \URP_UserOrg $oUserOrg */ $oUserOrg = \MetaModel::NewObject('URP_UserOrg', ['allowed_org_id' => $oDemoOrg->GetKey(),]); $oAllowedOrgList = $oUserWithAllowedOrgs->Get('allowed_org_list'); From 47ccd7589feada55170099f52cacab6a161b4913 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Thu, 16 Nov 2023 11:16:59 +0100 Subject: [PATCH 2/3] :white_check_mark: Fix TriggerTest relying on hardcoded admin user id --- tests/php-unit-tests/unitary-tests/core/TriggerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/php-unit-tests/unitary-tests/core/TriggerTest.php b/tests/php-unit-tests/unitary-tests/core/TriggerTest.php index 0d8333698..3101cc6f4 100644 --- a/tests/php-unit-tests/unitary-tests/core/TriggerTest.php +++ b/tests/php-unit-tests/unitary-tests/core/TriggerTest.php @@ -92,7 +92,7 @@ class TriggerTest extends ItopDataTestCase IssueLog::Enable($sTestLogPath); try { - $oPerson1 = MetaModel::GetObject(Person::class, 1, true); + $oPerson1 = MetaModel::GetObjectByName(Person::class, 'Claude Monet'); $sExceptionMessage = 'My test exception message'; $oException = new Exception($sExceptionMessage); From a23d629e31d2f367527793b06f34b59d6d1770b7 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Thu, 16 Nov 2023 11:23:07 +0100 Subject: [PATCH 3/3] :white_check_mark: ItopDataTestCase fix using non existing EventService (added in 3.1.0) --- tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php b/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php index 5f5f15c8f..9660b2bb1 100644 --- a/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php +++ b/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php @@ -59,7 +59,6 @@ abstract class ItopDataTestCase extends ItopTestCase private $iTestOrgId; // For cleanup private $aCreatedObjects = []; - private $aEventListeners = []; /** * @var string Default environment to use for test cases @@ -137,10 +136,6 @@ abstract class ItopDataTestCase extends ItopTestCase \UserRights::Logoff(); $this->SetNonPublicStaticProperty(UserRights::class, 'm_aCacheUsers', []); - foreach ($this->aEventListeners as $sListenerId) { - EventService::UnRegisterListener($sListenerId); - } - parent::tearDown(); }