Skip to content

Commit

Permalink
Test instructing an event listener to be queued
Browse files Browse the repository at this point in the history
  • Loading branch information
unclexo committed Jan 16, 2023
1 parent 606217e commit ac66840
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/Listeners/OrderCreationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;

class OrderCreationListener
class OrderCreationListener implements ShouldQueue
{
/**
* Create the event listener.
Expand Down
10 changes: 10 additions & 0 deletions tests/Feature/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use App\Models\User;
use Illuminate\Auth\Events\Login;
use Illuminate\Auth\Events\Logout;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Support\Facades\Event;
Expand Down Expand Up @@ -139,4 +140,13 @@ public function subscribing_to_logout_event()
return $event->user->email === $user->email;
});
}

/** @test */
public function an_event_listener_can_be_instructed_to_be_queued()
{
$this->assertInstanceOf(
ShouldQueue::class,
app(OrderCreationListener::class)
);
}
}

0 comments on commit ac66840

Please sign in to comment.