@@ 55-63 (lines=9) @@ | ||
52 | /** |
|
53 | * @test |
|
54 | */ |
|
55 | public function shouldThrowAnExceptionIfMutexIsAlreadyAcquired() |
|
56 | { |
|
57 | $this->setExpectedExceptionRegExp(\RuntimeException::class); |
|
58 | ||
59 | \Phake::when($this->mutexAdapter)->generateKey($this->anything())->thenReturn('worker_test'); |
|
60 | \Phake::when($this->mutex)->acquire($this->anything(), $this->anything())->thenReturn(null); |
|
61 | ||
62 | $this->mutexAdapter->acquire('test'); |
|
63 | } |
|
64 | ||
65 | /** |
|
66 | * @test |
|
@@ 68-74 (lines=7) @@ | ||
65 | /** |
|
66 | * @test |
|
67 | */ |
|
68 | public function shouldReleaseMutex() |
|
69 | { |
|
70 | \Phake::when($this->mutexAdapter)->generateKey('test')->thenReturn('worker_test'); |
|
71 | \Phake::when($this->mutex)->release($this->anything(), $this->anything())->thenReturn(true); |
|
72 | ||
73 | $this->assertNull($this->mutexAdapter->release('worker_test')); |
|
74 | } |
|
75 | ||
76 | /** |
|
77 | * @test |
|
@@ 79-87 (lines=9) @@ | ||
76 | /** |
|
77 | * @test |
|
78 | */ |
|
79 | public function shouldThrowAnExceptionIfCantReleaseTheMutex() |
|
80 | { |
|
81 | $this->setExpectedExceptionRegExp(\RuntimeException::class); |
|
82 | ||
83 | \Phake::when($this->mutexAdapter)->generateKey($this->anything())->thenReturn('worker_test'); |
|
84 | \Phake::when($this->mutex)->release($this->anything())->thenReturn(false); |
|
85 | ||
86 | $this->mutexAdapter->release('test'); |
|
87 | } |
|
88 | } |
|
89 |