Skip to content

Commit 3fa18f3

Browse files
committed
Add test on restoreLock
1 parent 17fa3fc commit 3fa18f3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/Cache/MongoLockTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Cache\Repository;
66
use Illuminate\Support\Facades\Cache;
77
use Illuminate\Support\Facades\DB;
8+
use MongoDB\Laravel\Cache\MongoLock;
89
use MongoDB\Laravel\Tests\TestCase;
910

1011
use function now;
@@ -80,6 +81,21 @@ public function testOwnedByCurrentProcess()
8081
$this->assertFalse($otherLock->isOwnedByCurrentProcess());
8182
}
8283

84+
public function testRestoreLock()
85+
{
86+
$lock = $this->getCache()->lock('foo');
87+
$lock->acquire();
88+
$this->assertInstanceOf(MongoLock::class, $lock);
89+
90+
$owner = $lock->owner();
91+
92+
$resoredLock = $this->getCache()->restoreLock('foo', $owner);
93+
$this->assertTrue($resoredLock->isOwnedByCurrentProcess());
94+
95+
$resoredLock->release();
96+
$this->assertFalse($resoredLock->isOwnedByCurrentProcess());
97+
}
98+
8399
private function getCache(): Repository
84100
{
85101
$repository = Cache::driver('mongodb');

0 commit comments

Comments
 (0)