1515use Psr \Log \LoggerInterface ;
1616use Symfony \Component \Lock \BlockingStoreInterface ;
1717use Symfony \Component \Lock \Exception \LockConflictedException ;
18+ use Symfony \Component \Lock \Exception \LockReleasingException ;
1819use Symfony \Component \Lock \Key ;
1920use Symfony \Component \Lock \Lock ;
2021use Symfony \Component \Lock \PersistingStoreInterface ;
@@ -28,7 +29,7 @@ class LockTest extends TestCase
2829 public function testAcquireNoBlocking ()
2930 {
3031 $ key = new Key (uniqid (__METHOD__ , true ));
31- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
32+ $ store = $ this ->createMock (PersistingStoreInterface::class);
3233 $ lock = new Lock ($ key , $ store );
3334
3435 $ store
@@ -44,7 +45,7 @@ public function testAcquireNoBlocking()
4445 public function testAcquireNoBlockingStoreInterface ()
4546 {
4647 $ key = new Key (uniqid (__METHOD__ , true ));
47- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
48+ $ store = $ this ->createMock (PersistingStoreInterface::class);
4849 $ lock = new Lock ($ key , $ store );
4950
5051 $ store
@@ -60,7 +61,7 @@ public function testAcquireNoBlockingStoreInterface()
6061 public function testAcquireReturnsFalse ()
6162 {
6263 $ key = new Key (uniqid (__METHOD__ , true ));
63- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
64+ $ store = $ this ->createMock (PersistingStoreInterface::class);
6465 $ lock = new Lock ($ key , $ store );
6566
6667 $ store
@@ -77,7 +78,7 @@ public function testAcquireReturnsFalse()
7778 public function testAcquireReturnsFalseStoreInterface ()
7879 {
7980 $ key = new Key (uniqid (__METHOD__ , true ));
80- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
81+ $ store = $ this ->createMock (PersistingStoreInterface::class);
8182 $ lock = new Lock ($ key , $ store );
8283
8384 $ store
@@ -113,7 +114,7 @@ public function testAcquireBlocking()
113114 public function testAcquireSetsTtl ()
114115 {
115116 $ key = new Key (uniqid (__METHOD__ , true ));
116- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
117+ $ store = $ this ->createMock (PersistingStoreInterface::class);
117118 $ lock = new Lock ($ key , $ store , 10 );
118119
119120 $ store
@@ -133,7 +134,7 @@ public function testAcquireSetsTtl()
133134 public function testRefresh ()
134135 {
135136 $ key = new Key (uniqid (__METHOD__ , true ));
136- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
137+ $ store = $ this ->createMock (PersistingStoreInterface::class);
137138 $ lock = new Lock ($ key , $ store , 10 );
138139
139140 $ store
@@ -150,7 +151,7 @@ public function testRefresh()
150151 public function testRefreshCustom ()
151152 {
152153 $ key = new Key (uniqid (__METHOD__ , true ));
153- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
154+ $ store = $ this ->createMock (PersistingStoreInterface::class);
154155 $ lock = new Lock ($ key , $ store , 10 );
155156
156157 $ store
@@ -167,7 +168,7 @@ public function testRefreshCustom()
167168 public function testIsAquired ()
168169 {
169170 $ key = new Key (uniqid (__METHOD__ , true ));
170- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
171+ $ store = $ this ->createMock (PersistingStoreInterface::class);
171172 $ lock = new Lock ($ key , $ store , 10 );
172173
173174 $ store
@@ -181,7 +182,7 @@ public function testIsAquired()
181182 public function testRelease ()
182183 {
183184 $ key = new Key (uniqid (__METHOD__ , true ));
184- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
185+ $ store = $ this ->createMock (PersistingStoreInterface::class);
185186 $ lock = new Lock ($ key , $ store , 10 );
186187
187188 $ store
@@ -201,7 +202,7 @@ public function testRelease()
201202 public function testReleaseStoreInterface ()
202203 {
203204 $ key = new Key (uniqid (__METHOD__ , true ));
204- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
205+ $ store = $ this ->createMock (PersistingStoreInterface::class);
205206 $ lock = new Lock ($ key , $ store , 10 );
206207
207208 $ store
@@ -258,9 +259,9 @@ public function testNoAutoReleaseWhenNotConfigured()
258259
259260 public function testReleaseThrowsExceptionWhenDeletionFail ()
260261 {
261- $ this ->expectException (\ Symfony \ Component \ Lock \ Exception \ LockReleasingException::class);
262+ $ this ->expectException (LockReleasingException::class);
262263 $ key = new Key (uniqid (__METHOD__ , true ));
263- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
264+ $ store = $ this ->createMock (PersistingStoreInterface::class);
264265 $ lock = new Lock ($ key , $ store , 10 );
265266
266267 $ store
@@ -279,9 +280,9 @@ public function testReleaseThrowsExceptionWhenDeletionFail()
279280
280281 public function testReleaseThrowsExceptionIfNotWellDeleted ()
281282 {
282- $ this ->expectException (\ Symfony \ Component \ Lock \ Exception \ LockReleasingException::class);
283+ $ this ->expectException (LockReleasingException::class);
283284 $ key = new Key (uniqid (__METHOD__ , true ));
284- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
285+ $ store = $ this ->createMock (PersistingStoreInterface::class);
285286 $ lock = new Lock ($ key , $ store , 10 );
286287
287288 $ store
@@ -300,10 +301,10 @@ public function testReleaseThrowsExceptionIfNotWellDeleted()
300301
301302 public function testReleaseThrowsAndLog ()
302303 {
303- $ this ->expectException (\ Symfony \ Component \ Lock \ Exception \ LockReleasingException::class);
304+ $ this ->expectException (LockReleasingException::class);
304305 $ key = new Key (uniqid (__METHOD__ , true ));
305- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
306- $ logger = $ this ->getMockBuilder (LoggerInterface::class)-> getMock ( );
306+ $ store = $ this ->createMock (PersistingStoreInterface::class);
307+ $ logger = $ this ->createMock (LoggerInterface::class);
307308 $ lock = new Lock ($ key , $ store , 10 , true );
308309 $ lock ->setLogger ($ logger );
309310
@@ -331,7 +332,7 @@ public function testReleaseThrowsAndLog()
331332 public function testExpiration ($ ttls , $ expected )
332333 {
333334 $ key = new Key (uniqid (__METHOD__ , true ));
334- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
335+ $ store = $ this ->createMock (PersistingStoreInterface::class);
335336 $ lock = new Lock ($ key , $ store , 10 );
336337
337338 foreach ($ ttls as $ ttl ) {
@@ -350,7 +351,7 @@ public function testExpiration($ttls, $expected)
350351 public function testExpirationStoreInterface ($ ttls , $ expected )
351352 {
352353 $ key = new Key (uniqid (__METHOD__ , true ));
353- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
354+ $ store = $ this ->createMock (PersistingStoreInterface::class);
354355 $ lock = new Lock ($ key , $ store , 10 );
355356
356357 foreach ($ ttls as $ ttl ) {
0 commit comments