33namespace Tests \Discord \FlowMeasure \Helper ;
44
55use App \Discord \FlowMeasure \Helper \NotificationReissuer ;
6- use App \Discord \Webhook \EcfmpWebhook ;
76use App \Enums \DiscordNotificationType as DiscordNotificationTypeEnum ;
87use App \Models \DivisionDiscordNotification ;
98use App \Models \DiscordNotificationType ;
1413class NotificationReissuerTest extends TestCase
1514{
1615 private readonly FlowMeasure $ flowMeasure ;
16+ private readonly DivisionDiscordWebhook $ webhook ;
1717
1818 public function setUp (): void
1919 {
2020 parent ::setUp ();
2121 $ this ->flowMeasure = FlowMeasure::factory ()->create ();
22+ $ this ->webhook = DivisionDiscordWebhook::factory ()
23+ ->create ();
2224 }
2325
2426 public function testItHasAType ()
@@ -29,7 +31,7 @@ public function testItHasAType()
2931 new NotificationReissuer (
3032 $ this ->flowMeasure ,
3133 DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED ,
32- new EcfmpWebhook ()
34+ $ this -> webhook
3335 )
3436 )->type ()
3537 );
@@ -43,15 +45,17 @@ public function testItHasAFlowMeasure()
4345 new NotificationReissuer (
4446 $ this ->flowMeasure ,
4547 DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED ,
46- new EcfmpWebhook ()
48+ $ this -> webhook
4749 )
4850 )->measure ()
4951 );
5052 }
5153
5254 public function testItsAReissueIfItsNotifiedAndTheIdentifierHasChanged ()
5355 {
54- $ previousNotification = DivisionDiscordNotification::factory ()->create ();
56+ $ previousNotification = DivisionDiscordNotification::factory ()
57+ ->toDivisionWebhook ($ this ->webhook )
58+ ->create ();
5559 $ this ->flowMeasure ->divisionDiscordNotifications ()->sync (
5660 [
5761 $ previousNotification ->id => [
@@ -68,15 +72,17 @@ public function testItsAReissueIfItsNotifiedAndTheIdentifierHasChanged()
6872 new NotificationReissuer (
6973 $ this ->flowMeasure ,
7074 DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED ,
71- new EcfmpWebhook ()
75+ $ this -> webhook
7276 )
7377 )->isReissuedNotification ()
7478 );
7579 }
7680
7781 public function testItsAReissueIfItsActivatedAndTheIdentifierHasChanged ()
7882 {
79- $ previousNotification = DivisionDiscordNotification::factory ()->create ();
83+ $ previousNotification = DivisionDiscordNotification::factory ()
84+ ->toDivisionWebhook ($ this ->webhook )
85+ ->create ();
8086 $ this ->flowMeasure ->divisionDiscordNotifications ()->sync (
8187 [
8288 $ previousNotification ->id => [
@@ -93,15 +99,17 @@ public function testItsAReissueIfItsActivatedAndTheIdentifierHasChanged()
9399 new NotificationReissuer (
94100 $ this ->flowMeasure ,
95101 DiscordNotificationTypeEnum::FLOW_MEASURE_ACTIVATED ,
96- new EcfmpWebhook ()
102+ $ this -> webhook
97103 )
98104 )->isReissuedNotification ()
99105 );
100106 }
101107
102108 public function testItsAReissueIfItWasNotifiedAndTheIdentifierHasChangedForActivation ()
103109 {
104- $ previousNotification = DivisionDiscordNotification::factory ()->create ();
110+ $ previousNotification = DivisionDiscordNotification::factory ()
111+ ->toDivisionWebhook ($ this ->webhook )
112+ ->create ();
105113 $ this ->flowMeasure ->divisionDiscordNotifications ()->sync (
106114 [
107115 $ previousNotification ->id => [
@@ -118,45 +126,7 @@ public function testItsAReissueIfItWasNotifiedAndTheIdentifierHasChangedForActiv
118126 new NotificationReissuer (
119127 $ this ->flowMeasure ,
120128 DiscordNotificationTypeEnum::FLOW_MEASURE_ACTIVATED ,
121- new EcfmpWebhook ()
122- )
123- )->isReissuedNotification ()
124- );
125- }
126-
127- public function testItsAReissueIfItsNotifiedOnAEcfmpWebhook ()
128- {
129- $ previousNotificationEcfmp = DivisionDiscordNotification::factory ()
130- ->create ();
131-
132- $ divisionWebhook = DivisionDiscordWebhook::factory ()->create ();
133- $ previousDivisionNotification = DivisionDiscordNotification::factory ()
134- ->toDivisionWebhook ($ divisionWebhook )
135- ->create ();
136-
137- $ this ->flowMeasure ->divisionDiscordNotifications ()->sync (
138- [
139- $ previousNotificationEcfmp ->id => [
140- 'discord_notification_type_id ' => DiscordNotificationType::idFromEnum (
141- DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED
142- ),
143- 'notified_as ' => 'notthis ' ,
144- ],
145- $ previousDivisionNotification ->id => [
146- 'discord_notification_type_id ' => DiscordNotificationType::idFromEnum (
147- DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED
148- ),
149- 'notified_as ' => $ this ->flowMeasure ->identifier ,
150- ],
151- ]
152- );
153-
154- $ this ->assertTrue (
155- (
156- new NotificationReissuer (
157- $ this ->flowMeasure ,
158- DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED ,
159- new EcfmpWebhook ()
129+ $ this ->webhook
160130 )
161131 )->isReissuedNotification ()
162132 );
@@ -169,9 +139,8 @@ public function testItsAReissueIfItsNotifiedOnADifferentDivisionWebhook()
169139 ->toDivisionWebhook ($ otherDivisionWebhook )
170140 ->create ();
171141
172- $ divisionWebhook = DivisionDiscordWebhook::factory ()->create ();
173142 $ previousDivisionNotification = DivisionDiscordNotification::factory ()
174- ->toDivisionWebhook ($ divisionWebhook )
143+ ->toDivisionWebhook ($ this -> webhook )
175144 ->create ();
176145
177146 $ this ->flowMeasure ->divisionDiscordNotifications ()->sync (
@@ -196,7 +165,7 @@ public function testItsAReissueIfItsNotifiedOnADifferentDivisionWebhook()
196165 new NotificationReissuer (
197166 $ this ->flowMeasure ,
198167 DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED ,
199- $ divisionWebhook
168+ $ this -> webhook
200169 )
201170 )->isReissuedNotification ()
202171 );
@@ -209,9 +178,8 @@ public function testItsAReissueIfItsActivatedOnADifferentDivisionWebhook()
209178 ->toDivisionWebhook ($ otherDivisionWebhook )
210179 ->create ();
211180
212- $ divisionWebhook = DivisionDiscordWebhook::factory ()->create ();
213181 $ previousDivisionNotification = DivisionDiscordNotification::factory ()
214- ->toDivisionWebhook ($ divisionWebhook )
182+ ->toDivisionWebhook ($ this -> webhook )
215183 ->create ();
216184
217185 $ this ->flowMeasure ->divisionDiscordNotifications ()->sync (
@@ -236,42 +204,17 @@ public function testItsAReissueIfItsActivatedOnADifferentDivisionWebhook()
236204 new NotificationReissuer (
237205 $ this ->flowMeasure ,
238206 DiscordNotificationTypeEnum::FLOW_MEASURE_ACTIVATED ,
239- $ divisionWebhook
207+ $ this -> webhook
240208 )
241209 )->isReissuedNotification ()
242210 );
243211 }
244212
245- public function testItsAReissueIfItsActivatedOnAEcfmpWebhook ()
213+ public function testItIsNotAReissueIfItsNotifiedAndTheIdentifierHasNotChanged ()
246214 {
247215 $ previousNotification = DivisionDiscordNotification::factory ()
216+ ->toDivisionWebhook ($ this ->webhook )
248217 ->create ();
249-
250- $ this ->flowMeasure ->divisionDiscordNotifications ()->sync (
251- [
252- $ previousNotification ->id => [
253- 'discord_notification_type_id ' => DiscordNotificationType::idFromEnum (
254- DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED
255- ),
256- 'notified_as ' => 'nothis ' ,
257- ],
258- ]
259- );
260-
261- $ this ->assertTrue (
262- (
263- new NotificationReissuer (
264- $ this ->flowMeasure ,
265- DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED ,
266- new EcfmpWebhook ()
267- )
268- )->isReissuedNotification ()
269- );
270- }
271-
272- public function testItIsNotAReissueIfItsNotifiedAndTheIdentifierHasNotChanged ()
273- {
274- $ previousNotification = DivisionDiscordNotification::factory ()->create ();
275218 $ this ->flowMeasure ->divisionDiscordNotifications ()->sync (
276219 [
277220 $ previousNotification ->id => [
@@ -288,15 +231,17 @@ public function testItIsNotAReissueIfItsNotifiedAndTheIdentifierHasNotChanged()
288231 new NotificationReissuer (
289232 $ this ->flowMeasure ,
290233 DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED ,
291- new EcfmpWebhook ()
234+ $ this -> webhook
292235 )
293236 )->isReissuedNotification ()
294237 );
295238 }
296239
297240 public function testItIsNotAReissueIfItsActivatedAndTheIdentifierHasNotChanged ()
298241 {
299- $ previousNotification = DivisionDiscordNotification::factory ()->create ();
242+ $ previousNotification = DivisionDiscordNotification::factory ()
243+ ->toDivisionWebhook ($ this ->webhook )
244+ ->create ();
300245 $ this ->flowMeasure ->divisionDiscordNotifications ()->sync (
301246 [
302247 $ previousNotification ->id => [
@@ -313,15 +258,17 @@ public function testItIsNotAReissueIfItsActivatedAndTheIdentifierHasNotChanged()
313258 new NotificationReissuer (
314259 $ this ->flowMeasure ,
315260 DiscordNotificationTypeEnum::FLOW_MEASURE_ACTIVATED ,
316- new EcfmpWebhook ()
261+ $ this -> webhook
317262 )
318263 )->isReissuedNotification ()
319264 );
320265 }
321266
322267 public function testItIsNotAReissueIfItsNotifiedAndThenActivatedTheIdentifierHasNotChanged ()
323268 {
324- $ previousNotification = DivisionDiscordNotification::factory ()->create ();
269+ $ previousNotification = DivisionDiscordNotification::factory ()
270+ ->toDivisionWebhook ($ this ->webhook )
271+ ->create ();
325272 $ this ->flowMeasure ->divisionDiscordNotifications ()->sync (
326273 [
327274 $ previousNotification ->id => [
@@ -338,7 +285,7 @@ public function testItIsNotAReissueIfItsNotifiedAndThenActivatedTheIdentifierHas
338285 new NotificationReissuer (
339286 $ this ->flowMeasure ,
340287 DiscordNotificationTypeEnum::FLOW_MEASURE_ACTIVATED ,
341- new EcfmpWebhook ()
288+ $ this -> webhook
342289 )
343290 )->isReissuedNotification ()
344291 );
@@ -351,7 +298,7 @@ public function testItIsNotAReissueIfItsNotifiedAndNeverBeenNotified()
351298 new NotificationReissuer (
352299 $ this ->flowMeasure ,
353300 DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED ,
354- new EcfmpWebhook ()
301+ $ this -> webhook
355302 )
356303 )->isReissuedNotification ()
357304 );
@@ -364,15 +311,17 @@ public function testItIsNotAReissueIfItsNotifiedAndNeverBeenActivated()
364311 new NotificationReissuer (
365312 $ this ->flowMeasure ,
366313 DiscordNotificationTypeEnum::FLOW_MEASURE_ACTIVATED ,
367- new EcfmpWebhook ()
314+ $ this -> webhook
368315 )
369316 )->isReissuedNotification ()
370317 );
371318 }
372319
373320 public function testItIsNotAReissueIfItsWithdrawn ()
374321 {
375- $ previousNotification = DivisionDiscordNotification::factory ()->create ();
322+ $ previousNotification = DivisionDiscordNotification::factory ()
323+ ->toDivisionWebhook ($ this ->webhook )
324+ ->create ();
376325 $ this ->flowMeasure ->divisionDiscordNotifications ()->sync (
377326 [
378327 $ previousNotification ->id => [
@@ -389,15 +338,17 @@ public function testItIsNotAReissueIfItsWithdrawn()
389338 new NotificationReissuer (
390339 $ this ->flowMeasure ,
391340 DiscordNotificationTypeEnum::FLOW_MEASURE_WITHDRAWN ,
392- new EcfmpWebhook ()
341+ $ this -> webhook
393342 )
394343 )->isReissuedNotification ()
395344 );
396345 }
397346
398347 public function testItIsNotAReissueIfItsExpired ()
399348 {
400- $ previousNotification = DivisionDiscordNotification::factory ()->create ();
349+ $ previousNotification = DivisionDiscordNotification::factory ()
350+ ->toDivisionWebhook ($ this ->webhook )
351+ ->create ();
401352 $ this ->flowMeasure ->divisionDiscordNotifications ()->sync (
402353 [
403354 $ previousNotification ->id => [
@@ -414,7 +365,7 @@ public function testItIsNotAReissueIfItsExpired()
414365 new NotificationReissuer (
415366 $ this ->flowMeasure ,
416367 DiscordNotificationTypeEnum::FLOW_MEASURE_EXPIRED ,
417- new EcfmpWebhook ()
368+ $ this -> webhook
418369 )
419370 )->isReissuedNotification ()
420371 );
0 commit comments