mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
✅ Optimize tests execution time (force cache usage and set the modification date in the past instead of waiting 1s)
This commit is contained in:
@@ -28,6 +28,10 @@ class RouterTest extends ItopDataTestCase
|
||||
parent::setUp();
|
||||
|
||||
$this->RequireOnceItopFile('setup/setuputils.class.inc.php');
|
||||
|
||||
// Speedup test by forcing the use of the cache, even on a development environment
|
||||
$oRouter = Router::GetInstance();
|
||||
$oRouter->SetUseCache(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,12 +207,9 @@ class RouterTest extends ItopDataTestCase
|
||||
$this->fail("Cache file was not generated ($sRoutesCacheFilePath)");
|
||||
}
|
||||
|
||||
clearstatcache();
|
||||
$iFirstModificationTimestamp = filemtime($sRoutesCacheFilePath);
|
||||
$this->debug("Initial timestamp: $iFirstModificationTimestamp");
|
||||
|
||||
// Wait for just 1s to ensure timestamps would be different is the file is re-generated
|
||||
sleep(1);
|
||||
// Set its modification date in the past so that regenerating it will result in a new modification date without any doubt
|
||||
$iFirstModificationTimestamp = time() - 2;
|
||||
touch($sRoutesCacheFilePath, $iFirstModificationTimestamp);
|
||||
|
||||
// Call GetRoutes() again to see if cache gets re-generated or not
|
||||
$this->InvokeNonPublicMethod(Router::class, 'GetRoutes', $oRouter, []);
|
||||
|
||||
Reference in New Issue
Block a user