mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
✅ Optimize tests execution time (no need for process isolation as long as we leave the premises clean)
This commit is contained in:
@@ -30,9 +30,6 @@ use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
use Dict;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @runClassInSeparateProcess
|
||||
*/
|
||||
class dictTest extends ItopTestCase
|
||||
{
|
||||
private $sEnvName;
|
||||
@@ -42,7 +39,9 @@ class dictTest extends ItopTestCase
|
||||
|
||||
$this->RequireOnceItopFile('core'.DIRECTORY_SEPARATOR.'apc-service.class.inc.php');
|
||||
|
||||
$this->sEnvName = time();
|
||||
// This id will be used as path to the dictionary files
|
||||
// It must be unique enough for the magic of Dict to operate (due to the use of require_once to load dictionaries)
|
||||
$this->sEnvName = uniqid();
|
||||
$sDictionaryFolder = APPROOT."env-$this->sEnvName".DIRECTORY_SEPARATOR."dictionaries";
|
||||
@mkdir($sDictionaryFolder, 0777, true);
|
||||
|
||||
@@ -68,6 +67,12 @@ PHP;
|
||||
file_put_contents($sDictionaryFolder.DIRECTORY_SEPARATOR."en-en.dict.php", $sContent);
|
||||
|
||||
$_SESSION['itop_env'] = $this->sEnvName;
|
||||
|
||||
// Preserve the dictionary for test that will be executed later on
|
||||
static::BackupStaticProperties('Dict');
|
||||
|
||||
// Reset the dictionary
|
||||
static::SetNonPublicStaticProperty('Dict', 'm_aData', []);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
@@ -78,6 +83,8 @@ PHP;
|
||||
rmdir(APPROOT."env-$this->sEnvName".DIRECTORY_SEPARATOR."dictionaries");
|
||||
rmdir(APPROOT."env-$this->sEnvName");
|
||||
|
||||
static::RestoreStaticProperties('Dict');
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user