On my last post about sending email notification using observer, I forgot to add its test when building it. Our team adopted TDD and although I am not a big fan of it, I slowly liked it and learned how beneficial it is to follow. But since I am not really talking about TDD, you may search its advantages and also why I was not a big fan.
As you can see on my last post that I have two methods hooked on the model events, created and deleted so the test I have created for them is a unit tests.
To create a unit test you run
php artisan make:test ClaroomObserverTest --unit and the file can be found in test/Unit.
Or a refactored version based on my last post about pivot table. The code will look cooler like this: