Skip to content

aircargobook/cakephp-fixture-importer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

cakephp-fixture-importer

CakePHP Plugin that extends the capability of a Fixture to load not only structure but already.

installation

composer require aircargobook/cakephp-fixture-importer

usage

Load the Trait into your existing fixture.

<?php
namespace App\Test\Fixture;

use Aircargobook\CakephpFixtureImporter\Traits\FixtureImportTrait;
use Cake\TestSuite\Fixture\TestFixture;

class ExampleFixture extends TestFixture
{
    /** @var array Set this property to load fixtures to a different test datasource */
    public $import = ['table' => 'example', 'connection' => 'test_fixtures'];

    /**
    * @return void
    */
    public function init()
    {
        parent::init();
        $this->insertDataFromSourceTable();
    }
}

It will now load the table structure from the test_fixture connection and insert data from the test_fixture connection into the connection test.