Test Helper

The Test Helper file contains functions that assist in testing your project.

Loading this Helper

This helper is loaded using the following code:



Available Functions

The following functions are available:

fake($model, array $overrides = null)
  • $model (Model|object|string) – Instance or name of the model to use with Fabricator

  • $overrides (array|null) – Overriding data to pass to Fabricator::setOverrides()


A random fake item created and added to the database by Fabricator

Return type:


Uses CodeIgniter\Test\Fabricator to create a random item and add it to the database.

Usage example:


use CodeIgniter\Test\CIUnitTestCase;

final class MyTestClass extends CIUnitTestCase
    public function testUserAccess()
        $user = fake('App\Models\UserModel');