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:
Centum\Codeception\Actions\AccessActions
Centum\Codeception\Actions\AjaxActions
Centum\Codeception\Actions\ConsoleActions
Centum\Codeception\Actions\ContainerActions
Centum\Codeception\Actions\CookieActions
Centum\Codeception\Actions\CsrfActions
Centum\Codeception\Actions\FilterActions
Centum\Codeception\Actions\HeaderActions
Centum\Codeception\Actions\HtmlActions
Centum\Codeception\Actions\HttpFormActions
Centum\Codeception\Actions\JsonActions
Centum\Codeception\Actions\QueueActions
Centum\Codeception\Actions\RouterActions
Centum\Codeception\Actions\RouterReplacementActions
Centum\Codeception\Actions\SessionActions
Centum\Codeception\Actions\UnitTestActions
Centum\Codeception\Actions\ValidatorActions
These traits can be used at will in your Tester classes (tests/Support/UnitTester.php
, for example).