Download the PHP package tecnocen/yii2-arfixture without Composer
On this page you can find all versions of the php package tecnocen/yii2-arfixture. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tecnocen/yii2-arfixture
More information about tecnocen/yii2-arfixture
Files in tecnocen/yii2-arfixture
Package yii2-arfixture
Short Description Yii2 library to run fixtures the ActiveRecord Dao
License BSD-3-Clause
Homepage https://github.com/tecnocen-com/yii2-arfixture
Informations about the package yii2-arfixture
Tecnocen.com Yii2 Active Record Fixture
Library to load data fixutres using using the methods defined by yii\db\ActiveRecord
and show progress log.
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require
section of your composer.json
file.
Differences
yii\test\Fixture
and yii\test\ActiveFixture
load data to the tables using
the name of the table and the yii\db\Schema::insert()
method which means all
the methods defined in the model such as validations, events, behaviors and even
table prefix are ignored.
tecnocen\arfixutre\ARFixture
loads fixtures by creating a model using the
$modelClass
property and then passes by all the workflow of saving the data
using ActiveRecord
considering scenarios, exceptions, events, safe attributes,
validation errors and showing detailed information to the user of the procedure.
\ | ARFixture | ActiveFixture & Fixture |
---|---|---|
How is the data saved? | ActiveRecord::save() |
Schema::insert() |
Works will all the db's | Without modification | Have to change classes |
Support to change scenario | :+1: | :-1: |
Support ActiveRecord events | :+1: | :-1: |
Support Behaviors | :+1: | :-1: |
Shows details on each row | :+1: | :-1: |
Check validated attributes | :+1: | :-1: |
Shows how many tests passed | :+1: | :-1: |
Shows how many tests failed | :+1: | :-1: |
Support silent mode | :+1: | :-1: |
Exception handling | :+1: | :-1: |
Usage
ARFixture
If [[$dataFile]] is not defined then it will seek on the data/
subfolder the
file with the same name as this class except for the Fixture
keyword at the
end. Example: UserFixture
will return the file data/User.php
or an empty
array when the file can not found.
The data must follow this structure
Each row can contain the following special options:
-
attributeErrors: array list of expected validation errors in the format
Warning: If this option is defined the record won't be saved even if it passes all the validations.
- scenario: string to be used as scenario for the model to handle
the methods
Model::load()
andModel::validate()
, if not defined the$scenarioDefault
will be used
Documentation
TODO
License
The BSD License (BSD). Please see License File for more information.