Allows the generation of SilverStripe unit test fixtures from existing DataObjects either programatically created or from the database.
Creating fixtures files for unit tests is tedious at best, and this library's goal is to alleviate some of the pain.
$ composer require camspiers/silverstripe-fixturegenerator:~0.1
use Camspiers\SilverStripe\FixtureGenerator;
$records = //some DataObjectSet
(new FixtureGenerator\Generator(
new FixtureGenerator\Dumpers\Yaml(
__DIR__ . '/tests/MyFixture.yml'
)
))->process($records);
use Camspiers\SilverStripe\FixtureGenerator;
$records = //some DataObjectSet
(new FixtureGenerator\Generator(
new FixtureGenerator\Dumpers\Yaml(
__DIR__ . '/tests/MyFixture.yml'
),
array(
'MyDataObject.SomeHasOneRelation',
'MyDataObject.SomeHasManyRelation'
)
))->process($records);
use Camspiers\SilverStripe\FixtureGenerator;
$records = //some DataObjectSet
(new FixtureGenerator\Generator(
new FixtureGenerator\Dumpers\Yaml(
__DIR__ . '/tests/MyFixture.yml'
),
array(
'MyDataObject.SomeHasOneRelation',
'MyDataObject.SomeHasManyRelation'
),
FixtureGenerator\Generator::RELATION_MODE_EXCLUDE
))->process($records);
$ composer install --dev
$ phpunit