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,7 +45,7 @@ public function testItHasAFlowMeasure()
4345 new NotificationReissuer (
4446 $ this ->flowMeasure ,
4547 DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED ,
46- new EcfmpWebhook ()
48+ $ this -> webhook
4749 )
4850 )->measure ()
4951 );
@@ -68,7 +70,7 @@ public function testItsAReissueIfItsNotifiedAndTheIdentifierHasChanged()
6870 new NotificationReissuer (
6971 $ this ->flowMeasure ,
7072 DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED ,
71- new EcfmpWebhook ()
73+ $ this -> webhook
7274 )
7375 )->isReissuedNotification ()
7476 );
@@ -93,7 +95,7 @@ public function testItsAReissueIfItsActivatedAndTheIdentifierHasChanged()
9395 new NotificationReissuer (
9496 $ this ->flowMeasure ,
9597 DiscordNotificationTypeEnum::FLOW_MEASURE_ACTIVATED ,
96- new EcfmpWebhook ()
98+ $ this -> webhook
9799 )
98100 )->isReissuedNotification ()
99101 );
@@ -118,45 +120,7 @@ public function testItsAReissueIfItWasNotifiedAndTheIdentifierHasChangedForActiv
118120 new NotificationReissuer (
119121 $ this ->flowMeasure ,
120122 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 ()
123+ $ this ->webhook
160124 )
161125 )->isReissuedNotification ()
162126 );
@@ -169,9 +133,8 @@ public function testItsAReissueIfItsNotifiedOnADifferentDivisionWebhook()
169133 ->toDivisionWebhook ($ otherDivisionWebhook )
170134 ->create ();
171135
172- $ divisionWebhook = DivisionDiscordWebhook::factory ()->create ();
173136 $ previousDivisionNotification = DivisionDiscordNotification::factory ()
174- ->toDivisionWebhook ($ divisionWebhook )
137+ ->toDivisionWebhook ($ this -> webhook )
175138 ->create ();
176139
177140 $ this ->flowMeasure ->divisionDiscordNotifications ()->sync (
@@ -196,7 +159,7 @@ public function testItsAReissueIfItsNotifiedOnADifferentDivisionWebhook()
196159 new NotificationReissuer (
197160 $ this ->flowMeasure ,
198161 DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED ,
199- $ divisionWebhook
162+ $ this -> webhook
200163 )
201164 )->isReissuedNotification ()
202165 );
@@ -209,9 +172,8 @@ public function testItsAReissueIfItsActivatedOnADifferentDivisionWebhook()
209172 ->toDivisionWebhook ($ otherDivisionWebhook )
210173 ->create ();
211174
212- $ divisionWebhook = DivisionDiscordWebhook::factory ()->create ();
213175 $ previousDivisionNotification = DivisionDiscordNotification::factory ()
214- ->toDivisionWebhook ($ divisionWebhook )
176+ ->toDivisionWebhook ($ this -> webhook )
215177 ->create ();
216178
217179 $ this ->flowMeasure ->divisionDiscordNotifications ()->sync (
@@ -236,34 +198,7 @@ public function testItsAReissueIfItsActivatedOnADifferentDivisionWebhook()
236198 new NotificationReissuer (
237199 $ this ->flowMeasure ,
238200 DiscordNotificationTypeEnum::FLOW_MEASURE_ACTIVATED ,
239- $ divisionWebhook
240- )
241- )->isReissuedNotification ()
242- );
243- }
244-
245- public function testItsAReissueIfItsActivatedOnAEcfmpWebhook ()
246- {
247- $ previousNotification = DivisionDiscordNotification::factory ()
248- ->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 ()
201+ $ this ->webhook
267202 )
268203 )->isReissuedNotification ()
269204 );
@@ -288,7 +223,7 @@ public function testItIsNotAReissueIfItsNotifiedAndTheIdentifierHasNotChanged()
288223 new NotificationReissuer (
289224 $ this ->flowMeasure ,
290225 DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED ,
291- new EcfmpWebhook ()
226+ $ this -> webhook
292227 )
293228 )->isReissuedNotification ()
294229 );
@@ -313,7 +248,7 @@ public function testItIsNotAReissueIfItsActivatedAndTheIdentifierHasNotChanged()
313248 new NotificationReissuer (
314249 $ this ->flowMeasure ,
315250 DiscordNotificationTypeEnum::FLOW_MEASURE_ACTIVATED ,
316- new EcfmpWebhook ()
251+ $ this -> webhook
317252 )
318253 )->isReissuedNotification ()
319254 );
@@ -338,7 +273,7 @@ public function testItIsNotAReissueIfItsNotifiedAndThenActivatedTheIdentifierHas
338273 new NotificationReissuer (
339274 $ this ->flowMeasure ,
340275 DiscordNotificationTypeEnum::FLOW_MEASURE_ACTIVATED ,
341- new EcfmpWebhook ()
276+ $ this -> webhook
342277 )
343278 )->isReissuedNotification ()
344279 );
@@ -351,7 +286,7 @@ public function testItIsNotAReissueIfItsNotifiedAndNeverBeenNotified()
351286 new NotificationReissuer (
352287 $ this ->flowMeasure ,
353288 DiscordNotificationTypeEnum::FLOW_MEASURE_NOTIFIED ,
354- new EcfmpWebhook ()
289+ $ this -> webhook
355290 )
356291 )->isReissuedNotification ()
357292 );
@@ -364,7 +299,7 @@ public function testItIsNotAReissueIfItsNotifiedAndNeverBeenActivated()
364299 new NotificationReissuer (
365300 $ this ->flowMeasure ,
366301 DiscordNotificationTypeEnum::FLOW_MEASURE_ACTIVATED ,
367- new EcfmpWebhook ()
302+ $ this -> webhook
368303 )
369304 )->isReissuedNotification ()
370305 );
@@ -389,7 +324,7 @@ public function testItIsNotAReissueIfItsWithdrawn()
389324 new NotificationReissuer (
390325 $ this ->flowMeasure ,
391326 DiscordNotificationTypeEnum::FLOW_MEASURE_WITHDRAWN ,
392- new EcfmpWebhook ()
327+ $ this -> webhook
393328 )
394329 )->isReissuedNotification ()
395330 );
@@ -414,7 +349,7 @@ public function testItIsNotAReissueIfItsExpired()
414349 new NotificationReissuer (
415350 $ this ->flowMeasure ,
416351 DiscordNotificationTypeEnum::FLOW_MEASURE_EXPIRED ,
417- new EcfmpWebhook ()
352+ $ this -> webhook
418353 )
419354 )->isReissuedNotification ()
420355 );
0 commit comments