@@ -15,8 +15,40 @@ final class LockServiceTest extends TestCase
1515 public function testBlock (): void
1616 {
1717 $ lock = app (LockServiceInterface::class);
18- $ lock ->block ('hello ' , static fn () => 'hello world ' );
19- $ lock ->block ('hello ' , static fn () => 'hello world ' );
18+
19+ $ message = $ lock ->block (__METHOD__ , static fn () => 'hello world ' );
20+ self ::assertSame ('hello world ' , $ message );
21+
22+ $ message = $ lock ->block (__METHOD__ , static fn () => 'hello world ' );
23+ self ::assertSame ('hello world ' , $ message );
24+
25+ self ::assertTrue (true );
26+ }
27+
28+ public function testLockFailed (): void
29+ {
30+ $ lock = app (LockServiceInterface::class);
31+
32+ try {
33+ $ lock ->block (__METHOD__ , static fn () => throw new \Exception ('hello world ' ));
34+ } catch (\Throwable $ throwable ) {
35+ self ::assertSame ('hello world ' , $ throwable ->getMessage ());
36+ }
37+
38+ $ message = $ lock ->block (__METHOD__ , static fn () => 'hello world ' );
39+ self ::assertSame ('hello world ' , $ message );
40+ self ::assertTrue (true );
41+ }
42+
43+ public function testLockDeep (): void
44+ {
45+ $ lock = app (LockServiceInterface::class);
46+ $ message = $ lock ->block (
47+ __METHOD__ ,
48+ static fn () => $ lock ->block (__METHOD__ , static fn () => 'hello world ' ),
49+ );
50+
51+ self ::assertSame ('hello world ' , $ message );
2052 self ::assertTrue (true );
2153 }
2254}
0 commit comments