@@ -34,6 +34,9 @@ public function testAcquireNoBlocking()
3434 $ store
3535 ->expects ($ this ->once ())
3636 ->method ('save ' );
37+ $ store
38+ ->method ('exists ' )
39+ ->willReturnOnConsecutiveCalls (true , false );
3740
3841 $ this ->assertTrue ($ lock ->acquire (false ));
3942 }
@@ -47,6 +50,9 @@ public function testAcquireNoBlockingStoreInterface()
4750 $ store
4851 ->expects ($ this ->once ())
4952 ->method ('save ' );
53+ $ store
54+ ->method ('exists ' )
55+ ->willReturnOnConsecutiveCalls (true , false );
5056
5157 $ this ->assertTrue ($ lock ->acquire (false ));
5258 }
@@ -63,6 +69,9 @@ public function testPassingOldStoreInterface()
6369 $ store
6470 ->expects ($ this ->once ())
6571 ->method ('save ' );
72+ $ store
73+ ->method ('exists ' )
74+ ->willReturnOnConsecutiveCalls (true , false );
6675
6776 $ this ->assertTrue ($ lock ->acquire (false ));
6877 }
@@ -77,6 +86,9 @@ public function testAcquireReturnsFalse()
7786 ->expects ($ this ->once ())
7887 ->method ('save ' )
7988 ->willThrowException (new LockConflictedException ());
89+ $ store
90+ ->method ('exists ' )
91+ ->willReturnOnConsecutiveCalls (true , false );
8092
8193 $ this ->assertFalse ($ lock ->acquire (false ));
8294 }
@@ -91,6 +103,9 @@ public function testAcquireReturnsFalseStoreInterface()
91103 ->expects ($ this ->once ())
92104 ->method ('save ' )
93105 ->willThrowException (new LockConflictedException ());
106+ $ store
107+ ->method ('exists ' )
108+ ->willReturnOnConsecutiveCalls (true , false );
94109
95110 $ this ->assertFalse ($ lock ->acquire (false ));
96111 }
@@ -107,6 +122,9 @@ public function testAcquireBlocking()
107122 $ store
108123 ->expects ($ this ->once ())
109124 ->method ('waitAndSave ' );
125+ $ store
126+ ->method ('exists ' )
127+ ->willReturnOnConsecutiveCalls (true , false );
110128
111129 $ this ->assertTrue ($ lock ->acquire (true ));
112130 }
@@ -124,6 +142,9 @@ public function testAcquireSetsTtl()
124142 ->expects ($ this ->once ())
125143 ->method ('putOffExpiration ' )
126144 ->with ($ key , 10 );
145+ $ store
146+ ->method ('exists ' )
147+ ->willReturnOnConsecutiveCalls (true , false );
127148
128149 $ lock ->acquire ();
129150 }
@@ -138,6 +159,9 @@ public function testRefresh()
138159 ->expects ($ this ->once ())
139160 ->method ('putOffExpiration ' )
140161 ->with ($ key , 10 );
162+ $ store
163+ ->method ('exists ' )
164+ ->willReturnOnConsecutiveCalls (true , false );
141165
142166 $ lock ->refresh ();
143167 }
@@ -152,6 +176,9 @@ public function testRefreshCustom()
152176 ->expects ($ this ->once ())
153177 ->method ('putOffExpiration ' )
154178 ->with ($ key , 20 );
179+ $ store
180+ ->method ('exists ' )
181+ ->willReturnOnConsecutiveCalls (true , false );
155182
156183 $ lock ->refresh (20 );
157184 }
@@ -163,10 +190,9 @@ public function testIsAquired()
163190 $ lock = new Lock ($ key , $ store , 10 );
164191
165192 $ store
166- ->expects ($ this ->any ())
167193 ->method ('exists ' )
168194 ->with ($ key )
169- ->will ( $ this -> onConsecutiveCalls ( true , false ) );
195+ ->willReturnOnConsecutiveCalls ( true , false );
170196
171197 $ this ->assertTrue ($ lock ->isAcquired ());
172198 }
@@ -219,7 +245,7 @@ public function testReleaseOnDestruction()
219245
220246 $ store
221247 ->method ('exists ' )
222- ->willReturnOnConsecutiveCalls ([ true , false ] )
248+ ->willReturnOnConsecutiveCalls (true , false )
223249 ;
224250 $ store
225251 ->expects ($ this ->once ())
@@ -238,7 +264,7 @@ public function testNoAutoReleaseWhenNotConfigured()
238264
239265 $ store
240266 ->method ('exists ' )
241- ->willReturnOnConsecutiveCalls ([ true , false ] )
267+ ->willReturnOnConsecutiveCalls (true , false )
242268 ;
243269 $ store
244270 ->expects ($ this ->never ())
0 commit comments