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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.