Writing Unit Tests Using PHPUnit
summary
Live coding shows PHPUnit used to write real unit tests that actually run and fail then turn green: a simple double() test, a user model test that replaces a mailer with a getMock and asserts the mailer method is called with specific args, and a fix exposed by a reflection call that initially reports bananas as blue. The workflow uses Composer autoloading, PHPUnit assertions and mocks, and coverage reporting including the CRAP index to prioritize what to test.
AI-written summary · about
chapters (20)
- 0:00Introduction
- 1:00Overview
- 2:37Why is unit testing important
- 5:45Writing the first unit test
- 7:33Creating a folder for unit tests
- 15:42Writing unit tests
- 16:22Writing complex unit tests
- 17:02The essence of unit testing
- 27:37Dependency injection
- 29:02Dependency containers
- 32:32Writing testable code
- 33:22Voodoo
- 33:37Testing Private Methods
- 36:32Warning Sign
- 37:22Database Tests
- 38:57Testdriven development
- 39:12Fixing bugs
- 40:32What to test
- 41:27CREP index
- 43:52Conclusion








