From 14fdc00d92d5e0b0ca98d622606ceda1d8152e77 Mon Sep 17 00:00:00 2001 From: Anne-Cath Date: Mon, 10 Nov 2025 16:14:43 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B08692=20-=20Notification=20-=20placeholde?= =?UTF-8?q?r=20attributesubitem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/attributedef.class.inc.php | 11 +++++++---- .../core/AttributeDefinitionTest.php | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index 150a28cdc4..82c460e088 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -8985,12 +8985,15 @@ public function GetSubItemAsPlainText($sItemCode, $value) switch ($sThresholdCode) { case 'deadline': if ($value) { - if (is_int($value)) { + if (is_numeric($value)) { + if (!is_int($value)) { + $value = intval($value); + } $sDate = date(AttributeDateTime::GetInternalFormat(), $value); $sRet = AttributeDeadline::FormatDeadline($sDate); - } else { - $sRet = $value; - } + } else { + $sRet = $value; + } } else { $sRet = ''; } diff --git a/tests/php-unit-tests/unitary-tests/core/AttributeDefinitionTest.php b/tests/php-unit-tests/unitary-tests/core/AttributeDefinitionTest.php index 739cf3b652..c3bf7e7e7a 100644 --- a/tests/php-unit-tests/unitary-tests/core/AttributeDefinitionTest.php +++ b/tests/php-unit-tests/unitary-tests/core/AttributeDefinitionTest.php @@ -347,4 +347,20 @@ public function GivenAttribute(string $sHostClass, string $sAttCode, string $sAt return $oAttribute; } + public function testDisplayStopwatch() + { + $aUserRequestCustomParams = [ + 'title' => "Test DisplayStopwatch", + ]; + $oUserRequest = $this->CreateUserRequest(456, $aUserRequestCustomParams); + $oAttDef = MetaModel::GetAttributeDef(get_class($oUserRequest), 'ttr_escalation_deadline'); + $iStartDate = time() - 200; + + $oStopwatch = $oUserRequest->Get('ttr'); + $oStopwatch->DefineThreshold(100, $iStartDate); + $oUserRequest->Set('ttr', $oStopwatch); + $value = $oUserRequest->Get('ttr_escalation_deadline'); + $sRet = $oAttDef->GetAsPlainText($value, $oUserRequest); + self::assertEquals('Missed by 3 min', $sRet); + } }