File tree Expand file tree Collapse file tree 3 files changed +13
-14
lines changed Expand file tree Collapse file tree 3 files changed +13
-14
lines changed Original file line number Diff line number Diff line change 1717
1818final class PostgresLockId
1919{
20- private const DB_INT64_VALUE_MIN = -9_223_372_036_854_775_808 ;
21- private const DB_INT64_VALUE_MAX = 9_223_372_036_854_775_807 ;
20+ private const DB_INT32_VALUE_MIN = -2_147_483_648 ;
2221 private const DB_INT32_VALUE_MAX = 2_147_483_647 ;
2322
2423 public function __construct (
2524 public readonly int $ id ,
2625 public readonly string $ humanReadableValue = '' ,
2726 ) {
28- if ($ id < self ::DB_INT64_VALUE_MIN ) {
27+ if ($ id < self ::DB_INT32_VALUE_MIN ) {
2928 throw new InvalidArgumentException ('Out of bound exception (id is too small) ' );
3029 }
31- if ($ id > self ::DB_INT64_VALUE_MAX ) {
30+ if ($ id > self ::DB_INT32_VALUE_MAX ) {
3231 throw new InvalidArgumentException ('Out of bound exception (id is too big) ' );
3332 }
3433 }
Original file line number Diff line number Diff line change 2121
2222final class PostgresAdvisoryLockerTest extends AbstractIntegrationTestCase
2323{
24- private const DB_INT64_VALUE_MIN = 0 ;
25- private const DB_INT64_VALUE_MAX = 9223372036854775807 ;
24+ private const DB_INT32_VALUE_MIN = - 2_147_483_648 ;
25+ private const DB_INT32_VALUE_MAX = 2_147_483_647 ;
2626
2727 public function test_it_can_acquire_lock (): void
2828 {
@@ -41,7 +41,7 @@ public function test_it_can_acquire_lock_with_smallest_lock_id(): void
4141 {
4242 $ locker = $ this ->initLocker ();
4343 $ dbConnection = $ this ->initPostgresPdoConnection ();
44- $ postgresLockId = new PostgresLockId (self ::DB_INT64_VALUE_MIN );
44+ $ postgresLockId = new PostgresLockId (self ::DB_INT32_VALUE_MIN );
4545
4646 $ isLockAcquired = $ locker ->tryAcquireLock ($ dbConnection , $ postgresLockId );
4747
@@ -54,7 +54,7 @@ public function test_it_can_acquire_lock_with_biggest_lock_id(): void
5454 {
5555 $ locker = $ this ->initLocker ();
5656 $ dbConnection = $ this ->initPostgresPdoConnection ();
57- $ postgresLockId = new PostgresLockId (self ::DB_INT64_VALUE_MAX );
57+ $ postgresLockId = new PostgresLockId (self ::DB_INT32_VALUE_MAX );
5858
5959 $ isLockAcquired = $ locker ->tryAcquireLock ($ dbConnection , $ postgresLockId );
6060
Original file line number Diff line number Diff line change 1919
2020final class PostgresLockIdTest extends AbstractUnitTestCase
2121{
22- private const DB_INT64_VALUE_MIN = 0 ;
23- private const DB_INT64_VALUE_MAX = 9223372036854775807 ;
22+ private const DB_INT32_VALUE_MIN = - 2_147_483_648 ;
23+ private const DB_INT32_VALUE_MAX = 2_147_483_647 ;
2424
2525 public function test_it_can_create_postgres_lock_id_with_min_id (): void
2626 {
27- $ lockId = new PostgresLockId (self ::DB_INT64_VALUE_MIN );
27+ $ lockId = new PostgresLockId (self ::DB_INT32_VALUE_MIN );
2828
29- $ this ->assertSame (self ::DB_INT64_VALUE_MIN , $ lockId ->id );
29+ $ this ->assertSame (self ::DB_INT32_VALUE_MIN , $ lockId ->id );
3030 }
3131
3232 public function test_it_can_create_postgres_lock_id_with_max_id (): void
3333 {
34- $ lockId = new PostgresLockId (self ::DB_INT64_VALUE_MAX );
34+ $ lockId = new PostgresLockId (self ::DB_INT32_VALUE_MAX );
3535
36- $ this ->assertSame (self ::DB_INT64_VALUE_MAX , $ lockId ->id );
36+ $ this ->assertSame (self ::DB_INT32_VALUE_MAX , $ lockId ->id );
3737 }
3838
3939 public function test_it_can_create_postgres_lock_id_from_lock_id (): void
You can’t perform that action at this time.
0 commit comments