N°6976 Fix DeprecatedCallsLog error handler never set (#576)

Caused by N°6274 (disabling error handler when running phpunit)
There is now a test testing the handler is really fixed when not in the phpunit context
Also a TRACE log is made on setting the handler
This commit is contained in:
Pierre Goiffon
2023-11-23 15:54:10 +01:00
committed by GitHub
parent e02b6ee14a
commit 6f1de11c59
4 changed files with 89 additions and 5 deletions

View File

@@ -7,6 +7,7 @@
namespace Combodo\iTop\Test\UnitTest;
use CMDBSource;
use DeprecatedCallsLog;
use MySQLTransactionNotClosedException;
use PHPUnit\Framework\TestCase;
use SetupUtils;
@@ -24,6 +25,12 @@ define('DEBUG_UNIT_TEST', true);
abstract class ItopTestCase extends TestCase
{
public const TEST_LOG_DIR = 'test';
/**
* @var bool
* @since 3.0.4 3.1.1 3.2.0 N°6976 Allow to enable/disable {@see DeprecatedCallsLog} error handler
*/
public const DISABLE_DEPRECATEDCALLSLOG_ERRORHANDLER = true;
public static $DEBUG_UNIT_TEST = false;
protected static $aBackupStaticProperties = [];
@@ -46,9 +53,10 @@ abstract class ItopTestCase extends TestCase
require_once static::GetAppRoot() . 'approot.inc.php';
if (false === defined('ITOP_PHPUNIT_RUNNING_CONSTANT_NAME')) {
if ((static::DISABLE_DEPRECATEDCALLSLOG_ERRORHANDLER)
&& (false === defined(ITOP_PHPUNIT_RUNNING_CONSTANT_NAME))) {
// setUp might be called multiple times, so protecting the define() call !
define('ITOP_PHPUNIT_RUNNING_CONSTANT_NAME', true);
define(ITOP_PHPUNIT_RUNNING_CONSTANT_NAME, true);
}
}