N°6274 Fix log.class.inc.php crashing cause cannot load ItopTestCase class

Now the constant name is defined in approot
This commit is contained in:
Pierre Goiffon
2023-05-04 17:33:25 +02:00
parent 584cfa8cbf
commit 1884596ecd
3 changed files with 11 additions and 12 deletions

View File

@@ -25,4 +25,9 @@ define('ITOP_DESIGN_LATEST_VERSION', '3.0');
*/
define('ITOP_CORE_VERSION', '3.0.3');
/**
* @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']
*/
define('ITOP_PHPUNIT_RUNNING_CONSTANT_NAME', 'ITOP_PHPUNIT_RUNNING');
require_once APPROOT.'bootstrap.inc.php';

View File

@@ -15,7 +15,6 @@
//
// You should have received a copy of the GNU Affero General Public License
// along with iTop. If not, see <http://www.gnu.org/licenses/>
use Combodo\iTop\Test\UnitTest\ItopTestCase;
/**
@@ -1081,7 +1080,7 @@ class DeprecatedCallsLog extends LogAPI
parent::Enable($sTargetFile);
if (
(false === defined(ItopTestCase::ITOP_PHPUNIT_RUNNING_CONSTANT_NAME))
(false === defined(ITOP_PHPUNIT_RUNNING_CONSTANT_NAME))
&& static::IsLogLevelEnabledSafe(self::LEVEL_WARNING, self::ENUM_CHANNEL_PHP_LIBMETHOD)
) {
set_error_handler([static::class, 'DeprecatedNoticesErrorHandler'], E_DEPRECATED | E_USER_DEPRECATED);

View File

@@ -33,19 +33,9 @@ use SetupUtils;
define('DEBUG_UNIT_TEST', true);
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);
}
$sAppRootRelPath = 'approot.inc.php';
$sDepthSeparator = '../';
for ($iDepth = 0; $iDepth < 8; $iDepth++) {
@@ -56,6 +46,11 @@ class ItopTestCase extends TestCase {
$sAppRootRelPath = $sDepthSeparator.$sAppRootRelPath;
}
if (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);
}
}
/**