1616use Symfony \Component \Lock \BlockingSharedLockStoreInterface ;
1717use Symfony \Component \Lock \BlockingStoreInterface ;
1818use Symfony \Component \Lock \Exception \LockConflictedException ;
19+ use Symfony \Component \Lock \Exception \LockReleasingException ;
1920use Symfony \Component \Lock \Key ;
2021use Symfony \Component \Lock \Lock ;
2122use Symfony \Component \Lock \PersistingStoreInterface ;
@@ -30,7 +31,7 @@ class LockTest extends TestCase
3031 public function testAcquireNoBlocking ()
3132 {
3233 $ key = new Key (uniqid (__METHOD__ , true ));
33- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
34+ $ store = $ this ->createMock (PersistingStoreInterface::class);
3435 $ lock = new Lock ($ key , $ store );
3536
3637 $ store
@@ -46,7 +47,7 @@ public function testAcquireNoBlocking()
4647 public function testAcquireNoBlockingWithPersistingStoreInterface ()
4748 {
4849 $ key = new Key (uniqid (__METHOD__ , true ));
49- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
50+ $ store = $ this ->createMock (PersistingStoreInterface::class);
5051 $ lock = new Lock ($ key , $ store );
5152
5253 $ store
@@ -100,7 +101,7 @@ public function testAcquireBlockingRetryWithPersistingStoreInterface()
100101 public function testAcquireReturnsFalse ()
101102 {
102103 $ key = new Key (uniqid (__METHOD__ , true ));
103- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
104+ $ store = $ this ->createMock (PersistingStoreInterface::class);
104105 $ lock = new Lock ($ key , $ store );
105106
106107 $ store
@@ -117,7 +118,7 @@ public function testAcquireReturnsFalse()
117118 public function testAcquireReturnsFalseStoreInterface ()
118119 {
119120 $ key = new Key (uniqid (__METHOD__ , true ));
120- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
121+ $ store = $ this ->createMock (PersistingStoreInterface::class);
121122 $ lock = new Lock ($ key , $ store );
122123
123124 $ store
@@ -153,7 +154,7 @@ public function testAcquireBlockingWithBlockingStoreInterface()
153154 public function testAcquireSetsTtl ()
154155 {
155156 $ key = new Key (uniqid (__METHOD__ , true ));
156- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
157+ $ store = $ this ->createMock (PersistingStoreInterface::class);
157158 $ lock = new Lock ($ key , $ store , 10 );
158159
159160 $ store
@@ -173,7 +174,7 @@ public function testAcquireSetsTtl()
173174 public function testRefresh ()
174175 {
175176 $ key = new Key (uniqid (__METHOD__ , true ));
176- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
177+ $ store = $ this ->createMock (PersistingStoreInterface::class);
177178 $ lock = new Lock ($ key , $ store , 10 );
178179
179180 $ store
@@ -190,7 +191,7 @@ public function testRefresh()
190191 public function testRefreshCustom ()
191192 {
192193 $ key = new Key (uniqid (__METHOD__ , true ));
193- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
194+ $ store = $ this ->createMock (PersistingStoreInterface::class);
194195 $ lock = new Lock ($ key , $ store , 10 );
195196
196197 $ store
@@ -207,7 +208,7 @@ public function testRefreshCustom()
207208 public function testIsAquired ()
208209 {
209210 $ key = new Key (uniqid (__METHOD__ , true ));
210- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
211+ $ store = $ this ->createMock (PersistingStoreInterface::class);
211212 $ lock = new Lock ($ key , $ store , 10 );
212213
213214 $ store
@@ -221,7 +222,7 @@ public function testIsAquired()
221222 public function testRelease ()
222223 {
223224 $ key = new Key (uniqid (__METHOD__ , true ));
224- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
225+ $ store = $ this ->createMock (PersistingStoreInterface::class);
225226 $ lock = new Lock ($ key , $ store , 10 );
226227
227228 $ store
@@ -241,7 +242,7 @@ public function testRelease()
241242 public function testReleaseStoreInterface ()
242243 {
243244 $ key = new Key (uniqid (__METHOD__ , true ));
244- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
245+ $ store = $ this ->createMock (PersistingStoreInterface::class);
245246 $ lock = new Lock ($ key , $ store , 10 );
246247
247248 $ store
@@ -298,9 +299,9 @@ public function testNoAutoReleaseWhenNotConfigured()
298299
299300 public function testReleaseThrowsExceptionWhenDeletionFail ()
300301 {
301- $ this ->expectException (\ Symfony \ Component \ Lock \ Exception \ LockReleasingException::class);
302+ $ this ->expectException (LockReleasingException::class);
302303 $ key = new Key (uniqid (__METHOD__ , true ));
303- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
304+ $ store = $ this ->createMock (PersistingStoreInterface::class);
304305 $ lock = new Lock ($ key , $ store , 10 );
305306
306307 $ store
@@ -319,9 +320,9 @@ public function testReleaseThrowsExceptionWhenDeletionFail()
319320
320321 public function testReleaseThrowsExceptionIfNotWellDeleted ()
321322 {
322- $ this ->expectException (\ Symfony \ Component \ Lock \ Exception \ LockReleasingException::class);
323+ $ this ->expectException (LockReleasingException::class);
323324 $ key = new Key (uniqid (__METHOD__ , true ));
324- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
325+ $ store = $ this ->createMock (PersistingStoreInterface::class);
325326 $ lock = new Lock ($ key , $ store , 10 );
326327
327328 $ store
@@ -340,10 +341,10 @@ public function testReleaseThrowsExceptionIfNotWellDeleted()
340341
341342 public function testReleaseThrowsAndLog ()
342343 {
343- $ this ->expectException (\ Symfony \ Component \ Lock \ Exception \ LockReleasingException::class);
344+ $ this ->expectException (LockReleasingException::class);
344345 $ key = new Key (uniqid (__METHOD__ , true ));
345- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
346- $ logger = $ this ->getMockBuilder (LoggerInterface::class)-> getMock ( );
346+ $ store = $ this ->createMock (PersistingStoreInterface::class);
347+ $ logger = $ this ->createMock (LoggerInterface::class);
347348 $ lock = new Lock ($ key , $ store , 10 , true );
348349 $ lock ->setLogger ($ logger );
349350
@@ -371,7 +372,7 @@ public function testReleaseThrowsAndLog()
371372 public function testExpiration ($ ttls , $ expected )
372373 {
373374 $ key = new Key (uniqid (__METHOD__ , true ));
374- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
375+ $ store = $ this ->createMock (PersistingStoreInterface::class);
375376 $ lock = new Lock ($ key , $ store , 10 );
376377
377378 foreach ($ ttls as $ ttl ) {
@@ -390,7 +391,7 @@ public function testExpiration($ttls, $expected)
390391 public function testExpirationStoreInterface ($ ttls , $ expected )
391392 {
392393 $ key = new Key (uniqid (__METHOD__ , true ));
393- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
394+ $ store = $ this ->createMock (PersistingStoreInterface::class);
394395 $ lock = new Lock ($ key , $ store , 10 );
395396
396397 foreach ($ ttls as $ ttl ) {
0 commit comments