A lot of people will tell you that unit testing in PHP is easy, but in practice it’s one of the hardest disciplines to get right. When you’ve never written unit tests before you’ll probably have a million questions really fast; your code has got a lot of dependencies, runs queries on your database and sends out e-mails, and there seems to be no way to write reliable tests for this code that you can actually use time after time.
This talk is a hands-on introduction to writing unit tests using PHPUnit. We’ll be writing some actual unit tests for (sometimes problematic) pieces of code that you could come across while testing real-life applications. I’ll explain how you could apply TDD and how to use it into your advantage, and I’ll come with some suggestions on how you could convince your boss that unit testing is important and actually worth the effort on the long run.