diff --git a/core/dbobject.class.php b/core/dbobject.class.php index bf51353eb..48b3364ed 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -2867,6 +2867,14 @@ abstract class DBObject implements iDisplay protected function ListChangedValues(array $aProposal) { $aDelta = array(); + $sClass = get_class($this); + if (MetaModel::HasLifecycle($sClass) && utils::IsNotNullOrEmptyString($this->sStimulusBeingApplied)) { + $sStateAttCode = MetaModel::GetStateAttributeCode($sClass); + if (!in_array($sStateAttCode, $aProposal)) { + // Same state but the transition was asked, act as if the state was changed + $aDelta[$sStateAttCode] = $this->m_aCurrValues[$sStateAttCode]; + } + } foreach ($aProposal as $sAtt => $proposedValue) { if (!array_key_exists($sAtt, $this->m_aOrigValues)) diff --git a/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php b/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php index 463d1c44b..52cbe3436 100644 --- a/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php +++ b/tests/php-unit-tests/src/BaseTestCase/ItopTestCase.php @@ -9,9 +9,9 @@ namespace Combodo\iTop\Test\UnitTest; use CMDBSource; use DeprecatedCallsLog; use MySQLTransactionNotClosedException; +use PHPUnit\Framework\TestCase; use ReflectionMethod; use SetupUtils; -use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\HttpKernel\KernelInterface; use const DEBUG_BACKTRACE_IGNORE_ARGS; @@ -23,7 +23,7 @@ use const DEBUG_BACKTRACE_IGNORE_ARGS; * * @since 3.0.4 3.1.1 3.2.0 N°6658 move some setUp/tearDown code to the corresponding methods *BeforeClass to speed up tests process time. */ -abstract class ItopTestCase extends KernelTestCase +abstract class ItopTestCase extends TestCase { public const TEST_LOG_DIR = 'test'; diff --git a/tests/php-unit-tests/unitary-tests/core/TriggerOnStateEnterTest.php b/tests/php-unit-tests/unitary-tests/core/TriggerOnStateEnterTest.php index 32134c1e2..f7e878354 100644 --- a/tests/php-unit-tests/unitary-tests/core/TriggerOnStateEnterTest.php +++ b/tests/php-unit-tests/unitary-tests/core/TriggerOnStateEnterTest.php @@ -35,11 +35,9 @@ class TriggerOnStateEnterTest extends ItopDataTestCase $oUserRequest = $this->GivenUserRequest('new'); $oUserRequest->ApplyStimulus('ev_assign'); - $bTransitionned = $oUserRequest->ApplyStimulus('ev_reassign'); - $this->assertTrue($bTransitionned, 'The stimulus should have been accepted'); - return; + $bTransitioned = $oUserRequest->ApplyStimulus('ev_reassign'); + $this->assertTrue($bTransitioned, 'The stimulus should have been accepted'); - $this->MarkTestSkipped('This test fails because the trigger is not executed'); $this->AssertTriggerExecuted($iTrigger, 2, 'The trigger should have been executed twice'); } public function testIsTriggeredOnNewObject()