alexmanno / doctrine-auto-fixtures

Automatic fixtures

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

doctrine-auto-fixtures

Automatic fixture for doctrine entities

Build Status Scrutinizer Coverage

Installation

composer require alexmanno/doctrine-auto-fixtures

Usage

In your entity:

Fixed value on field
class Entity {
    /**
     * @Fixture(value="Fixed value")
     */
    private $entityField;
}
Factory on field
class Entity {
    /**
     * @Fixture(factory="Acme\FactoryClass:factoryMethod")
     */
    private $entityField;
}
Faker on field
class Entity {
    /**
     * @Fixture(faker="address")
     */
    private $entityField;
}
Link another entity on field
class Entity {
    /**
     * @Fixture(class="Acme\AnotherEntity")
     */
    private $entityField;
}

Than in your tests:

    // ----
    $engine = new AlexManno\Engine\FixtureEngine();
    $fixture = $engine->get(Acme\Entity::class); // <- this will return your fixture
    // ----

About

Automatic fixtures

License:MIT License


Languages

Language:PHP 100.0%