Skip to content

Commit dbb6678

Browse files
committed
Remove redundant LockId abstraction
1 parent 3df7d17 commit dbb6678

File tree

4 files changed

+4
-112
lines changed

4 files changed

+4
-112
lines changed

src/LockId/PostgresLockId.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,11 @@ private function __construct(
4242
public static function fromKeyValue(
4343
string $key,
4444
string $value = '',
45-
): self {
46-
return self::fromLockId(
47-
new LockId(
48-
$key,
49-
$value,
50-
),
51-
);
52-
}
53-
54-
public static function fromLockId(
55-
LockId $lockId,
5645
): self {
5746
return new self(
58-
classId: self::convertStringToSignedInt32($lockId->key),
59-
objectId: self::convertStringToSignedInt32($lockId->value),
60-
humanReadableValue: (string)$lockId,
47+
classId: self::convertStringToSignedInt32($key),
48+
objectId: self::convertStringToSignedInt32($value),
49+
humanReadableValue: "$key:$value",
6150
);
6251
}
6352

test/Integration/Locker/PostgresAdvisoryLockerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ public function testItCannotAcquireLockWithinTransactionNotInTransaction(): void
467467
{
468468
$this->expectException(LogicException::class);
469469
$this->expectExceptionMessage(
470-
'Transaction-level advisory lock `test` cannot be acquired outside of transaction',
470+
'Transaction-level advisory lock `test:` cannot be acquired outside of transaction',
471471
);
472472

473473
$locker = $this->initLocker();

test/Unit/LockId/LockIdTest.php

Lines changed: 0 additions & 68 deletions
This file was deleted.

test/Unit/LockId/PostgresLockIdTest.php

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
namespace Cog\Test\DbLocker\Unit\LockId;
1515

16-
use Cog\DbLocker\LockId\LockId;
1716
use Cog\DbLocker\LockId\PostgresLockId;
1817
use Cog\Test\DbLocker\Unit\AbstractUnitTestCase;
1918
use PHPUnit\Framework\Attributes\DataProvider;
@@ -54,34 +53,6 @@ public static function provideItCanCreatePostgresLockIdFromKeyValueData(): array
5453
];
5554
}
5655

57-
#[DataProvider('provideItCanCreatePostgresLockIdFromLockIdData')]
58-
public function testItCanCreatePostgresLockIdFromLockId(
59-
LockId $lockId,
60-
int $expectedClassId,
61-
int $expectedObjectId,
62-
): void {
63-
$postgresLockId = PostgresLockId::fromLockId($lockId);
64-
65-
$this->assertSame($expectedClassId, $postgresLockId->classId);
66-
$this->assertSame($expectedObjectId, $postgresLockId->objectId);
67-
}
68-
69-
public static function provideItCanCreatePostgresLockIdFromLockIdData(): array
70-
{
71-
return [
72-
'key only' => [
73-
new LockId('test'),
74-
-662733300,
75-
0,
76-
],
77-
'key + value' => [
78-
new LockId('test', '1'),
79-
-662733300,
80-
-2082672713,
81-
],
82-
];
83-
}
84-
8556
#[DataProvider('provideItCanCreatePostgresLockIdFromIntKeysData')]
8657
public function testItCanCreatePostgresLockIdFromIntKeys(
8758
int $classId,

0 commit comments

Comments
 (0)