PHPackages                             tecnocen/yii2-arfixture - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. tecnocen/yii2-arfixture

ActiveYii2-extension[Testing &amp; Quality](/categories/testing)

tecnocen/yii2-arfixture
=======================

Yii2 library to run fixtures the ActiveRecord Dao

0.1(9y ago)39.8k[5 issues](https://github.com/tecnocen-com/arfixture/issues)BSD-3-ClausePHP

Since Jun 10Pushed 9y ago2 watchersCompare

[ Source](https://github.com/tecnocen-com/arfixture)[ Packagist](https://packagist.org/packages/tecnocen/yii2-arfixture)[ Docs](https://github.com/tecnocen-com/yii2-arfixture)[ RSS](/packages/tecnocen-yii2-arfixture/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Tecnocen.com Yii2 Active Record Fixture
=======================================

[](#tecnocencom-yii2-active-record-fixture)

[![Latest Stable Version](https://camo.githubusercontent.com/39cc5fdc032d0419f7b111aa9853e5931999e6178c5f11731ddcaec4a8fb9b5a/68747470733a2f2f706f7365722e707567782e6f72672f7465636e6f63656e2f796969322d6172666978747572652f762f737461626c65)](https://packagist.org/packages/tecnocen/yii2-arfixture) [![Total Downloads](https://camo.githubusercontent.com/8c8271363a002eb15665c96e20f25eadb8592dda7b76eddd9b7ea9bc8a6f7d08/68747470733a2f2f706f7365722e707567782e6f72672f7465636e6f63656e2f796969322d6172666978747572652f646f776e6c6f616473)](https://packagist.org/packages/tecnocen/yii2-arfixture) [![Latest Unstable Version](https://camo.githubusercontent.com/6b3b4ebce4f65ba1f94a6ee0adbe98868ea162ccf0be2d115de20212b7ff8389/68747470733a2f2f706f7365722e707567782e6f72672f7465636e6f63656e2f796969322d6172666978747572652f762f756e737461626c65)](https://packagist.org/packages/tecnocen/yii2-arfixture) [![License](https://camo.githubusercontent.com/653e5b3bed6c488b68e819e0abd36b2ad07cba839b46cedcc270d5d7ad8acd51/68747470733a2f2f706f7365722e707567782e6f72672f7465636e6f63656e2f796969322d6172666978747572652f6c6963656e7365)](https://packagist.org/packages/tecnocen/yii2-arfixture)

Library to load data fixutres using using the methods defined by `yii\db\ActiveRecord` and show progress log.

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
composer require --prefer-dist "tecnocen/yii2-arfixture:*"
```

or add

```
"tecnocen/yii2-arfixture": "*"

```

to the `require` section of your `composer.json` file.

Differences
-----------

[](#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.

\\ARFixtureActiveFixture &amp; FixtureHow is the data saved?`ActiveRecord::save()``Schema::insert()`Works will all the db'sWithout modificationHave to change classesSupport to change scenario👍👎Support ActiveRecord events👍👎Support Behaviors👍👎Shows details on each row👍👎Check validated attributes👍👎Shows how many tests passed👍👎Shows how many tests failed👍👎Support silent mode👍👎Exception handling👍👎Usage
-----

[](#usage)

### ARFixture

[](#arfixture)

```
class UserFixture extends ARFixture
{
    public $modelClass = 'common\models\User';
}
```

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

```
return [
    // record with no explicit alias, will only show the key number on the log.
    [
        'username' => 'faryshta',
        'name' => 'Angel',
        'lastname' => 'Guevara',
        'email' => 'angeldelcaos@gmail.com',
    ],

    // record with explicit alias, will be shown on the log
    'duplicated' => [
        'username' => 'faryshta',
        'name' => 'Angel',
        'lastname' => 'Guevara',
        'email' => 'angeldelcaos@gmail.com',

        // optional, will apply the scenario before loading the models.
        'scenario' => 'api-save',

        // optional, will check the validation errors.
        'attributeErrors' => [
            // will check that username has this exact validation error.
            'username' => 'Username already in use',
            // will check that email has any validation error
            'email',
            // the other attributes are not expected to have a validation error.
        ],
    ]
];
```

Each row can contain the following special options:

- attributeErrors: array list of expected validation errors in the format

    ```
    'attributeErrors' => [
        'attribute1', // will check that it contains any error.
        'attribute2' => 'Error Message' // This has to be the error found.
    ]
    ```

    > 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()` and `Model::validate()`, if not defined the `$scenarioDefault` will be used

Documentation
-------------

[](#documentation)

TODO

License
-------

[](#license)

The BSD License (BSD). Please see [License File](LICENSE.md) for more information.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3624d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2341d88f3cdea0c2474cfbf59e5cf6dab5dd6a026d7846fabf219f2a93be1641?d=identicon)[neverabe](/maintainers/neverabe)

---

Top Contributors

[![neverabe](https://avatars.githubusercontent.com/u/1173807?v=4)](https://github.com/neverabe "neverabe (7 commits)")[![Faryshta](https://avatars.githubusercontent.com/u/2029247?v=4)](https://github.com/Faryshta "Faryshta (2 commits)")

---

Tags

testingFixturetestsyii2yiiactiverecorddaoar

### Embed Badge

![Health badge](/badges/tecnocen-yii2-arfixture/health.svg)

```
[![Health](https://phpackages.com/badges/tecnocen-yii2-arfixture/health.svg)](https://phpackages.com/packages/tecnocen-yii2-arfixture)
```

###  Alternatives

[phpspec/phpspec

Specification-oriented BDD framework for PHP 7.1+

1.9k36.7M3.1k](/packages/phpspec-phpspec)[typo3/testing-framework

The TYPO3 testing framework provides base classes for unit, functional and acceptance testing.

675.0M775](/packages/typo3-testing-framework)[janmarek/mockista

Mockista is library for mocking, which I've written, because I find mocking in PHPUnit awful.

29221.0k28](/packages/janmarek-mockista)[code-distortion/adapt

A Laravel package that builds databases for your tests, improving their speed.

2835.5k](/packages/code-distortion-adapt)[lastzero/test-tools

Increases testing productivity by adding a service container and self-initializing fakes to PHPUnit

2244.3k13](/packages/lastzero-test-tools)[magetest/manager

Magento fixture manager

1744.1k](/packages/magetest-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
