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

Setting up and using unit testing

To start using Unit testing in Zend Framework 2 can be a bit of a hassle. But don't worry; help is coming as we fly you through a proper set up of Zend Framework 2 unit testing.

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 on a couple of different ways but the easiest and 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.*"
  }
}

After saving the composer.json file, run Composer to update the new requirements.

$ php composer.phar ...

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