PHPackages                             englishdom/unitarum - 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. [Database &amp; ORM](/categories/database)
4. /
5. englishdom/unitarum

ActiveLibrary[Database &amp; ORM](/categories/database)

englishdom/unitarum
===================

The PHPUnit library is providing and flexible changing fixtures to database

1.0.5(2y ago)08.1k3[3 issues](https://github.com/englishdom/unitarum/issues)Apache-2.0PHPPHP ^7.3|^8.0CI failing

Since Jan 18Pushed 2y ago2 watchersCompare

[ Source](https://github.com/englishdom/unitarum)[ Packagist](https://packagist.org/packages/englishdom/unitarum)[ Docs](https://github.com/englishdom/unitarum)[ RSS](/packages/englishdom-unitarum/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (2)Versions (18)Used By (0)

Unitarum
========

[](#unitarum)

The library for providing and flexible changing fixtures for PHPUnit

Default fixtures
----------------

[](#default-fixtures)

Fixtures use entities. Entities must provide methods `getId` and `setId`. The library propose interface `EntityIdentifierInterface` with this two methods if it need.

#### An entity's example

[](#an-entitys-example)

```
class User
{
    protected $id;
    protected $name;
    protected $email;

    public function getId()
    {
        return $this->id;
    }

    public function setId($id)
    {
        $this->id = $id;
    }

    public function getName()
    {
        return $this->name;
    }

    public function setName($name)
    {
        $this->name = $name;
    }

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}
```

#### A fixture's example:

[](#a-fixtures-example)

```
$entity = new Entity\User();
$entity->setId(1);
$entity->setName('Test');
$entity->setEmail('test@test.no');

return ['table_name' => $entity];
```

PhpUnit test
------------

[](#phpunit-test)

In the test's start need initialize the `Unitarum` object with two parameters. The first parameter is path to folder with fixtures. The second parameter is `dsn` connection string to `sqlite`.

#### Test example

[](#test-example)

```
use PHPUnit\Framework\TestCase;

class DatabaseTest extends TestCase
{
    protected static $unitarum;

    public static function setUpBeforeClass()
    {
        self::$unitarum = new Unitarum([
            OptionsInterface::FIXTURE_FOLDER_OPTION => '../data',
            OptionsInterface::DSN_OPTION => 'sqlite:data/sqlite.db',
        ]);
    }
}
```

In the every test's cases need to start and rollback a transaction.

#### Test example

[](#test-example-1)

```
class DatabaseTest extends TestCase
{
    protected static $unitarum;

    public static function setUpBeforeClass()
    {
        ...
    }

    public function setUp()
    {
        self::$unitarum->getDataBase()->startTransaction();
        // or notning
    }

    public function tearDown()
    {
        self::$unitarum->getDataBase()->rollbackTransaction();
        //or
        self::$unitarun->truncate();
    }
}
```

If you don't want to use transaction, you can use TRUNCATE data.

### Setup fixtures

[](#setup-fixtures)

In the test you can apply fixtures and change any data from it. You can call methods from the initialized `unitarum` object. Called method name must be equals name of fixture file. A method can get one parameter, is it `Entity`. An entity can rewrite default data from fixture.

#### Test example

[](#test-example-2)

```
class DatabaseTest extends TestCase
{
    ...

    public function testApplication()
    {
        $user = new Entity\User();
        $user->setEmail('newemail@email.no');

        $role = new Entity\Role();
        $role->setRole('viewer');
        $role->setUserId($user->getId());

        self::$unitarum->user($user)->role($role);

        // test
        ...
    }
}
```

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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

Every ~139 days

Recently: every ~363 days

Total

17

Last Release

854d ago

Major Versions

0.3.6 → 1.0.02020-03-02

PHP version history (3 changes)0.1PHP ^7.1

1.0.3PHP ^7.3

1.0.4PHP ^7.3|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/a23a77acfb47f8b6c8f52a757a5a74d14e6c2ed428340235339c714132ded654?d=identicon)[EnglishDom](/maintainers/EnglishDom)

![](https://www.gravatar.com/avatar/3cdb20f2b32d73e11bc1d18ea00cedf6007b9d731e7f6547735bcde03718fa48?d=identicon)[newage](/maintainers/newage)

---

Top Contributors

[![newage](https://avatars.githubusercontent.com/u/426997?v=4)](https://github.com/newage "newage (52 commits)")

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/englishdom-unitarum/health.svg)

```
[![Health](https://phpackages.com/badges/englishdom-unitarum/health.svg)](https://phpackages.com/packages/englishdom-unitarum)
```

PHPackages © 2026

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