O'Reilly logo

Zend Framework 2 Cookbook by Josephus Callaars

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

Unit testing – why would you do it

Unit testing is a form of testing that has been widely accepted in the programming world. Unfortunately a lot of PHP developers still lack the knowledge on how to utilize it to their benefit, or they just don't know how to get started. This recipe will try to change that.

Getting ready

To get started with Unit testing a Zend Framework 2 application, it is required that we have PHPUnit 3.7.x installed. We can do this in a couple of different ways, but the easiest and most recommended way is by installing it through Composer, which comes with the Zend Framework 2 application.

To install PHPUnit through Composer we just need to add the following lines to composer.json:

{ "require-dev": { "phpunit/phpunit": "3.7.*" } ...

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