aircargobook/cakephp-fixture-importer

CakePHP3 FixtureImporter plugin

1.0.3 2020-08-06 17:37 UTC

This package is auto-updated.

Last update: 2024-04-07 04:56:17 UTC


README

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.