@@ -61,15 +61,18 @@ public function testItDoesNotSetRateLimitIfNoAnnotationProvided(): void
6161 $ this ->assertFalse ($ event ->getRequest ()->attributes ->has ('_rate_limit ' ));
6262 }
6363
64- public function testItSetRateLimitIfNoAnnotationProvidedAndServiceAliasIsUsed (): void
64+ /**
65+ * @dataProvider servicesAliasDataProvider
66+ */
67+ public function testItSetRateLimitIfNoAnnotationProvidedAndServiceAliasIsUsed (string $ serviceAlias ): void
6568 {
6669 $ this ->createReadRateLimitAnnotationListerner ();
6770
6871 $ this ->container ->expects ($ this ->once ())
6972 ->method ('get ' )
7073 ->willReturn (new FakeInvokableClassWithDefaultRateLimit ());
7174
72- $ event = $ this ->createEvent (null , true );
75+ $ event = $ this ->createEvent (null , $ serviceAlias );
7376
7477 $ this ->annotationReader ->expects ($ this ->once ())->method ('getMethodAnnotation ' )->willReturn (null );
7578
@@ -80,6 +83,19 @@ public function testItSetRateLimitIfNoAnnotationProvidedAndServiceAliasIsUsed():
8083 $ this ->assertFalse ($ event ->getRequest ()->attributes ->has ('_rate_limit ' ));
8184 }
8285
86+ /**
87+ * @return \Generator<array<string>>
88+ */
89+ public function servicesAliasDataProvider (): \Generator
90+ {
91+ yield 'service alias with : ' => [
92+ 'fake.invokable.class:__invoke ' ,
93+ ];
94+ yield 'service alias with :: ' => [
95+ 'fake.invokable.class::__invoke ' ,
96+ ];
97+ }
98+
8399 public function testItSetsRateLimitIfAnnotationProvidedWithDefaultValue (): void
84100 {
85101 $ this ->createReadRateLimitAnnotationListerner ();
@@ -159,15 +175,15 @@ public function rateLimitConfigurationDataProvider(): \Generator
159175 ];
160176 }
161177
162- protected function createEvent (Request $ request = null , bool $ useAlias = false ): ControllerEvent
178+ protected function createEvent (Request $ request = null , string $ serviceId = null ): ControllerEvent
163179 {
164180 $ request = $ request ?? new Request ();
165- $ request ->attributes ->set ('_controller ' , $ useAlias ? ' fake.invokable.class:__invoke ' : FakeInvokableClassWithDefaultRateLimit::class);
181+ $ request ->attributes ->set ('_controller ' , $ serviceId ?? FakeInvokableClassWithDefaultRateLimit::class);
166182
167183 return new ControllerEvent (
168184 $ this ->createMock (HttpKernelInterface::class),
169185 new FakeInvokableClassWithDefaultRateLimit (),
170- $ request ?? new Request () ,
186+ $ request ,
171187 HttpKernelInterface::MASTER_REQUEST
172188 );
173189 }
0 commit comments