99use  Ibexa \Contracts \Core \Repository \Events \Notification \BeforeCreateNotificationEvent ;
1010use  Ibexa \Contracts \Core \Repository \Events \Notification \BeforeDeleteNotificationEvent ;
1111use  Ibexa \Contracts \Core \Repository \Events \Notification \BeforeMarkNotificationAsReadEvent ;
12+ use  Ibexa \Contracts \Core \Repository \Events \Notification \BeforeMarkNotificationAsUnreadEvent ;
1213use  Ibexa \Contracts \Core \Repository \Events \Notification \CreateNotificationEvent ;
1314use  Ibexa \Contracts \Core \Repository \Events \Notification \DeleteNotificationEvent ;
1415use  Ibexa \Contracts \Core \Repository \Events \Notification \MarkNotificationAsReadEvent ;
16+ use  Ibexa \Contracts \Core \Repository \Events \Notification \MarkNotificationAsUnreadEvent ;
1517use  Ibexa \Contracts \Core \Repository \NotificationService  as  NotificationServiceInterface ;
1618use  Ibexa \Contracts \Core \Repository \Values \Notification \CreateStruct ;
1719use  Ibexa \Contracts \Core \Repository \Values \Notification \Notification ;
@@ -63,9 +65,13 @@ public function testReturnCreateNotificationResultInBeforeEvents()
6365        $ innerServiceMock$ this createMock (NotificationServiceInterface::class);
6466        $ innerServiceMockmethod ('createNotification ' )->willReturn ($ notification
6567
66-         $ traceableEventDispatcheraddListener (BeforeCreateNotificationEvent::class, static  function  (BeforeCreateNotificationEvent $ eventuse  ($ eventNotification
67-             $ eventsetNotification ($ eventNotification
68-         }, 10 );
68+         $ traceableEventDispatcheraddListener (
69+             BeforeCreateNotificationEvent::class,
70+             static  function  (BeforeCreateNotificationEvent $ eventuse  ($ eventNotificationvoid  {
71+                 $ eventsetNotification ($ eventNotification
72+             },
73+             10 
74+         );
6975
7076        $ servicenew  NotificationService ($ innerServiceMock$ traceableEventDispatcher
7177        $ result$ servicecreateNotification (...$ parameters
@@ -97,10 +103,14 @@ public function testCreateNotificationStopPropagationInBeforeEvents()
97103        $ innerServiceMock$ this createMock (NotificationServiceInterface::class);
98104        $ innerServiceMockmethod ('createNotification ' )->willReturn ($ notification
99105
100-         $ traceableEventDispatcheraddListener (BeforeCreateNotificationEvent::class, static  function  (BeforeCreateNotificationEvent $ eventuse  ($ eventNotification
101-             $ eventsetNotification ($ eventNotification
102-             $ eventstopPropagation ();
103-         }, 10 );
106+         $ traceableEventDispatcheraddListener (
107+             BeforeCreateNotificationEvent::class,
108+             static  function  (BeforeCreateNotificationEvent $ eventuse  ($ eventNotificationvoid  {
109+                 $ eventsetNotification ($ eventNotification
110+                 $ eventstopPropagation ();
111+             },
112+             10 
113+         );
104114
105115        $ servicenew  NotificationService ($ innerServiceMock$ traceableEventDispatcher
106116        $ result$ servicecreateNotification (...$ parameters
@@ -156,9 +166,13 @@ public function testDeleteNotificationStopPropagationInBeforeEvents()
156166
157167        $ innerServiceMock$ this createMock (NotificationServiceInterface::class);
158168
159-         $ traceableEventDispatcheraddListener (BeforeDeleteNotificationEvent::class, static  function  (BeforeDeleteNotificationEvent $ event
160-             $ eventstopPropagation ();
161-         }, 10 );
169+         $ traceableEventDispatcheraddListener (
170+             BeforeDeleteNotificationEvent::class,
171+             static  function  (BeforeDeleteNotificationEvent $ eventvoid  {
172+                 $ eventstopPropagation ();
173+             },
174+             10 
175+         );
162176
163177        $ servicenew  NotificationService ($ innerServiceMock$ traceableEventDispatcher
164178        $ servicedeleteNotification (...$ parameters
@@ -200,6 +214,31 @@ public function testMarkNotificationAsReadEvents()
200214        $ this assertSame ([], $ traceableEventDispatchergetNotCalledListeners ());
201215    }
202216
217+     public  function  testMarkNotificationAsUnreadEvents (): void 
218+     {
219+         $ traceableEventDispatcher$ this getEventDispatcher (
220+             BeforeMarkNotificationAsUnreadEvent::class,
221+             MarkNotificationAsUnreadEvent::class
222+         );
223+ 
224+         $ parameters
225+             $ this createMock (Notification::class),
226+         ];
227+ 
228+         $ innerServiceMock$ this createMock (NotificationServiceInterface::class);
229+ 
230+         $ servicenew  NotificationService ($ innerServiceMock$ traceableEventDispatcher
231+         $ servicemarkNotificationAsUnread (...$ parameters
232+ 
233+         $ calledListeners$ this getListenersStack ($ traceableEventDispatchergetCalledListeners ());
234+ 
235+         self ::assertSame ($ calledListeners
236+             [BeforeMarkNotificationAsUnreadEvent::class, 0 ],
237+             [MarkNotificationAsUnreadEvent::class, 0 ],
238+         ]);
239+         self ::assertSame ([], $ traceableEventDispatchergetNotCalledListeners ());
240+     }
241+ 
203242    public  function  testMarkNotificationAsReadStopPropagationInBeforeEvents ()
204243    {
205244        $ traceableEventDispatcher$ this getEventDispatcher (
@@ -213,9 +252,13 @@ public function testMarkNotificationAsReadStopPropagationInBeforeEvents()
213252
214253        $ innerServiceMock$ this createMock (NotificationServiceInterface::class);
215254
216-         $ traceableEventDispatcheraddListener (BeforeMarkNotificationAsReadEvent::class, static  function  (BeforeMarkNotificationAsReadEvent $ event
217-             $ eventstopPropagation ();
218-         }, 10 );
255+         $ traceableEventDispatcheraddListener (
256+             BeforeMarkNotificationAsReadEvent::class,
257+             static  function  (BeforeMarkNotificationAsReadEvent $ eventvoid  {
258+                 $ eventstopPropagation ();
259+             },
260+             10 
261+         );
219262
220263        $ servicenew  NotificationService ($ innerServiceMock$ traceableEventDispatcher
221264        $ servicemarkNotificationAsRead (...$ parameters
@@ -231,6 +274,42 @@ public function testMarkNotificationAsReadStopPropagationInBeforeEvents()
231274            [MarkNotificationAsReadEvent::class, 0 ],
232275        ]);
233276    }
277+ 
278+     public  function  testMarkNotificationAsUnreadStopPropagationInBeforeEvents (): void 
279+     {
280+         $ traceableEventDispatcher$ this getEventDispatcher (
281+             BeforeMarkNotificationAsUnreadEvent::class,
282+             MarkNotificationAsUnreadEvent::class
283+         );
284+ 
285+         $ parameters
286+             $ this createMock (Notification::class),
287+         ];
288+ 
289+         $ innerServiceMock$ this createMock (NotificationServiceInterface::class);
290+ 
291+         $ traceableEventDispatcheraddListener (
292+             BeforeMarkNotificationAsUnreadEvent::class,
293+             static  function  (BeforeMarkNotificationAsUnreadEvent $ eventvoid  {
294+                 $ eventstopPropagation ();
295+             },
296+             10 
297+         );
298+ 
299+         $ servicenew  NotificationService ($ innerServiceMock$ traceableEventDispatcher
300+         $ servicemarkNotificationAsUnread (...$ parameters
301+ 
302+         $ calledListeners$ this getListenersStack ($ traceableEventDispatchergetCalledListeners ());
303+         $ notCalledListeners$ this getListenersStack ($ traceableEventDispatchergetNotCalledListeners ());
304+ 
305+         self ::assertSame ($ calledListeners
306+             [BeforeMarkNotificationAsUnreadEvent::class, 10 ],
307+         ]);
308+         self ::assertSame ($ notCalledListeners
309+             [BeforeMarkNotificationAsUnreadEvent::class, 0 ],
310+             [MarkNotificationAsUnreadEvent::class, 0 ],
311+         ]);
312+     }
234313}
235314
236315class_alias (NotificationServiceTest::class, 'eZ\Publish\Core\Event\Tests\NotificationServiceTest ' );
0 commit comments