PHP Classes

File: system/Helpers/test_helper.php

Recommend this page to a friend!
  Classes of Faris AL-Otabi   PHP GuestBook with Database   system/Helpers/test_helper.php   Download  
File: system/Helpers/test_helper.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP GuestBook with Database
GuestBook application using MySQL to store posts
Author: By
Last change:
Date: 6 months ago
Size: 972 bytes
 

Contents

Class file image Download
<?php

/**
 * This file is part of the CodeIgniter 4 framework.
 *
 * (c) CodeIgniter Foundation <admin@codeigniter.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

use CodeIgniter\Test\Fabricator;

/**
 * CodeIgniter Test Helpers
 */
//--------------------------------------------------------------------

if (! function_exists('fake'))
{
   
/**
     * Creates a single item using Fabricator.
     *
     * @param Model|object|string $model Instance or name of the model
     * @param array|null $overrides Overriding data to pass to Fabricator::setOverrides()
     *
     * @return object|array
     */
   
function fake($model, array $overrides = null)
    {
       
// Get a model-appropriate Fabricator instance
       
$fabricator = new Fabricator($model);

       
// Set overriding data, if necessary
       
if ($overrides)
        {
           
$fabricator->setOverrides($overrides);
        }

        return
$fabricator->create();
    }
}