N°6274 Fix PHP Notices not caught in ItopDataTestCase PHPUnit

This was caused by the set_error_handler() done in DeprecatedCallsLog during startup

Now we are :
* not registering the handler if a PHPUnit test is running (based on a constant set in ItopTestCase::setUp)
* on registration only do it for the required notices
This commit is contained in:
Pierre Goiffon
2023-05-04 17:03:10 +02:00
parent eebc61385d
commit 584cfa8cbf
3 changed files with 62 additions and 10 deletions

View File

@@ -32,13 +32,20 @@ use SetupUtils;
define('DEBUG_UNIT_TEST', true);
class ItopTestCase extends TestCase
{
const TEST_LOG_DIR = 'test';
class ItopTestCase extends TestCase {
/**
* @since 3.0.4 N°6274 Allow to test if PHPUnit is currently running. Starting with PHPUnit 9.5 we'll be able to replace it with $GLOBALS['phpunit_version']
*/
public const ITOP_PHPUNIT_RUNNING_CONSTANT_NAME = 'ITOP_PHPUNIT_RUNNING';
public const TEST_LOG_DIR = 'test';
protected function setUp(): void {
if (false === defined(static::ITOP_PHPUNIT_RUNNING_CONSTANT_NAME)) {
// setUp might be called multiple times, so protecting the define() call !
define(static::ITOP_PHPUNIT_RUNNING_CONSTANT_NAME, true);
}
/** @noinspection UsingInclusionOnceReturnValueInspection avoid errors for approot includes */
protected function setUp(): void
{
$sAppRootRelPath = 'approot.inc.php';
$sDepthSeparator = '../';
for ($iDepth = 0; $iDepth < 8; $iDepth++) {