15
15
use Psr \Log \LoggerInterface ;
16
16
use Symfony \Component \Lock \BlockingStoreInterface ;
17
17
use Symfony \Component \Lock \Exception \LockConflictedException ;
18
+ use Symfony \Component \Lock \Exception \LockReleasingException ;
18
19
use Symfony \Component \Lock \Key ;
19
20
use Symfony \Component \Lock \Lock ;
20
21
use Symfony \Component \Lock \PersistingStoreInterface ;
@@ -29,7 +30,7 @@ class LockTest extends TestCase
29
30
public function testAcquireNoBlocking ()
30
31
{
31
32
$ key = new Key (uniqid (__METHOD__ , true ));
32
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
33
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
33
34
$ lock = new Lock ($ key , $ store );
34
35
35
36
$ store
@@ -45,7 +46,7 @@ public function testAcquireNoBlocking()
45
46
public function testAcquireNoBlockingStoreInterface ()
46
47
{
47
48
$ key = new Key (uniqid (__METHOD__ , true ));
48
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
49
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
49
50
$ lock = new Lock ($ key , $ store );
50
51
51
52
$ store
@@ -64,7 +65,7 @@ public function testAcquireNoBlockingStoreInterface()
64
65
public function testPassingOldStoreInterface ()
65
66
{
66
67
$ key = new Key (uniqid (__METHOD__ , true ));
67
- $ store = $ this ->getMockBuilder (StoreInterface::class)-> getMock ( );
68
+ $ store = $ this ->createMock (StoreInterface::class);
68
69
$ lock = new Lock ($ key , $ store );
69
70
70
71
$ store
@@ -80,7 +81,7 @@ public function testPassingOldStoreInterface()
80
81
public function testAcquireReturnsFalse ()
81
82
{
82
83
$ key = new Key (uniqid (__METHOD__ , true ));
83
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
84
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
84
85
$ lock = new Lock ($ key , $ store );
85
86
86
87
$ store
@@ -97,7 +98,7 @@ public function testAcquireReturnsFalse()
97
98
public function testAcquireReturnsFalseStoreInterface ()
98
99
{
99
100
$ key = new Key (uniqid (__METHOD__ , true ));
100
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
101
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
101
102
$ lock = new Lock ($ key , $ store );
102
103
103
104
$ store
@@ -133,7 +134,7 @@ public function testAcquireBlocking()
133
134
public function testAcquireSetsTtl ()
134
135
{
135
136
$ key = new Key (uniqid (__METHOD__ , true ));
136
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
137
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
137
138
$ lock = new Lock ($ key , $ store , 10 );
138
139
139
140
$ store
@@ -153,7 +154,7 @@ public function testAcquireSetsTtl()
153
154
public function testRefresh ()
154
155
{
155
156
$ key = new Key (uniqid (__METHOD__ , true ));
156
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
157
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
157
158
$ lock = new Lock ($ key , $ store , 10 );
158
159
159
160
$ store
@@ -170,7 +171,7 @@ public function testRefresh()
170
171
public function testRefreshCustom ()
171
172
{
172
173
$ key = new Key (uniqid (__METHOD__ , true ));
173
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
174
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
174
175
$ lock = new Lock ($ key , $ store , 10 );
175
176
176
177
$ store
@@ -187,7 +188,7 @@ public function testRefreshCustom()
187
188
public function testIsAquired ()
188
189
{
189
190
$ key = new Key (uniqid (__METHOD__ , true ));
190
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
191
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
191
192
$ lock = new Lock ($ key , $ store , 10 );
192
193
193
194
$ store
@@ -201,7 +202,7 @@ public function testIsAquired()
201
202
public function testRelease ()
202
203
{
203
204
$ key = new Key (uniqid (__METHOD__ , true ));
204
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
205
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
205
206
$ lock = new Lock ($ key , $ store , 10 );
206
207
207
208
$ store
@@ -221,7 +222,7 @@ public function testRelease()
221
222
public function testReleaseStoreInterface ()
222
223
{
223
224
$ key = new Key (uniqid (__METHOD__ , true ));
224
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
225
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
225
226
$ lock = new Lock ($ key , $ store , 10 );
226
227
227
228
$ store
@@ -278,9 +279,9 @@ public function testNoAutoReleaseWhenNotConfigured()
278
279
279
280
public function testReleaseThrowsExceptionWhenDeletionFail ()
280
281
{
281
- $ this ->expectException (\ Symfony \ Component \ Lock \ Exception \ LockReleasingException::class);
282
+ $ this ->expectException (LockReleasingException::class);
282
283
$ key = new Key (uniqid (__METHOD__ , true ));
283
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
284
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
284
285
$ lock = new Lock ($ key , $ store , 10 );
285
286
286
287
$ store
@@ -299,9 +300,9 @@ public function testReleaseThrowsExceptionWhenDeletionFail()
299
300
300
301
public function testReleaseThrowsExceptionIfNotWellDeleted ()
301
302
{
302
- $ this ->expectException (\ Symfony \ Component \ Lock \ Exception \ LockReleasingException::class);
303
+ $ this ->expectException (LockReleasingException::class);
303
304
$ key = new Key (uniqid (__METHOD__ , true ));
304
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
305
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
305
306
$ lock = new Lock ($ key , $ store , 10 );
306
307
307
308
$ store
@@ -320,10 +321,10 @@ public function testReleaseThrowsExceptionIfNotWellDeleted()
320
321
321
322
public function testReleaseThrowsAndLog ()
322
323
{
323
- $ this ->expectException (\ Symfony \ Component \ Lock \ Exception \ LockReleasingException::class);
324
+ $ this ->expectException (LockReleasingException::class);
324
325
$ 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);
327
328
$ lock = new Lock ($ key , $ store , 10 , true );
328
329
$ lock ->setLogger ($ logger );
329
330
@@ -351,7 +352,7 @@ public function testReleaseThrowsAndLog()
351
352
public function testExpiration ($ ttls , $ expected )
352
353
{
353
354
$ key = new Key (uniqid (__METHOD__ , true ));
354
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
355
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
355
356
$ lock = new Lock ($ key , $ store , 10 );
356
357
357
358
foreach ($ ttls as $ ttl ) {
@@ -370,7 +371,7 @@ public function testExpiration($ttls, $expected)
370
371
public function testExpirationStoreInterface ($ ttls , $ expected )
371
372
{
372
373
$ key = new Key (uniqid (__METHOD__ , true ));
373
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
374
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
374
375
$ lock = new Lock ($ key , $ store , 10 );
375
376
376
377
foreach ($ ttls as $ ttl ) {
0 commit comments