Optimize tests execution time (no need for process isolation as long as we leave the premises clean)

This commit is contained in:
Romain Quetiez
2023-10-25 23:08:26 +02:00
parent 7f245a15be
commit 8893cdac1d
2 changed files with 19 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
<?php
// Copyright (C) 2010-2021 Combodo SARL
// Copyright (C) 2010-2023 Combodo SARL
//
// This file is part of iTop.
//
@@ -448,7 +448,7 @@ class LogFileNameBuilderFactory
/**
* File logging
*
* @copyright Copyright (C) 2010-2021 Combodo SARL
* @copyright Copyright (C) 2010-2023 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
* @since 2.7.0 N°2518 N°2793 file log rotation
*/
@@ -1511,6 +1511,8 @@ class ExceptionLog extends LogAPI
*/
private static function GetLastEventIssue()
{
return self::$oLastEventIssue;
$oRet = self::$oLastEventIssue;
self::$oLastEventIssue = null;
return $oRet;
}
}

View File

@@ -30,8 +30,6 @@ class ExceptionLogTest extends ItopDataTestCase
}
/**
* @runInSeparateProcess
*
* @dataProvider logProvider
*/
public function testLogInFile($aLevels, $aExceptions, $sChannel, $aExpectedWriteNumber, $logLevelMin, $aExpectedDbWriteNumber, $logLevelMinWriteInDb)
@@ -91,14 +89,26 @@ class ExceptionLogTest extends ItopDataTestCase
$oExpectedLastEventIssue = $this->InvokeNonPublicStaticMethod('ExceptionLog', 'GetLastEventIssue', []);
if (0 == $iExpectedDbWriteNumber) {
$this->assertNull($oExpectedLastEventIssue);
if (!is_null($oExpectedLastEventIssue)) {
$this->fail("Level '$sLevel': unexpected EventIssue");
}
} else {
$this->assertInstanceOf(\EventIssue::class, $oExpectedLastEventIssue);
$this->assertInstanceOf(\EventIssue::class, $oExpectedLastEventIssue, "Level '$sLevel': missing EventIssue");
$this->assertEquals($aExpectedFileContext, $oExpectedLastEventIssue->Get('data'));
}
}
}
/**
* @return array[]
* aLevels: log levels to iterate on (AND name of the method that will be called on the underlying FileLog)
* aExceptions: For each log level => Exception to generate
* sChannel: Expected 2nd argument to the FileLog::{Level}
* aExpectedWriteNumber: For each log level => Number of times the method FileLog::{Level} will be called
* logLevelMin: Configuration / log_level_min
* iExpectedDbWriteNumber: For each log level => 1 if at least ONE EventIssue has been recorded into the DB
* logLevelMinWriteInDb: Configuration / log_level_min.write_in_db
*/
public function logProvider()
{
return [