Skip to content

Commit ac66840

Browse files
committed
Test instructing an event listener to be queued
1 parent 606217e commit ac66840

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

app/Listeners/OrderCreationListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Illuminate\Contracts\Queue\ShouldQueue;
77
use Illuminate\Queue\InteractsWithQueue;
88

9-
class OrderCreationListener
9+
class OrderCreationListener implements ShouldQueue
1010
{
1111
/**
1212
* Create the event listener.

tests/Feature/EventTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use App\Models\User;
1515
use Illuminate\Auth\Events\Login;
1616
use Illuminate\Auth\Events\Logout;
17+
use Illuminate\Contracts\Queue\ShouldQueue;
1718
use Illuminate\Foundation\Testing\RefreshDatabase;
1819
use Illuminate\Foundation\Testing\WithFaker;
1920
use Illuminate\Support\Facades\Event;
@@ -139,4 +140,13 @@ public function subscribing_to_logout_event()
139140
return $event->user->email === $user->email;
140141
});
141142
}
143+
144+
/** @test */
145+
public function an_event_listener_can_be_instructed_to_be_queued()
146+
{
147+
$this->assertInstanceOf(
148+
ShouldQueue::class,
149+
app(OrderCreationListener::class)
150+
);
151+
}
142152
}

0 commit comments

Comments
 (0)