File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 5
5
use Illuminate \Cache \Repository ;
6
6
use Illuminate \Support \Facades \Cache ;
7
7
use Illuminate \Support \Facades \DB ;
8
+ use MongoDB \Laravel \Cache \MongoLock ;
8
9
use MongoDB \Laravel \Tests \TestCase ;
9
10
10
11
use function now ;
@@ -80,6 +81,21 @@ public function testOwnedByCurrentProcess()
80
81
$ this ->assertFalse ($ otherLock ->isOwnedByCurrentProcess ());
81
82
}
82
83
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
+
83
99
private function getCache (): Repository
84
100
{
85
101
$ repository = Cache::driver ('mongodb ' );
You can’t perform that action at this time.
0 commit comments