From 4e28856015c96bf6fe5fd69f5ae3c896fd269545 Mon Sep 17 00:00:00 2001 From: odain Date: Fri, 25 Oct 2024 12:02:15 +0200 Subject: [PATCH] ci: enhance DB cleanup in tearDown --- .../php-unit-tests/src/BaseTestCase/ItopDataTestCase.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php b/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php index cde0f101a..30a94d743 100644 --- a/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php +++ b/tests/php-unit-tests/src/BaseTestCase/ItopDataTestCase.php @@ -151,6 +151,10 @@ abstract class ItopDataTestCase extends ItopTestCase static::SetNonPublicStaticProperty(\cmdbAbstractObject::class, 'aObjectsAwaitingEventDbLinksChanged', []); \cmdbAbstractObject::SetEventDBLinksChangedBlocked(false); + // disconnection before object deletions. make sure to have enough rights to proceed (especially with user object) + if (UserRights::IsLoggedIn()) { + UserRights::Logoff(); + } if (static::USE_TRANSACTION) { $this->debug("ROLLBACK !!!"); CMDBSource::Query('ROLLBACK'); @@ -175,10 +179,6 @@ abstract class ItopDataTestCase extends ItopTestCase // As soon as a rollback has been performed, each object memoized should be discarded CMDBObject::SetCurrentChange(null); - // Leave the place clean - if (UserRights::IsLoggedIn()) { - UserRights::Logoff(); - } $this->SetNonPublicStaticProperty(UserRights::class, 'm_aCacheUsers', []); // we could have cached rollbacked instances if ($this->bIsUsingSilo) { $this->ResetMetaModelQueyCacheGetObject();