mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 17:48:43 +02:00
✅ Optimize tests execution time (no need for process isolation as long as we leave the premises clean)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 [
|
||||
|
||||
Reference in New Issue
Block a user