1212use Closure ;
1313use DateTime ;
1414use Error ;
15+ use PHPUnit \Framework \Attributes \Group ;
16+ use PHPUnit \Framework \Attributes \Test ;
1517use PHPUnit \Framework \MockObject \MockObject ;
1618use PHPUnit \Framework \TestCase ;
1719use Symfony \Component \DependencyInjection \ContainerInterface ;
2729
2830/**
2931 * Tests for the EventListener.
30- *
31- * @group time-sensitive
3232 */
33+ #[Group('time-sensitive ' )]
3334final class EventListenerTest extends TestCase
3435{
3536 /**
@@ -53,31 +54,31 @@ protected function setUp(): void
5354 $ this ->eventListener = new EventListener ($ this ->container );
5455 }
5556
56- /** @test */
57+ #[Test]
5758 public function onKernelControllerDoesNoHarmForMissingAnnotation (): void
5859 {
5960 $ this ->exerciseOnKernelController ([DummyController::class, 'plainAction ' ]);
6061
6162 $ this ->assertRegularControllerResponse ();
6263 }
6364
64- /** @test */
65+ #[Test]
6566 public function onKernelControllerDoesNoHarmForNoDeterminedLastModified (): void
6667 {
6768 $ this ->exerciseOnKernelController ([DummyController::class, 'abstainingLastModifiedAction ' ]);
6869
6970 $ this ->assertRegularControllerResponse ();
7071 }
7172
72- /** @test */
73+ #[Test]
7374 public function onKernelControllerDoesNoHarmIfNotModifiedSinceHeaderIsNotInRequest (): void
7475 {
7576 $ this ->exerciseOnKernelController ([DummyController::class, 'oneDayAgoModifiedLastModifiedAction ' ]);
7677
7778 $ this ->assertRegularControllerResponse ();
7879 }
7980
80- /** @test */
81+ #[Test]
8182 public function onKernelControllerSkipsToModifiedResponseIfLastModifiedIsSmallerThanIfNotModifiedSinceHeader (): void
8283 {
8384 $ this ->request ->headers ->set ('If-Modified-Since ' , '-1 hour ' );
@@ -87,7 +88,7 @@ public function onKernelControllerSkipsToModifiedResponseIfLastModifiedIsSmaller
8788 $ this ->assertNotModifiedResponse ();
8889 }
8990
90- /** @test */
91+ #[Test]
9192 public function onKernelControllerAlwaysRunsControllerInKernelDebugMode (): void
9293 {
9394 $ this ->eventListener = new EventListener ($ this ->container , true );
@@ -98,7 +99,7 @@ public function onKernelControllerAlwaysRunsControllerInKernelDebugMode(): void
9899 $ this ->assertRegularControllerResponse ();
99100 }
100101
101- /** @test */
102+ #[Test]
102103 public function onKernelControllerSkipsToNotModifiedResponseIfLastModifiedIsEqualToIfNotModifiedSinceHeader (): void
103104 {
104105 $ this ->request ->headers ->set ('If-Modified-Since ' , '2000-01-01 ' );
@@ -108,7 +109,7 @@ public function onKernelControllerSkipsToNotModifiedResponseIfLastModifiedIsEqua
108109 $ this ->assertNotModifiedResponse ();
109110 }
110111
111- /** @test */
112+ #[Test]
112113 public function onKernelControllerDoesNotReplaceDeterminedControllerIfLastModifiedIsGreaterThanIfNotModifiedSinceHeader (): void
113114 {
114115 $ this ->request ->headers ->set ('If-Modified-Since ' , '-2 day ' );
@@ -118,9 +119,7 @@ public function onKernelControllerDoesNotReplaceDeterminedControllerIfLastModifi
118119 $ this ->assertRegularControllerResponse ();
119120 }
120121
121- /**
122- * @test
123- */
122+ #[Test]
124123 public function onKernelResponseSetsLastModifiedHeaderToResponseIfAvailable (): void
125124 {
126125 $ this ->exerciseOnKernelController ([DummyController::class, 'oneDayAgoModifiedLastModifiedAction ' ]);
@@ -131,7 +130,7 @@ public function onKernelResponseSetsLastModifiedHeaderToResponseIfAvailable(): v
131130 self ::assertEquals (DateTime::createFromFormat ('U ' , time () - 86400 ), $ this ->response ->getLastModified ());
132131 }
133132
134- /** @test */
133+ #[Test]
135134 public function onKernelResponseDoesNotSetLastModifiedHeaderToResponseIfNotAvailable (): void
136135 {
137136 $ this ->exerciseOnKernelController ([DummyController::class, 'abstainingLastModifiedAction ' ]);
@@ -142,7 +141,7 @@ public function onKernelResponseDoesNotSetLastModifiedHeaderToResponseIfNotAvail
142141 self ::assertNull ($ this ->response ->getLastModified ());
143142 }
144143
145- /** @test */
144+ #[Test]
146145 public function eventListenerDifferentiatesBetweenMultipleRequests (): void
147146 {
148147 $ this ->exerciseOnKernelController ([DummyController::class, 'oneDayAgoModifiedLastModifiedAction ' ]);
@@ -160,7 +159,7 @@ public function eventListenerDifferentiatesBetweenMultipleRequests(): void
160159 self ::assertNull ($ anotherResponse ->getLastModified ());
161160 }
162161
163- /** @test */
162+ #[Test]
164163 public function onKernelControllerSearchesEventInsteadOfControllerForAttribute (): void
165164 {
166165 // setup an event that should lead to a NotModified response
@@ -186,7 +185,7 @@ function () {
186185 self ::assertNotModifiedResponse ();
187186 }
188187
189- /** @test */
188+ #[Test]
190189 public function onKernelControllerSavesOriginalControllerAttributesWhenReplacingTheController (): void
191190 {
192191 $ this ->request ->headers ->set ('If-Modified-Since ' , '-1 hour ' );
@@ -196,7 +195,7 @@ public function onKernelControllerSavesOriginalControllerAttributesWhenReplacing
196195 self ::assertNotEmpty ($ this ->filterControllerEvent ->getAttributes ());
197196 }
198197
199- /** @test */
198+ #[Test]
200199 public function onKernelControllerThrowsExceptionIfAttributeIsFoundMoreThanOnce (): void
201200 {
202201 self ::expectException (Error::class);
0 commit comments