* @package Combodo\iTop\Test\UnitTest\Hook * @since N°6097 2.7.10 3.0.4 3.1.1 */ class TestsRunStartHook implements BeforeFirstTestHook, AfterLastTestHook { /** * Use the modification time on this file to check whereas it is newer than the requirements in a test case * * @return string Abs. path to a file generated when the global tests run starts. */ public static function GetRunStartedFileAbsPath(): string { // Note: This can't be put in the cache- folder as we have multiple running across the test cases // We also don't want to put it in the unit tests folder as it is not supposed to be writable return APPROOT.'data/.php-unit-tests-run-started'; } /** * @inheritDoc */ public function executeBeforeFirstTest(): void { // Create / change modification timestamp of file marking the beginning of the tests run touch(static::GetRunStartedFileAbsPath()); } /** * @inheritDoc */ public function executeAfterLastTest(): void { // Cleanup of file marking the beginning of the tests run if (file_exists(static::GetRunStartedFileAbsPath())) { unlink(static::GetRunStartedFileAbsPath()); } } }