O'Reilly logo

PHPUnit Essentials by Zdenek Machek

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Testing Dependencies and Exceptions

In this chapter, you will see that one of the biggest problems faced when writing PHPUnit tests is dependencies. You might be wondering what we mean by dependencies. Obviously, code needs to interact with other code, and you need to know it works. Yes, this is true, but with unit testing, you are trying to verify that the smallest possible piece of code works as expected, and to be sure that nothing else is breaking the tested code, you need to isolate the code. Code isolation is one way to do it, and you should start with this.

But what really are dependencies? The following are the parts of the application and code that might be causing problems:

  • Global variables: For example, you create a $config ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required