Chapter 13. Best Practices, Testing, and Debugging
In this chapter, we will cover the following topics:
- Using Traits and Interfaces
- Universal exception handler
- Universal error handler
- Writing a simple test
- Writing a test suite
- Generating fake test data
- Customizing sessions using
session_start
parameters
Introduction
In this chapter, we will show you how traits and interfaces work together. Then, we turn our attention to the design of a fallback mechanism that will catch errors and exceptions in situations where you were not able (or forgot) to define specific try/catch
blocks. We will then venture into the world of unit testing, showing you first how to write simple tests, and then how to group those tests together into test suites. Next, we define a class ...
Get PHP 7: Real World Application Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.