@@ -188,7 +188,7 @@ public function testWorkflowDefaultMarkingStoreDefinition()
188
188
$ this ->assertNull ($ argumentsB ['index_1 ' ], 'workflow_b marking_store argument is null ' );
189
189
}
190
190
191
- public function testRateLimiterWithLockFactory ()
191
+ public function testRateLimiterLockFactoryWithLockDisabled ()
192
192
{
193
193
try {
194
194
$ this ->createContainerFromClosure (function (ContainerBuilder $ container ) {
@@ -199,7 +199,7 @@ public function testRateLimiterWithLockFactory()
199
199
'php_errors ' => ['log ' => true ],
200
200
'lock ' => false ,
201
201
'rate_limiter ' => [
202
- 'with_lock ' => ['policy ' => 'fixed_window ' , 'limit ' => 10 , 'interval ' => '1 hour ' ],
202
+ 'with_lock ' => ['policy ' => 'fixed_window ' , 'limit ' => 10 , 'interval ' => '1 hour ' , ' lock_factory ' => ' lock.factory ' ],
203
203
],
204
204
]);
205
205
});
@@ -208,7 +208,10 @@ public function testRateLimiterWithLockFactory()
208
208
} catch (LogicException $ e ) {
209
209
$ this ->assertEquals ('Rate limiter "with_lock" requires the Lock component to be configured. ' , $ e ->getMessage ());
210
210
}
211
+ }
211
212
213
+ public function testRateLimiterAutoLockFactoryWithLockEnabled ()
214
+ {
212
215
$ container = $ this ->createContainerFromClosure (function (ContainerBuilder $ container ) {
213
216
$ container ->loadFromExtension ('framework ' , [
214
217
'annotations ' => false ,
@@ -226,13 +229,35 @@ public function testRateLimiterWithLockFactory()
226
229
$ this ->assertEquals ('lock.factory ' , (string ) $ withLock ->getArgument (2 ));
227
230
}
228
231
229
- public function testRateLimiterLockFactory ()
232
+ public function testRateLimiterAutoLockFactoryWithLockDisabled ()
230
233
{
231
234
$ container = $ this ->createContainerFromClosure (function (ContainerBuilder $ container ) {
232
235
$ container ->loadFromExtension ('framework ' , [
233
236
'annotations ' => false ,
234
237
'http_method_override ' => false ,
235
238
'handle_all_throwables ' => true ,
239
+ 'lock ' => false ,
240
+ 'php_errors ' => ['log ' => true ],
241
+ 'rate_limiter ' => [
242
+ 'without_lock ' => ['policy ' => 'fixed_window ' , 'limit ' => 10 , 'interval ' => '1 hour ' ],
243
+ ],
244
+ ]);
245
+ });
246
+
247
+ $ this ->expectException (OutOfBoundsException::class);
248
+ $ this ->expectExceptionMessageMatches ('/^The argument "2" doesn \'t exist.*\.$/ ' );
249
+
250
+ $ container ->getDefinition ('limiter.without_lock ' )->getArgument (2 );
251
+ }
252
+
253
+ public function testRateLimiterDisableLockFactory ()
254
+ {
255
+ $ container = $ this ->createContainerFromClosure (function (ContainerBuilder $ container ) {
256
+ $ container ->loadFromExtension ('framework ' , [
257
+ 'annotations ' => false ,
258
+ 'http_method_override ' => false ,
259
+ 'handle_all_throwables ' => true ,
260
+ 'lock ' => true ,
236
261
'php_errors ' => ['log ' => true ],
237
262
'rate_limiter ' => [
238
263
'without_lock ' => ['policy ' => 'fixed_window ' , 'limit ' => 10 , 'interval ' => '1 hour ' , 'lock_factory ' => null ],
0 commit comments