PHPackages                             roaresearch/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. roaresearch/yii2-arfixture

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

roaresearch/yii2-arfixture
==========================

Yii2 library to run fixtures the ActiveRecord Dao

0.1(9y ago)013[5 issues](https://github.com/ROAResearch/yii2-arfixture/issues)BSD-3-ClausePHPCI failing

Since Jun 10Pushed 3y ago2 watchersCompare

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

READMEChangelogDependencies (1)Versions (3)Used By (0)

Yii2 Active Record Fixture
==========================

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

[![Latest Stable Version](https://camo.githubusercontent.com/673071d0d828c1c0ef9ed7e5e71146830d9066cf736662856125890ec38de851/68747470733a2f2f706f7365722e707567782e6f72672f2f796969322d6172666978747572652f762f737461626c65)](https://packagist.org/packages/roaresearch/yii2-arfixture) [![Total Downloads](https://camo.githubusercontent.com/d442a8253a10c8c486619d06d9514dc37d8bab6fc6c9d9d3b9c0083f3bcc3833/68747470733a2f2f706f7365722e707567782e6f72672f726f6172657365617263682f796969322d6172666978747572652f646f776e6c6f616473)](https://packagist.org/packages/roaresearch/yii2-arfixture) [![Latest Unstable Version](https://camo.githubusercontent.com/5c63fc7080398534e7d41afdf4edc44e19286bf98c880b82f1e701dc7a40e7cb/68747470733a2f2f706f7365722e707567782e6f72672f726f6172657365617263682f796969322d6172666978747572652f762f756e737461626c65)](https://packagist.org/packages/roaresearch/yii2-arfixture) [![License](https://camo.githubusercontent.com/231d82308b7e85c8bdad6c25a587de17def348d26a95a306a428d0a443b65f5a/68747470733a2f2f706f7365722e707567782e6f72672f726f6172657365617263682f796969322d6172666978747572652f6c6963656e7365)](https://packagist.org/packages/roaresearch/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 "roaresearch/yii2-arfixture:*"
```

or add

```
"roaresearch/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.

`roaresearch\yii2\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 = User::class;
}
```

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

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% 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/3d5f64412ef020f8c137ff5c7f5e4a0866271f2f9ba9584e5a24aa48467f958d?d=identicon)[Faryshta](/maintainers/Faryshta)

![](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 (8 commits)")[![Faryshta](https://avatars.githubusercontent.com/u/2029247?v=4)](https://github.com/Faryshta "Faryshta (4 commits)")

---

Tags

testingFixturetestsyii2yiiactiverecorddaoar

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/roaresearch-yii2-arfixture/health.svg)](https://phpackages.com/packages/roaresearch-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)
