Skip to content

Commit db8cdb4

Browse files
Remove random lock names from PgAdvisoryLockMutex usages
1 parent 1db29ab commit db8cdb4

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

tests/mutex/MutexConcurrencyTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ public function provideTestHighContention()
116116
{
117117
$cases = array_map(function (array $mutexFactory) {
118118
$file = tmpfile();
119-
$this->assertEquals(4, fwrite($file, pack("i", 0)));
119+
$this->assertEquals(4, fwrite($file, pack("i", 0)), "Expected 4 bytes to be written to temporary file.");
120120

121121
return [
122122
function ($increment) use ($file) {
123123
rewind($file);
124124
flock($file, LOCK_EX);
125125
$data = fread($file, 4);
126126

127-
$this->assertEquals(4, strlen($data));
127+
$this->assertEquals(4, strlen($data), "Expected four bytes to be present in temporary file.");
128128

129129
$counter = unpack("i", $data)[1];
130130

@@ -296,7 +296,7 @@ function ($uri) {
296296
$pdo = new \PDO(getenv("PGSQL_DSN"), getenv("PGSQL_USER"));
297297
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
298298

299-
return new PgAdvisoryLockMutex($pdo, "test" . time());
299+
return new PgAdvisoryLockMutex($pdo, "test");
300300
}];
301301
}
302302

tests/mutex/MutexTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function ($uri) {
122122
$pdo = new \PDO(getenv("PGSQL_DSN"), getenv("PGSQL_USER"));
123123
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
124124

125-
return new PgAdvisoryLockMutex($pdo, "test" . time());
125+
return new PgAdvisoryLockMutex($pdo, "test");
126126
}];
127127
}
128128

tests/mutex/PredisMutexTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ protected function setUp()
3737
}
3838

3939
$this->client = new Client($config);
40-
$this->client->flushall(); // Clear any existing locks
40+
41+
if (count($config) === 1) {
42+
$this->client->flushall(); // Clear any existing locks
43+
}
4144
}
4245

4346
private function getPredisConfig()

0 commit comments

Comments
 (0)