1313
1414namespace ProophTest \Common \Event ;
1515
16+ use PHPUnit \Framework \Attributes \Test ;
1617use PHPUnit \Framework \TestCase ;
1718use Prooph \Common \Event \ActionEvent ;
1819use Prooph \Common \Event \ListenerHandler ;
@@ -29,9 +30,7 @@ protected function setUp(): void
2930 $ this ->proophActionEventEmitter = new ProophActionEventEmitter ();
3031 }
3132
32- /**
33- * @test
34- */
33+ #[Test]
3534 public function it_attaches_action_event_listeners_and_dispatch_event_to_them (): void
3635 {
3736 $ lastEvent = null ;
@@ -52,9 +51,7 @@ public function it_attaches_action_event_listeners_and_dispatch_event_to_them():
5251 $ this ->assertSame ($ lastEvent , $ listener1 ->lastEvent );
5352 }
5453
55- /**
56- * @test
57- */
54+ #[Test]
5855 public function it_detaches_a_listener (): void
5956 {
6057 $ lastEvent = null ;
@@ -78,9 +75,7 @@ public function it_detaches_a_listener(): void
7875 $ this ->assertSame ($ actionEvent , $ lastEvent );
7976 }
8077
81- /**
82- * @test
83- */
78+ #[Test]
8479 public function it_triggers_listeners_until_callback_returns_true (): void
8580 {
8681 $ lastEvent = null ;
@@ -103,9 +98,7 @@ public function it_triggers_listeners_until_callback_returns_true(): void
10398 $ this ->assertSame ($ actionEvent , $ listener1 ->lastEvent );
10499 }
105100
106- /**
107- * @test
108- */
101+ #[Test]
109102 public function it_stops_dispatching_when_event_propagation_is_stopped (): void
110103 {
111104 $ lastEvent = null ;
@@ -131,9 +124,7 @@ public function it_stops_dispatching_when_event_propagation_is_stopped(): void
131124 $ this ->assertSame ($ actionEvent , $ listener1 ->lastEvent );
132125 }
133126
134- /**
135- * @test
136- */
127+ #[Test]
137128 public function it_stops_dispatching_when_event_propagation_is_stopped_2 (): void
138129 {
139130 $ lastEvent = null ;
@@ -160,9 +151,7 @@ public function it_stops_dispatching_when_event_propagation_is_stopped_2(): void
160151 $ this ->assertSame ($ actionEvent , $ listener1 ->lastEvent );
161152 }
162153
163- /**
164- * @test
165- */
154+ #[Test]
166155 public function it_triggers_listeners_with_high_priority_first (): void
167156 {
168157 $ lastEvent = null ;
@@ -188,9 +177,7 @@ public function it_triggers_listeners_with_high_priority_first(): void
188177 $ this ->assertNull ($ listener1 ->lastEvent );
189178 }
190179
191- /**
192- * @test
193- */
180+ #[Test]
194181 public function it_attaches_a_listener_aggregate (): void
195182 {
196183 $ listener1 = new ActionEventListenerMock ();
@@ -207,9 +194,7 @@ public function it_attaches_a_listener_aggregate(): void
207194 $ this ->assertNull ($ listener1 ->lastEvent );
208195 }
209196
210- /**
211- * @test
212- */
197+ #[Test]
213198 public function it_detaches_listener_aggregate (): void
214199 {
215200 $ listener1 = new ActionEventListenerMock ();
@@ -227,48 +212,44 @@ public function it_detaches_listener_aggregate(): void
227212 $ this ->assertSame ($ actionEvent , $ listener1 ->lastEvent );
228213 }
229214
230- /**
231- * @test
232- */
215+ #[Test]
233216 public function it_uses_default_event_name_if_none_given (): void
234217 {
235218 $ event = $ this ->proophActionEventEmitter ->getNewActionEvent ();
236219 $ this ->assertEquals ('action_event ' , $ event ->getName ());
237220 }
238221
239- /**
240- * @test
241- */
222+ #[Test]
242223 public function it_returns_false_when_unattached_listener_handler_gets_detached (): void
243224 {
244- $ listener = $ this ->getMockForAbstractClass (ListenerHandler::class);
225+ $ listener = $ this ->getMockBuilder (ListenerHandler::class)
226+ ->onlyMethods (['getActionEventListener ' ])
227+ ->getMock ();
245228
246229 $ this ->assertFalse ($ this ->proophActionEventEmitter ->detachListener ($ listener ));
247230 }
248231
249- /**
250- * @test
251- */
252- public function it_dispatches_until_whith_no_listeners_attached (): void
232+ #[Test]
233+ public function it_dispatches_until_with_no_listeners_attached (): void
253234 {
235+ $ this ->expectNotToPerformAssertions ();
236+
254237 $ actionEventMock = $ this ->createMock (ActionEvent::class);
255238
256239 $ this ->proophActionEventEmitter ->dispatchUntil ($ actionEventMock , fn () => true );
257240 }
258241
259- /**
260- * @test
261- */
242+ #[Test]
262243 public function it_attaches_to_known_event_names (): void
263244 {
245+ $ this ->expectNotToPerformAssertions ();
246+
264247 $ proophActionEventEmitter = new ProophActionEventEmitter (['foo ' ]);
265248 $ proophActionEventEmitter ->attachListener ('foo ' , function (): void {
266249 });
267250 }
268251
269- /**
270- * @test
271- */
252+ #[Test]
272253 public function it_does_not_attach_to_unknown_event_names (): void
273254 {
274255 $ this ->expectException (\InvalidArgumentException::class);
0 commit comments