Skip to content

Commit

Permalink
Test that we are queueing as expected.
Browse files Browse the repository at this point in the history
  • Loading branch information
edwh committed May 30, 2022
1 parent a30a79f commit 4dcb7de
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions tests/Feature/Events/CreateEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,19 @@ public function notifications_are_queued_as_expected()
$group->makeMemberAHost($host);
$this->actingAs($host);

// Clear any jobs queued in earlier tests.
$max = 1000;
do {
$job = Queue::pop();

if ($job) {
$job->fail('removed in UT');
}

$max--;
}
while (Queue::size() > 0 && $max > 0);

// Create an event.
$initialQueueSize = \Illuminate\Support\Facades\Queue::size();
$event = factory(Party::class)->raw();
Expand All @@ -644,13 +657,26 @@ public function notifications_are_queued_as_expected()
// Should have queued AdminModerationEvent.
$queueSize = Queue::size();
self::assertGreaterThan($initialQueueSize, $queueSize);
$max = 1000;
do {
$job = Queue::pop();

if ($job) {
self::assertStringContainsString('AdminModerationEvent', $job->getRawBody());
$job->fail('removed in UT');
}

$max--;
}
while (Queue::size() > 0 && $max > 0);

self::assertEquals(0, Queue::size());

// Approval should generate a notification to the host which is not queued.
$event = Party::latest()->first();
$event->approve();

# Should not have queued anything
$queueSize2 = Queue::size();
self::assertEquals($queueSize, $queueSize2);
self::assertEquals(0, Queue::size());
}
}

0 comments on commit 4dcb7de

Please sign in to comment.