Testing with(out) dependencies
Why distinguishing between test stubs and mock objects in PHPUnit significantly improves the quality and readability of tests.
On and , I was at SymfonyOnline. There I gave the presentation "Testing with(out) dependencies".
This presentation clarifies effective strategies for using PHPUnit's test doubles to write robust, maintainable unit tests, highlighting practical techniques and common pitfalls to avoid.
More informationMy name is Sebastian Bergmann, and I have been working as a software developer and consultant in the PHP ecosystem for over 25 years. I support development teams in creating better software through modern practices, tools and training.
I am deeply committed to Open Source, maintain critical Open Source projects in the PHP ecosystem, and help shape the work of the PHP Foundation as a member of its board. I have also represented the interests of Open Source at the European Commission and am active in the Open Source Working Group ("Arbeitskreis Open Source Software") of the German Informatics Society ("Gesellschaft fΓΌr Informatik").
I live and breathe Open Source and help shape how developers around the world test, write, and maintain their code.
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.
Why distinguishing between test stubs and mock objects in PHPUnit significantly improves the quality and readability of tests.
The any() matcher is deprecated. But migration is easier than you think β and leads to better tests.
I explain how PHPUnit 13's parameter set matchers finally solve the problem that made upgrading to PHPUnit 10 such a challenge.
Self-sabotaging mock objects? With PHPUnit 12.5, that's a thing of the past because the test runner now asks the right question: Do you really need a mock object, or would a test stub suffice?
Do you want your team to get better at testing? I can help with consulting, coaching, and training.