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 ;
@@ -28,7 +29,7 @@ class LockTest extends TestCase
28
29
public function testAcquireNoBlocking ()
29
30
{
30
31
$ key = new Key (uniqid (__METHOD__ , true ));
31
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
32
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
32
33
$ lock = new Lock ($ key , $ store );
33
34
34
35
$ store
@@ -44,7 +45,7 @@ public function testAcquireNoBlocking()
44
45
public function testAcquireNoBlockingStoreInterface ()
45
46
{
46
47
$ key = new Key (uniqid (__METHOD__ , true ));
47
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
48
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
48
49
$ lock = new Lock ($ key , $ store );
49
50
50
51
$ store
@@ -60,7 +61,7 @@ public function testAcquireNoBlockingStoreInterface()
60
61
public function testAcquireReturnsFalse ()
61
62
{
62
63
$ key = new Key (uniqid (__METHOD__ , true ));
63
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
64
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
64
65
$ lock = new Lock ($ key , $ store );
65
66
66
67
$ store
@@ -77,7 +78,7 @@ public function testAcquireReturnsFalse()
77
78
public function testAcquireReturnsFalseStoreInterface ()
78
79
{
79
80
$ key = new Key (uniqid (__METHOD__ , true ));
80
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
81
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
81
82
$ lock = new Lock ($ key , $ store );
82
83
83
84
$ store
@@ -113,7 +114,7 @@ public function testAcquireBlocking()
113
114
public function testAcquireSetsTtl ()
114
115
{
115
116
$ key = new Key (uniqid (__METHOD__ , true ));
116
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
117
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
117
118
$ lock = new Lock ($ key , $ store , 10 );
118
119
119
120
$ store
@@ -133,7 +134,7 @@ public function testAcquireSetsTtl()
133
134
public function testRefresh ()
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
@@ -150,7 +151,7 @@ public function testRefresh()
150
151
public function testRefreshCustom ()
151
152
{
152
153
$ key = new Key (uniqid (__METHOD__ , true ));
153
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
154
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
154
155
$ lock = new Lock ($ key , $ store , 10 );
155
156
156
157
$ store
@@ -167,7 +168,7 @@ public function testRefreshCustom()
167
168
public function testIsAquired ()
168
169
{
169
170
$ key = new Key (uniqid (__METHOD__ , true ));
170
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
171
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
171
172
$ lock = new Lock ($ key , $ store , 10 );
172
173
173
174
$ store
@@ -181,7 +182,7 @@ public function testIsAquired()
181
182
public function testRelease ()
182
183
{
183
184
$ key = new Key (uniqid (__METHOD__ , true ));
184
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
185
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
185
186
$ lock = new Lock ($ key , $ store , 10 );
186
187
187
188
$ store
@@ -201,7 +202,7 @@ public function testRelease()
201
202
public function testReleaseStoreInterface ()
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
@@ -258,9 +259,9 @@ public function testNoAutoReleaseWhenNotConfigured()
258
259
259
260
public function testReleaseThrowsExceptionWhenDeletionFail ()
260
261
{
261
- $ this ->expectException (\ Symfony \ Component \ Lock \ Exception \ LockReleasingException::class);
262
+ $ this ->expectException (LockReleasingException::class);
262
263
$ key = new Key (uniqid (__METHOD__ , true ));
263
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
264
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
264
265
$ lock = new Lock ($ key , $ store , 10 );
265
266
266
267
$ store
@@ -279,9 +280,9 @@ public function testReleaseThrowsExceptionWhenDeletionFail()
279
280
280
281
public function testReleaseThrowsExceptionIfNotWellDeleted ()
281
282
{
282
- $ this ->expectException (\ Symfony \ Component \ Lock \ Exception \ LockReleasingException::class);
283
+ $ this ->expectException (LockReleasingException::class);
283
284
$ key = new Key (uniqid (__METHOD__ , true ));
284
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
285
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
285
286
$ lock = new Lock ($ key , $ store , 10 );
286
287
287
288
$ store
@@ -300,10 +301,10 @@ public function testReleaseThrowsExceptionIfNotWellDeleted()
300
301
301
302
public function testReleaseThrowsAndLog ()
302
303
{
303
- $ this ->expectException (\ Symfony \ Component \ Lock \ Exception \ LockReleasingException::class);
304
+ $ this ->expectException (LockReleasingException::class);
304
305
$ 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);
307
308
$ lock = new Lock ($ key , $ store , 10 , true );
308
309
$ lock ->setLogger ($ logger );
309
310
@@ -331,7 +332,7 @@ public function testReleaseThrowsAndLog()
331
332
public function testExpiration ($ ttls , $ expected )
332
333
{
333
334
$ key = new Key (uniqid (__METHOD__ , true ));
334
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
335
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
335
336
$ lock = new Lock ($ key , $ store , 10 );
336
337
337
338
foreach ($ ttls as $ ttl ) {
@@ -350,7 +351,7 @@ public function testExpiration($ttls, $expected)
350
351
public function testExpirationStoreInterface ($ ttls , $ expected )
351
352
{
352
353
$ key = new Key (uniqid (__METHOD__ , true ));
353
- $ store = $ this ->getMockBuilder (PersistingStoreInterface::class)-> getMock ( );
354
+ $ store = $ this ->createMock (PersistingStoreInterface::class);
354
355
$ lock = new Lock ($ key , $ store , 10 );
355
356
356
357
foreach ($ ttls as $ ttl ) {
0 commit comments