The Laracasts/flash package is an amazing solution to send Bootstrap 3 styled flash messages to the user’s screen.
After you have set it up, you can do something like this in your controller:
public function store() { flash('Welcome Aboard!'); return home(); }
And you get a flash message looking like this:
But how do you test the flash message was actually sent using phpunit?
Luckily, someone already had figured out a solution. Paul-Henri L (@paulhenri-l) shared an easy-to-overlook snippet at the repository.
I adapted it a bit to suit my needs and refactored it into a trait. I have been using it a lot over the last weeks.
Here is the CanAssertFlash trait, and an example of how to use it.
Enjoy!