Automatic fixture for doctrine entities
composer require alexmanno/doctrine-auto-fixtures
In your entity:
class Entity {
/**
* @Fixture(value="Fixed value")
*/
private $entityField;
}
class Entity {
/**
* @Fixture(factory="Acme\FactoryClass:factoryMethod")
*/
private $entityField;
}
class Entity {
/**
* @Fixture(faker="address")
*/
private $entityField;
}
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
// ----