Testing with(out) dependencies

Welcome!

This page is the home of my "Testing with(out) dependencies" presentation. I most recently delivered it at the Symfony User Group Cologne on . Previous events include TYPO3 Developer Days, NEOS Conference, and International PHP Conference.

Testing with(out) dependencies

Testing a unit of code that depends on other components often raises a critical question: when should you replace real dependencies with Test Stubs or Mock Objects, and when should you allow the code under test to collaborate with actual dependencies?

In this presentation, I demystify the effective use of test stubs and mock objects in unit testing. You will gain a clear understanding of how to leverage PHPUnit's test double functionality to write robust tests, while also learning which features to avoid for better maintainability and reliability. By the end of this session, you will be equipped with practical strategies to make informed decisions about dependency handling in your tests.

Material

You can find the latest version of the material I use for this presentation here.

You can find a video recording of this presentation here.

About me

My name is Sebastian Bergmann and I am the creator of PHPUnit, the industry-standard testing framework that has greatly improved the professionalism of PHP software development.

As founding partner of and consultant with The PHP Consulting Company (thePHP.cc), I assist teams in adopting PHPUnit, optimizing its use, refining development workflows, and writing more testable code.

Upcoming events

In case you missed my presentation at the Symfony User Group Cologne, there are plenty more chances coming up to meet me.

The next time I present "Testing with(out) dependencies" will be at SymfonyCon on in Amsterdam.

More events where you can meet me are listed here.

My interactive online training courses are designed to provide you with practical knowledge that you can apply immediately. The next ones starting soon are listed here.

Keep up to date with PHPUnit

You can follow @phpunit@phpc.social to stay up to date with PHPUnit's development.

You can subscribe to the PHPUnit Updates newsletter to receive updates about and tips for PHPUnit.