JWT-OSS/sfJwtPhpUnitPlugin — Issue #35: Create phpunit:generate-fixture task.
Author: todofixthis
Created: 2011-12-20 16:02:59+00:00
State: open
Labels: enhancement

Create a task that can be used to generate fixtures from existing database records.

Usage would look something like this:

symfony phpunit:generate-fixture filename dql1 ... dqlN [--env=...] [--format=...] [--plugin=...]

Example usage:

symfony phpunit:generate-fixture Product/phone 'select * from product where id="15"' --env=prod --format=php --plugin=myCommercePlugin

The resulting fixture file would look something like this:

# sf_plugins_dir/myCommercePlugin/test/fixtures/Product/phone.php

PhoneProductCategory = new ProductCategory();
$this->PhoneProductCategory->setName('phone');
...
$this->PhoneProductCategory->save();

$this->IphoneProduct = new Product();
$this->IphoneProduct->setName('iPhone');
$this->IphoneProduct->setCategory($this->PhoneProductCategory);
...
$this->IphoneProduct->save();

Notes:

- For PHP fixtures, the name of each fixture object is determined by inflecting the record's `__toString()` value and appending the model name.
- If any matched records have relations, those relations are also included in the fixture.
- Only `SELECT` queries should be executed.