O'Reilly logo

Mastering PHP 7 by Branko Ajzele

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

Setting up a sample application

Before we start writing some PHPUnit test scripts, let's go ahead and create a very simple application consisting of merely a few files. This will allow us to focus on the essence of writing a test later on.

Test driven development (TDD), such as the one done with PHPUnit, encourages writing tests before the implementations. This way, the tests set the expectations for the functionality and not the other way around. This approach requires a certain level of experience and discipline, which might not sit well with newcomers to PHPUnit.

Let's assume that we are making a part of the web shopping functionality, thus dealing with product and category entities for a start. The first class we address is the Product ...

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