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 ;
@@ -29,7 +30,7 @@ class LockTest extends TestCase
2930 public function testAcquireNoBlocking ()
3031 {
3132 $ key = new Key (uniqid (__METHOD__ , true ));
32- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
33+ $ store = $ this ->createMock (PersistingStoreInterface::class);
3334 $ lock = new Lock ($ key , $ store );
3435
3536 $ store
@@ -45,7 +46,7 @@ public function testAcquireNoBlocking()
4546 public function testAcquireNoBlockingStoreInterface ()
4647 {
4748 $ key = new Key (uniqid (__METHOD__ , true ));
48- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
49+ $ store = $ this ->createMock (PersistingStoreInterface::class);
4950 $ lock = new Lock ($ key , $ store );
5051
5152 $ store
@@ -64,7 +65,7 @@ public function testAcquireNoBlockingStoreInterface()
6465 public function testPassingOldStoreInterface ()
6566 {
6667 $ key = new Key (uniqid (__METHOD__ , true ));
67- $ store = $ this ->getMockBuilder (StoreInterface::class)-> getMock ( );
68+ $ store = $ this ->createMock (StoreInterface::class);
6869 $ lock = new Lock ($ key , $ store );
6970
7071 $ store
@@ -80,7 +81,7 @@ public function testPassingOldStoreInterface()
8081 public function testAcquireReturnsFalse ()
8182 {
8283 $ key = new Key (uniqid (__METHOD__ , true ));
83- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
84+ $ store = $ this ->createMock (PersistingStoreInterface::class);
8485 $ lock = new Lock ($ key , $ store );
8586
8687 $ store
@@ -97,7 +98,7 @@ public function testAcquireReturnsFalse()
9798 public function testAcquireReturnsFalseStoreInterface ()
9899 {
99100 $ key = new Key (uniqid (__METHOD__ , true ));
100- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
101+ $ store = $ this ->createMock (PersistingStoreInterface::class);
101102 $ lock = new Lock ($ key , $ store );
102103
103104 $ store
@@ -133,7 +134,7 @@ public function testAcquireBlocking()
133134 public function testAcquireSetsTtl ()
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
@@ -153,7 +154,7 @@ public function testAcquireSetsTtl()
153154 public function testRefresh ()
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
@@ -170,7 +171,7 @@ public function testRefresh()
170171 public function testRefreshCustom ()
171172 {
172173 $ key = new Key (uniqid (__METHOD__ , true ));
173- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
174+ $ store = $ this ->createMock (PersistingStoreInterface::class);
174175 $ lock = new Lock ($ key , $ store , 10 );
175176
176177 $ store
@@ -187,7 +188,7 @@ public function testRefreshCustom()
187188 public function testIsAquired ()
188189 {
189190 $ key = new Key (uniqid (__METHOD__ , true ));
190- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
191+ $ store = $ this ->createMock (PersistingStoreInterface::class);
191192 $ lock = new Lock ($ key , $ store , 10 );
192193
193194 $ store
@@ -201,7 +202,7 @@ public function testIsAquired()
201202 public function testRelease ()
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
@@ -221,7 +222,7 @@ public function testRelease()
221222 public function testReleaseStoreInterface ()
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
@@ -278,9 +279,9 @@ public function testNoAutoReleaseWhenNotConfigured()
278279
279280 public function testReleaseThrowsExceptionWhenDeletionFail ()
280281 {
281- $ this ->expectException (\ Symfony \ Component \ Lock \ Exception \ LockReleasingException::class);
282+ $ this ->expectException (LockReleasingException::class);
282283 $ key = new Key (uniqid (__METHOD__ , true ));
283- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
284+ $ store = $ this ->createMock (PersistingStoreInterface::class);
284285 $ lock = new Lock ($ key , $ store , 10 );
285286
286287 $ store
@@ -299,9 +300,9 @@ public function testReleaseThrowsExceptionWhenDeletionFail()
299300
300301 public function testReleaseThrowsExceptionIfNotWellDeleted ()
301302 {
302- $ this ->expectException (\ Symfony \ Component \ Lock \ Exception \ LockReleasingException::class);
303+ $ this ->expectException (LockReleasingException::class);
303304 $ key = new Key (uniqid (__METHOD__ , true ));
304- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
305+ $ store = $ this ->createMock (PersistingStoreInterface::class);
305306 $ lock = new Lock ($ key , $ store , 10 );
306307
307308 $ store
@@ -320,10 +321,10 @@ public function testReleaseThrowsExceptionIfNotWellDeleted()
320321
321322 public function testReleaseThrowsAndLog ()
322323 {
323- $ this ->expectException (\ Symfony \ Component \ Lock \ Exception \ LockReleasingException::class);
324+ $ this ->expectException (LockReleasingException::class);
324325 $ key = new Key (uniqid (__METHOD__ , true ));
325- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
326- $ logger = $ this ->getMockBuilder (LoggerInterface::class)-> getMock ( );
326+ $ store = $ this ->createMock (PersistingStoreInterface::class);
327+ $ logger = $ this ->createMock (LoggerInterface::class);
327328 $ lock = new Lock ($ key , $ store , 10 , true );
328329 $ lock ->setLogger ($ logger );
329330
@@ -351,7 +352,7 @@ public function testReleaseThrowsAndLog()
351352 public function testExpiration ($ ttls , $ expected )
352353 {
353354 $ key = new Key (uniqid (__METHOD__ , true ));
354- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
355+ $ store = $ this ->createMock (PersistingStoreInterface::class);
355356 $ lock = new Lock ($ key , $ store , 10 );
356357
357358 foreach ($ ttls as $ ttl ) {
@@ -370,7 +371,7 @@ public function testExpiration($ttls, $expected)
370371 public function testExpirationStoreInterface ($ ttls , $ expected )
371372 {
372373 $ key = new Key (uniqid (__METHOD__ , true ));
373- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
374+ $ store = $ this ->createMock (PersistingStoreInterface::class);
374375 $ lock = new Lock ($ key , $ store , 10 );
375376
376377 foreach ($ ttls as $ ttl ) {
0 commit comments