mirror of
https://github.com/Combodo/iTop.git
synced 2026-03-05 00:54:12 +01:00
✅ N°6458 Improve ItopDataTestCase tests speed
What was measured : - 1'54 with previous code (always doing a reset in tearDown) - 1'44 without any ResetMetaModelQueyCacheGetObject call (but 3 tests are failing) - 1'44 with new optin mechanism + don't call Logoff if no current user logged
This commit is contained in:
@@ -60,6 +60,13 @@ abstract class ItopDataTestCase extends ItopTestCase
|
||||
// For cleanup
|
||||
private $aCreatedObjects = [];
|
||||
|
||||
/**
|
||||
* @var bool When testing with silo, there are some cache we need to update on tearDown. Doing it all the time will cost too much, so it's opt-in !
|
||||
* @see tearDown
|
||||
* @see ResetMetaModelQueyCacheGetObject
|
||||
*/
|
||||
private $bIsUsingSilo = false;
|
||||
|
||||
/**
|
||||
* @var string Default environment to use for test cases
|
||||
*/
|
||||
@@ -133,9 +140,13 @@ abstract class ItopDataTestCase extends ItopTestCase
|
||||
CMDBObject::SetCurrentChange(null);
|
||||
|
||||
// Leave the place clean
|
||||
\UserRights::Logoff();
|
||||
$this->SetNonPublicStaticProperty(UserRights::class, 'm_aCacheUsers', []);
|
||||
$this->ResetMetaModelQueyCacheGetObject();
|
||||
if (UserRights::IsLoggedIn()) {
|
||||
UserRights::Logoff();
|
||||
}
|
||||
$this->SetNonPublicStaticProperty(UserRights::class, 'm_aCacheUsers', []); // we could have cached rollbacked instances
|
||||
if ($this->bIsUsingSilo) {
|
||||
$this->ResetMetaModelQueyCacheGetObject();
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user