Unit testing with Atoum

Besides PHPUnit and Codeception, Atoum is a simple unit testing framework. You can use this framework for testing your extensions or for testing a code of your application.

Getting ready

Create an empty directory for the new project.

How to do it…

In this recipe, we will create a demonstration shopping cart extension with Atoum tests.

Preparing the extension structure

  1. First, create the directory structure for your extension:
    book
    └── cart
        ├── src
        └── tests
  2. For working with the extension as a composer package, prepare the book/cart/composer.json file as follows:
    { "name": "book/cart", "type": "yii2-extension", "require": { "yiisoft/yii2": "~2.0" }, "require-dev": { "atoum/atoum": "^2.7" }, "autoload": { "psr-4": { "book\\cart\\": ...

Get Yii2 Application Development Cookbook - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.