1. Go to this page and download the library: Download paul/alice-fixtures-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
paul / alice-fixtures-bundle example snippets
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
// ...
$bundles[] = new h4cc\AliceFixturesBundle\h4ccAliceFixturesBundle();
}
}
$files = array(__DIR__.'/fixtures/Users.yml', __DIR__.'/fixtures/Articles.yml');
// Or use $manager = $this->get('h4cc_alice_fixtures.[my_manager_name]_manager'); to use an other manager.
$manager = $this->get('h4cc_alice_fixtures.manager');
// Step 1, load entities.
$objects = $manager->loadFiles($files, 'yaml');
// Manipulate or add own objects here ...
// Step 2, persist them.
$manager->persist($objects, true);
$manager = $this->getContainer()->get('h4cc_alice_fixtures.manager');
// Get a FixtureSet with __default__ options.
$set = $manager->createFixtureSet();
$set->addFile(__DIR__.'/fixtures/Users.yml', 'yaml');
$set->addFile(__DIR__.'/fixtures/Articles.yml', 'yaml');
// Change locale for this set only.
$set->setLocale('de_DE');
// Define a custom random seed for "predictable randomness".
$set->setSeed(42);
// Enable persisting of objects
$set->setDoPersist(true);
// Enable dropping and recreating current ORM schema.
$set->setDoDrop(true);
return $set;
// Creating a fixture set with own configuration,
$set = new h4cc\AliceFixturesBundle\Fixtures\FixtureSet(array(
'locale' => 'de_DE',
'seed' => 42,
'do_drop' => true,
'do_persist' => true,
'order' => 5
));
$set->addFile(__DIR__.'/Users.yml', 'yaml');
$set->addFile(__DIR__.'/Articles.yml', 'yaml');
return $set;
// Ensuring the same fixtures for each testcase.
public function setUp()
{
// This may be slow ... have an eye on that.
$client = static::createClient();
$manager = $client->getContainer()->get('h4cc_alice_fixtures.manager');
$manager->load(