alexmanno/doctrine-auto-fixtures

Doctrine 实体自动 fixture

1.0.2 2018-05-02 17:58 UTC

This package is auto-updated.

Last update: 2024-09-22 21:08:35 UTC


README

Doctrine 实体自动 fixture

Build Status Scrutinizer Coverage

安装

composer require alexmanno/doctrine-auto-fixtures

用法

在您的实体中

字段上的固定值
class Entity {
    /**
     * @Fixture(value="Fixed value")
     */
    private $entityField;
}
字段上的工厂
class Entity {
    /**
     * @Fixture(factory="Acme\FactoryClass:factoryMethod")
     */
    private $entityField;
}
字段上的 Faker
class Entity {
    /**
     * @Fixture(faker="address")
     */
    private $entityField;
}
在字段上链接另一个实体
class Entity {
    /**
     * @Fixture(class="Acme\AnotherEntity")
     */
    private $entityField;
}

在您的测试中

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