https://github.com/alexmanno/doctrine-auto-fixtures
Automatic fixtures
https://github.com/alexmanno/doctrine-auto-fixtures
Last synced: 2 months ago
JSON representation
Automatic fixtures
- Host: GitHub
- URL: https://github.com/alexmanno/doctrine-auto-fixtures
- Owner: alexmanno
- License: mit
- Created: 2018-05-02T11:09:28.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-02T17:58:46.000Z (about 7 years ago)
- Last Synced: 2025-02-10T02:41:43.719Z (4 months ago)
- Language: PHP
- Size: 21.5 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# doctrine-auto-fixtures
Automatic fixture for doctrine entities[](https://travis-ci.org/alexmanno/doctrine-auto-fixtures)
## Installation
```bash
composer require alexmanno/doctrine-auto-fixtures
```## Usage
In your entity:
##### Fixed value on field
```php
class Entity {
/**
* @Fixture(value="Fixed value")
*/
private $entityField;
}
```##### Factory on field
```php
class Entity {
/**
* @Fixture(factory="Acme\FactoryClass:factoryMethod")
*/
private $entityField;
}
```##### Faker on field
```php
class Entity {
/**
* @Fixture(faker="address")
*/
private $entityField;
}
```##### Link another entity on field
```php
class Entity {
/**
* @Fixture(class="Acme\AnotherEntity")
*/
private $entityField;
}
```Than in your tests:
```php
// ----
$engine = new AlexManno\Engine\FixtureEngine();
$fixture = $engine->get(Acme\Entity::class); // <- this will return your fixture
// ----
```