PHP Code Analysis Through Unit Testing

You are here

This will be a live demo of writing a unit test for an existing class method in Drupal, using the PHPUnit framework.

There will be a general overview of test philosophy, and then the single most exciting thing you'll have ever seen: Live coding a unit test!

Since the time I proposed this talk, its focus has changed to being an overview of maintainability of legacy code. I'll pontificate about metrics and methodology for maximal reduction of terror with code from another time.

Topics we'll cover:

What metrics are available for understanding code quality?

What processes can we use to stay on top of the Code That Ate Pittsburgh?

What's a unit and why would you test it?

What can I learn from a coverage report?

What's an expectation?

Do I really need to mock everything?

To follow along you'll need some kind of code editor and PHP, or you could just watch.

This is an intermediate PHP-based session. We'll be working on Drupal 8 code, but the techniques and strategies apply to any PHP development process.