N°7206 - Force DBUpdate() when a transition is asked, and it leads to the same state

This commit is contained in:
Eric Espie
2025-01-06 11:31:22 +01:00
parent 1e674d7bdc
commit 73bb80ebea
3 changed files with 12 additions and 6 deletions

View File

@@ -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))

View File

@@ -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';

View File

@@ -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()