mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Merge remote-tracking branch 'origin/support/3.1' into develop
This commit is contained in:
@@ -7,8 +7,20 @@
|
||||
- Covers the consistency of some data through the app?
|
||||
- Most likely in "integration-tests".
|
||||
|
||||
## How do I make sure that my tests are efficient?
|
||||
|
||||
## Tests prerequisites
|
||||
|
||||
Install iTop with default setup options :
|
||||
- Configuration Management options : everything checked
|
||||
- Service Management for Enterprises
|
||||
- Simple Ticket Management + Customer portal
|
||||
- Simple Change Management
|
||||
|
||||
Plus :
|
||||
- Additional ITIL tickets : check Known Errors Management and FAQ
|
||||
|
||||
|
||||
## How do I make sure that my tests are efficient?
|
||||
|
||||
### Derive from the relevant test class
|
||||
|
||||
|
||||
@@ -65,6 +65,13 @@ abstract class ItopDataTestCase extends ItopTestCase
|
||||
private $aCreatedObjects = [];
|
||||
private $aEventListeners = [];
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
protected $bIsUsingSilo = false;
|
||||
|
||||
/**
|
||||
* @var string Default environment to use for test cases
|
||||
*/
|
||||
@@ -141,9 +148,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();
|
||||
}
|
||||
|
||||
foreach ($this->aEventListeners as $sListenerId) {
|
||||
EventService::UnRegisterListener($sListenerId);
|
||||
|
||||
@@ -191,6 +191,8 @@ class QueryTest extends ItopDataTestCase
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->oUser->DBDelete();
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -455,6 +455,7 @@ class DBObjectTest extends ItopDataTestCase
|
||||
public function testCheckExtKeysSiloOnAttributeExternalKey()
|
||||
{
|
||||
//--- Preparing data...
|
||||
$this->bIsUsingSilo = true;
|
||||
$oAlwaysTrueCallback = $this->GetAlwaysTrueCallback();
|
||||
$oAlwaysFalseCallback = $this->GetAlwaysFalseCallback();
|
||||
|
||||
@@ -532,6 +533,7 @@ class DBObjectTest extends ItopDataTestCase
|
||||
public function testCheckExtKeysOnAttributeLinkedSetIndirect()
|
||||
{
|
||||
//--- Preparing data...
|
||||
$this->bIsUsingSilo = true;
|
||||
/** @var Organization $oDemoOrg */
|
||||
$oDemoOrg = MetaModel::GetObjectByName(Organization::class, 'Demo');
|
||||
/** @var Person $oPersonOnItDepartmentOrg */
|
||||
@@ -633,6 +635,7 @@ class DBObjectTest extends ItopDataTestCase
|
||||
public function testCheckExtKeysSiloOnAttributeObjectKey()
|
||||
{
|
||||
//--- Preparing data...
|
||||
$this->bIsUsingSilo = true;
|
||||
/** @var Organization $oDemoOrg */
|
||||
$oDemoOrg = MetaModel::GetObjectByName(Organization::class, 'Demo');
|
||||
/** @var Person $oPersonOnItDepartmentOrg */
|
||||
|
||||
Reference in New Issue
Block a user