Testing

Centum\Codeception\Module

Centum uses Codeception for most of its testing and utilises its own module (Centum\Codeception\Module) to enable tests to use a centralised Container object.

This module is already enabled in SidRoberts/centum-project. You can also enable it in your own projects:

modules:
  enabled:
    - Centum\Codeception\Module:
        container: config/container.php

Currently, the only config setting is container which should link to a file that returns a Centum\Interfaces\Container\ContainerInterface object. If this isn’t specified, it will default to config/container.php.

This module is kept as simple as possible so that it can work with all kinds of tests. These methods are available in your Tester classes (tests/Support/UnitTester.php, for example):

  • makeNewContainer(): void
  • grabContainer(): Centum\Interfaces\Container\ContainerInterface
  • mock(class-string $class, callable $callable = null): Mockery\MockInterface

Traits

To futher enhance testing, these traits are available:

These traits can be used at will in your Tester classes (tests/Support/UnitTester.php, for example).


Table of contents