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:

helper('test');

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

傳回型態:

object|array

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

Usage example:

public function testUserAccess()
{
    $user = fake('App\Models\UserModel');

    $this->assertTrue($this->userHasAccess($user));
}