Behat tutorial part 2: testing Symfony 6 application

In part 1 we saw how to write a behat test. It's now time to use this knowledge to test our real-world application! Please notice that this tutorial will work with most versions of Symfony since behat is compatible with Symfony 4, 5, and 6. The project we…

Test emails with Symfony

Symfony 4 brought us the awesome Mailer Component. Something that you may not know about it, is how to test if an email has been sent. This is something not well known, but actually easy! Let's see together how to do it with PHPUnit, but also with Behat…

Simple strategy pattern with Symfony

The strategy pattern is a very easy implementation with the DIC from Symfony. Here is how: First let's define an interface for our strategies: namespace App\Domain\CustomProcess; interface MyStrategyInterface { public function execute(Whatever $input); public function supports(Whatever $input); } Then, we will add the tag app.my_…

Easy locks with Symfony

The Symfony documentation describes quite well how locks actually work, that's why this article will not describe why you should use a lock and how it actually works. But it says nothing about the short time installation it requires to set it up and run! Let's…