Skip to content

Commit 61cc1c9

Browse files
author
Andy Ford
committed
test: fix tests
1 parent 6b97ced commit 61cc1c9

2 files changed

Lines changed: 31 additions & 11 deletions

File tree

tests/Discord/FlowMeasure/Helper/NotificationReissuerTest.php

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ public function testItHasAFlowMeasure()
5353

5454
public function testItsAReissueIfItsNotifiedAndTheIdentifierHasChanged()
5555
{
56-
$previousNotification = DivisionDiscordNotification::factory()->create();
56+
$previousNotification = DivisionDiscordNotification::factory()
57+
->toDivisionWebhook($this->webhook)
58+
->create();
5759
$this->flowMeasure->divisionDiscordNotifications()->sync(
5860
[
5961
$previousNotification->id => [
@@ -78,7 +80,9 @@ public function testItsAReissueIfItsNotifiedAndTheIdentifierHasChanged()
7880

7981
public function testItsAReissueIfItsActivatedAndTheIdentifierHasChanged()
8082
{
81-
$previousNotification = DivisionDiscordNotification::factory()->create();
83+
$previousNotification = DivisionDiscordNotification::factory()
84+
->toDivisionWebhook($this->webhook)
85+
->create();
8286
$this->flowMeasure->divisionDiscordNotifications()->sync(
8387
[
8488
$previousNotification->id => [
@@ -103,7 +107,9 @@ public function testItsAReissueIfItsActivatedAndTheIdentifierHasChanged()
103107

104108
public function testItsAReissueIfItWasNotifiedAndTheIdentifierHasChangedForActivation()
105109
{
106-
$previousNotification = DivisionDiscordNotification::factory()->create();
110+
$previousNotification = DivisionDiscordNotification::factory()
111+
->toDivisionWebhook($this->webhook)
112+
->create();
107113
$this->flowMeasure->divisionDiscordNotifications()->sync(
108114
[
109115
$previousNotification->id => [
@@ -206,7 +212,9 @@ public function testItsAReissueIfItsActivatedOnADifferentDivisionWebhook()
206212

207213
public function testItIsNotAReissueIfItsNotifiedAndTheIdentifierHasNotChanged()
208214
{
209-
$previousNotification = DivisionDiscordNotification::factory()->create();
215+
$previousNotification = DivisionDiscordNotification::factory()
216+
->toDivisionWebhook($this->webhook)
217+
->create();
210218
$this->flowMeasure->divisionDiscordNotifications()->sync(
211219
[
212220
$previousNotification->id => [
@@ -231,7 +239,9 @@ public function testItIsNotAReissueIfItsNotifiedAndTheIdentifierHasNotChanged()
231239

232240
public function testItIsNotAReissueIfItsActivatedAndTheIdentifierHasNotChanged()
233241
{
234-
$previousNotification = DivisionDiscordNotification::factory()->create();
242+
$previousNotification = DivisionDiscordNotification::factory()
243+
->toDivisionWebhook($this->webhook)
244+
->create();
235245
$this->flowMeasure->divisionDiscordNotifications()->sync(
236246
[
237247
$previousNotification->id => [
@@ -256,7 +266,9 @@ public function testItIsNotAReissueIfItsActivatedAndTheIdentifierHasNotChanged()
256266

257267
public function testItIsNotAReissueIfItsNotifiedAndThenActivatedTheIdentifierHasNotChanged()
258268
{
259-
$previousNotification = DivisionDiscordNotification::factory()->create();
269+
$previousNotification = DivisionDiscordNotification::factory()
270+
->toDivisionWebhook($this->webhook)
271+
->create();
260272
$this->flowMeasure->divisionDiscordNotifications()->sync(
261273
[
262274
$previousNotification->id => [
@@ -307,7 +319,9 @@ public function testItIsNotAReissueIfItsNotifiedAndNeverBeenActivated()
307319

308320
public function testItIsNotAReissueIfItsWithdrawn()
309321
{
310-
$previousNotification = DivisionDiscordNotification::factory()->create();
322+
$previousNotification = DivisionDiscordNotification::factory()
323+
->toDivisionWebhook($this->webhook)
324+
->create();
311325
$this->flowMeasure->divisionDiscordNotifications()->sync(
312326
[
313327
$previousNotification->id => [
@@ -332,7 +346,9 @@ public function testItIsNotAReissueIfItsWithdrawn()
332346

333347
public function testItIsNotAReissueIfItsExpired()
334348
{
335-
$previousNotification = DivisionDiscordNotification::factory()->create();
349+
$previousNotification = DivisionDiscordNotification::factory()
350+
->toDivisionWebhook($this->webhook)
351+
->create();
336352
$this->flowMeasure->divisionDiscordNotifications()->sync(
337353
[
338354
$previousNotification->id => [

tests/Discord/FlowMeasure/Webhook/WebhookMapperTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ function (FlightInformationRegion $flightInformationRegion) {
8989
$this->filter->shouldReceive('shouldUseWebhook')
9090
->andReturnTrue();
9191

92-
$this->assertCount(3, $this->mapper->mapToWebhooks($flowMeasure));
92+
$this->assertCount(2, $this->mapper->mapToWebhooks($flowMeasure));
93+
$this->assertEquals(
94+
DivisionDiscordWebhook::all()->pluck('id'),
95+
$this->mapper->mapToWebhooks($flowMeasure)->map(fn (WebhookInterface $webhook) => $webhook->id())
96+
);
9397
}
9498

9599
public function testItDeduplicatesWebhooks()
@@ -129,9 +133,9 @@ function (FlightInformationRegion $flightInformationRegion) use ($webhook1) {
129133
$this->filter->shouldReceive('shouldUseWebhook')
130134
->andReturnTrue();
131135

132-
$this->assertCount(3, $this->mapper->mapToWebhooks($flowMeasure));
136+
$this->assertCount(2, $this->mapper->mapToWebhooks($flowMeasure));
133137
$this->assertEquals(
134-
new Collection([null, $webhook1->id, $webhook2->id]),
138+
new Collection([$webhook1->id, $webhook2->id]),
135139
$this->mapper->mapToWebhooks($flowMeasure)->map(fn (WebhookInterface $webhook) => $webhook->id())
136140
);
137141
}

0 commit comments

Comments
 (0)