Skip to content

Commit

Permalink
SUPESC-851 Fixed out of range issue for id_oms_state_machine_lock. (#…
Browse files Browse the repository at this point in the history
…10975)

SUPESC-851 Fixed out of range issue for id_oms_state_machine_lock.
  • Loading branch information
yaroslav-spryker authored Jul 25, 2024
1 parent a842ee9 commit ebe34fa
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</table>

<table name="spy_oms_state_machine_lock" identifierQuoting="true">
<column name="id_oms_state_machine_lock" required="true" type="INTEGER" autoIncrement="true" primaryKey="true"/>
<column name="id_oms_state_machine_lock" required="true" type="BIGINT" autoIncrement="true" primaryKey="true"/>
<column name="identifier" type="VARCHAR" size="255" required="true"/>
<column name="expires" type="TIMESTAMP" required="true"/>
<column name="details" type="LONGVARCHAR"/>
Expand Down
21 changes: 21 additions & 0 deletions tests/SprykerTest/Zed/Oms/Business/Lock/TriggerLockerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use DateInterval;
use DateTime;
use Orm\Zed\Oms\Persistence\SpyOmsStateMachineLock;
use Orm\Zed\Oms\Persistence\SpyOmsStateMachineLockQuery;
use Spryker\Zed\Oms\Business\Exception\LockException;

/**
Expand All @@ -26,6 +27,11 @@
*/
class TriggerLockerTest extends Unit
{
/**
* @var int
*/
protected const INTEGER_OVERFLOW_VALUE = 2147483648;

/**
* @var \SprykerTest\Zed\Oms\OmsBusinessTester
*/
Expand Down Expand Up @@ -118,4 +124,19 @@ public function testClearLocksWillRemoveAllLockEntries(): void
$triggerLocker->clearLocks();
$this->tester->assertLockedEntityCount(0);
}

/**
* @return void
*/
public function testBigintLockIdIsSupported(): void
{
// Act
$this->tester->insertOmsStateMachineLockByIdUsingRawQuery(static::INTEGER_OVERFLOW_VALUE);

$omsStateMachineLockQuery = new SpyOmsStateMachineLockQuery();
$lockEntity = $omsStateMachineLockQuery->findOneByIdOmsStateMachineLock(static::INTEGER_OVERFLOW_VALUE);

//Assert
$this->assertNotNull($lockEntity);
}
}
26 changes: 26 additions & 0 deletions tests/SprykerTest/Zed/Oms/_support/OmsBusinessTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
use Generated\Shared\Transfer\OrderTransfer;
use Generated\Shared\Transfer\QuoteTransfer;
use Generated\Shared\Transfer\StoreTransfer;
use Orm\Zed\Oms\Persistence\Map\SpyOmsStateMachineLockTableMap;
use Orm\Zed\Oms\Persistence\SpyOmsStateMachineLockQuery;
use Orm\Zed\Sales\Persistence\SpySalesOrder;
use Orm\Zed\Sales\Persistence\SpySalesOrderItem;
use Orm\Zed\Sales\Persistence\SpySalesOrderQuery;
use PHPUnit\Framework\ExpectationFailedException;
use Propel\Runtime\Collection\ObjectCollection;
use Propel\Runtime\Propel;
use ReflectionClass;
use Spryker\Zed\MessageBroker\Communication\Plugin\MessageBroker\ValidationMiddlewarePlugin;
use Spryker\Zed\MessageBroker\MessageBrokerDependencyProvider;
Expand Down Expand Up @@ -80,6 +82,11 @@ class OmsBusinessTester extends Actor
*/
public const FAKE_SKU = 'FAKE_SKU';

/**
* @var string
*/
protected const LOCKED_ENTITY_IDENTIFIER = '1';

/**
* @return void
*/
Expand Down Expand Up @@ -479,6 +486,25 @@ public function getOrderByIdSalesOrder(int $idSalesOrder): OrderTransfer
);
}

/**
* @param int $identifier
*
* @return void
*/
public function insertOmsStateMachineLockByIdUsingRawQuery(int $identifier): void
{
$query = sprintf(
"INSERT INTO %s (id_oms_state_machine_lock, identifier, expires) VALUES (%d, '%s', '%s')",
SpyOmsStateMachineLockTableMap::TABLE_NAME,
$identifier,
static::LOCKED_ENTITY_IDENTIFIER,
'2025-01-01 00:00:00',
);

$connection = Propel::getConnection();
$connection->query($query);
}

/**
* @return \Spryker\Zed\Oms\Business\Reader\ProcessCacheReaderInterface
*/
Expand Down

0 comments on commit ebe34fa

Please sign in to comment.