h4cc / alicefixturesbundle Goto Github PK
View Code? Open in Web Editor NEWA Symfony2 bundle for using Alice and Faker with data fixtures. Abled to use Doctrine ORM as well as Doctrine MongoDB ODM.
License: MIT License
A Symfony2 bundle for using Alice and Faker with data fixtures. Abled to use Doctrine ORM as well as Doctrine MongoDB ODM.
License: MIT License
I have always been using this bundle as a dev dependency with no issues but now I am in the need of using it as prod dependency for some dummy generated content and I am having this issue:
[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
The service "h4cc_alice_fixtures.orm.schema_tool.doctrine" has a dependency on a non-existent service "doctrine".
My composer dependencies are:
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.6.*",
"doctrine/mongodb-odm": "1.0.*@dev",
"doctrine/mongodb-odm-bundle": "3.0.*@dev",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~3.0.12",
"sensio/framework-extra-bundle": "~3.0",
"incenteev/composer-parameter-handler": "~2.0",
"nelmio/api-doc-bundle": "~2.7",
"friendsofsymfony/rest-bundle": "1.5.3",
"jms/serializer-bundle": "0.13.*",
"stof/doctrine-extensions-bundle": "~1.1@dev",
"friendsofsymfony/user-bundle": "~2.0@dev",
"nelmio/cors-bundle": "~1.4",
"friendsofsymfony/oauth-server-bundle": "dev-master",
"white-october/pagerfanta-bundle": "~1.0",
"willdurand/hateoas-bundle": "0.4.*",
"aws/aws-sdk-php": "~2.7",
"liip/imagine-bundle": "~1.2",
"antimattr/mongodb-migrations": "~1.0@stable",
"antimattr/mongodb-migrations-bundle": "~1.0@stable",
"nesbot/carbon": "~1.18",
"jms/security-extra-bundle": "1.5.*@dev",
"h4cc/alice-fixtures-bundle": "0.5.1"
},
"require-dev": {
"sensio/generator-bundle": "~2.3",
"raulfraile/ladybug-bundle": "~1.0",
"behat/behat": "~3.0",
"behat/symfony2-extension": "~2.0",
"behat/mink": "~1.5",
"behat/mink-extension": "~2.0",
"behat/mink-browserkit-driver": "~1.1",
"behatch/contexts": "*",
"coduo/php-matcher": "~1.1",
"fzaninotto/faker": "dev-master",
"emuse/behat-html-formatter": "dev-master",
"pdepend/pdepend": "~2.0",
"phpmd/phpmd": "~2.2",
"sebastian/phpcpd": "~2.0",
"phploc/phploc": "~2.0",
"phpdocumentor/phpdocumentor": "~2.8",
"covex-nn/phpcb": "1.0.4.1",
"phing/phing": "~2.9",
"m6web/symfony2-coding-standard": "~2.0",
"m6web/coke": "~1.2"
}
May I missing something?
Thank you
Hello,
I am trying to load and remove some dataFixtures ...
The fixtures are correctly loaded but are never removed (remove function called in tearDown or tearDownAfterClass function does not seem to work well).
the remove is OK at the end of the last test, but KO after the first one.
I made a little example as you can see the issue by yourself:
The result:
$ phpunit -c app/
PHPUnit 4.8.16 by Sebastian Bergmann and contributors.
Eadd new entries
string(25) "SET_UP : nb_chronos = 2
"
string(39) "TEST_1 : nb_chronos before delete = 2
"
string(38) "TEST_1 : nb_chronos after delete = 1
"
string(22) "====================
"
delete entries
.add new entries
string(25) "SET_UP : nb_chronos = 3
"
string(25) "TEST_2 : nb_chronos = 3
"
delete entries
string(28) "TEAR_DOWN : nb_chronos = 1
"
Time: 1.16 seconds, Memory: 14.00Mb
The config_test.yml:
imports:
- { resource: config_dev.yml }
framework:
test: ~
session:
storage_id: session.storage.mock_file
profiler:
collect: false
web_profiler:
toolbar: false
intercept_redirects: false
swiftmailer:
disable_delivery: true
doctrine:
dbal:
driver: pdo_sqlite
user: test
path: %kernel.cache_dir%/sqlite.db
#memory: true
charset: utf8
h4cc_alice_fixtures:
locale: fr_FR #usefull to generate french fixtures like a french phoneNumber
The Test class:
<?php
namespace Chronos\RestBundle\Tests\Controller;
use h4cc\AliceFixturesBundle\Fixtures\FixtureManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
* Class ChronosControllerTest
* @package Chronos\RestBundle\Tests\Controller
*/
class ChronosControllerTest extends WebTestCase
{
/**
* @var array
*/
private static $fixtures;
/**
* @var FixtureManagerInterface
*/
private static $fixturesManager;
/**
* Loadin�g the fixtures at every Tests
*/
public function setUp()
{
echo "add new entries".PHP_EOL;
$client = static::createClient();
static::$fixturesManager = $client->getContainer()->get('h4cc_alice_fixtures.manager');
static::$fixtures = static::$fixturesManager->loadFiles(
array(__DIR__ . '/../DataFixtures/chronos.yml')
);
static::$fixturesManager->persist(static::$fixtures);
$repo = $client
->getContainer()
->get('doctrine')
->getRepository('ChronosRestBundle:Chronos');
$chronos = $repo->findAll();
var_dump("SET_UP : nb_chronos = ".count($chronos).PHP_EOL);
}
/**
* Remove fixtures after every single test.
*/
public function tearDown()
{
echo "delete entries".PHP_EOL;
$client = static::createClient();
static::$fixturesManager = $client->getContainer()->get('h4cc_alice_fixtures.manager');
static::$fixturesManager->remove(static::$fixtures);
$repo = $client
->getContainer()
->get('doctrine')
->getRepository('ChronosRestBundle:Chronos');
$chronos = $repo->findAll();
var_dump("TEAR_DOWN : nb_chronos = ".count($chronos).PHP_EOL);
}
public function testAddAction()
{
$client = static::createClient();
//get a chronosController
$chronosController = $client->getContainer()->get('chronos.chronos_controller');
// $chronosController->addAction();
$repo = $client
->getContainer()
->get('doctrine')
->getRepository('ChronosRestBundle:Chronos');
$chronos = $repo->findAll();
var_dump("TEST_1 : nb_chronos before delete = ".count($chronos).PHP_EOL);
$em = $client
->getContainer()
->get('doctrine.orm.entity_manager');
$em->remove($chronos[0]);
$em->flush();
$chronos = $repo->findAll();
var_dump("TEST_1 : nb_chronos after delete = ".count($chronos).PHP_EOL);
var_dump("====================".PHP_EOL);
}
public function testEditAction() {
$client = static::createClient();
//get a chronosController
$chronosController = $client->getContainer()->get('chronos.chronos_controller');
// $chronosController->addAction();
$repo = $client
->getContainer()
->get('doctrine')
->getRepository('ChronosRestBundle:Chronos');
$chronos = $repo->findAll();
var_dump("TEST_2 : nb_chronos = ".count($chronos).PHP_EOL);
}
}
The fixtures:
Chronos\RestBundle\Entity\Chronos:
chronos_1:
id: 1
priority: 1
callDestination: 12548
channel: "welcome"
clientPhoneNumber: 0612348598
active: 1
inactiveCause: ""
additionalInformations: ""
recallDate: <dateTimeBetween('now', '+5 days')>
createdAt: <dateTimeBetween('-1 days', 'now')>
updatedAt: <dateTimeBetween($createdAt, 'now')>
preTreatmentSmsDate: null
postTreatmentSmsDate: null
callDestinationType: "agent"
chronos_inactive:
id: 2
priority: 3
callDestination: 12549
channel: "nordnet.fr"
clientPhoneNumber: 0682348654
active: 0
inactiveCause: "nothing to say"
additionalInformations: ""
recallDate: <dateTimeBetween('now', '+5 days')>
createdAt: <dateTimeBetween('-1 days', 'now')>
updatedAt: <dateTimeBetween($createdAt, 'now')>
preTreatmentSmsDate: nuu
postTreatmentSmsDate: ""
callDestinationType: "group"
The Entity:
<?php
namespace Chronos\RestBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Chronos\RestBundle\Validator\Constraints as ChronosAssert;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Chronos
*
* @ORM\Table(name="chronos")
* @ORM\Entity(repositoryClass="Chronos\RestBundle\Entity\Repository\ChronosRepository")
* @ChronosAssert\ChronosConstraint()
*/
class Chronos
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var integer
*
* @ORM\Column(name="priority", type="integer")
* @Assert\NotBlank()
* @Assert\Regex("/^([123])$/")
*/
private $priority;
/**
* @var string
*
* @ORM\Column(name="call_destination", type="string", length=255)
* @Assert\NotBlank()
* @Assert\Type("string")
*/
private $callDestination;
/**
* @var string
*
* @ORM\Column(name="channel", type="string", length=255)
* @Assert\NotBlank()
* @Assert\Type("string")
*/
private $channel;
/**
* @var string
*
* @ORM\Column(name="client_phone_number", type="string")
* @Assert\NotBlank()
* @Assert\Type("string")
* @Assert\Regex("/^(0[1-9])(?:[ _.-]?(\d{2})){4}$/")
*/
private $clientPhoneNumber;
/**
* @var boolean
*
* @ORM\Column(name="is_active", type="boolean")
* @Assert\NotBlank()
* @Assert\Type("bool")
*/
private $active;
/**
* @var string
*
* @ORM\Column(name="inactive_cause", type="string", length=255, nullable=true)
* @Assert\Type("string")
*/
private $inactiveCause;
/**
* @var string
*
* @ORM\Column(name="additionnal_informations", type="json_array", nullable=true)
* @Assert\Type("string")
*/
private $additionalInformations;
/**
* @var \DateTime
*
* @ORM\Column(name="recall_date", type="datetime")
* @Assert\NotBlank()
* @Assert\DateTime()
*/
private $recallDate;
/**
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime")
* @Gedmo\Timestampable(on="create")
* @Assert\NotBlank()
* @Assert\DateTime()
*/
private $createdAt;
/**
* @var \DateTime
*
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
* @Gedmo\Timestampable(on="update")
* @Assert\DateTime()
*/
private $updatedAt;
/**
* @var \DateTime
*
* @ORM\Column(name="pre_treatment_sms_date", type="datetime", nullable=true)
* @Assert\DateTime()
*/
private $preTreatmentSmsDate;
/**
* @var \DateTime
*
* @ORM\Column(name="post_treatment_sms_date", type="datetime", nullable=true)
* @Assert\DateTime()
*/
private $postTreatmentSmsDate;
/**
* @var string
*
* @ORM\Column(name="call_destination_type", type="string", length=10)
* @Assert\Regex("#group|agent#")
*/
private $callDestinationType;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set priority
*
* @param integer $priority
*
* @return Chronos
*/
public function setPriority($priority)
{
$this->priority = $priority;
return $this;
}
/**
* Get priority
*
* @return integer
*/
public function getPriority()
{
return $this->priority;
}
/**
* Set callDestination
*
* @param string $callDestination
*
* @return Chronos
*/
public function setCallDestination($callDestination)
{
$this->callDestination = $callDestination;
return $this;
}
/**
* Get callDestination
*
* @return string
*/
public function getCallDestination()
{
return $this->callDestination;
}
/**
* Set channel
*
* @param string $channel
*
* @return Chronos
*/
public function setChannel($channel)
{
$this->channel = $channel;
return $this;
}
/**
* Get channel
*
* @return string
*/
public function getChannel()
{
return $this->channel;
}
/**
* Set clientPhoneNumber
*
* @param integer $clientPhoneNumber
*
* @return Chronos
*/
public function setClientPhoneNumber($clientPhoneNumber)
{
$this->clientPhoneNumber = $clientPhoneNumber;
return $this;
}
/**
* Get clientPhoneNumber
*
* @return integer
*/
public function getClientPhoneNumber()
{
return $this->clientPhoneNumber;
}
/**
* Set active�[D�[D�[D�[D�[D�[DisActive
*
* @param boolean $active
*
* @return Chronos
*/
public function setActive($active)
{
$this->active = $active;
return $this;
}
/**
* Get active�[D�[D�[D�[D�[D�[DisActive
*
* @return boolean
*/
public function getActive()
{
return $this->active;
}
/**
* Set inactiveCause
*
* @param string $inactiveCause
*
* @return Chronos
*/
public function setInactiveCause($inactiveCause)
{
$this->inactiveCause = $inactiveCause;
return $this;
}
/**
* Get inactiveCause
*
* @return string
*/
public function getInactiveCause()
{
return $this->inactiveCause;
}
/**
* Set additionalInformations
*
* @param string $additionalInformations
*
* @return Chronos
*/
public function setAdditionalInformations($additionalInformations)
{
$this->additionalInformations = $additionalInformations;
return $this;
}
/**
* Get additionalInformations
*
* @return string
*/
public function getAdditionalInformations()
{
return $this->additionalInformations;
}
/**
* Set recallDate
*
* @param \DateTime $recallDate
*
* @return Chronos
*/
public function setRecallDate($recallDate)
{
$this->recallDate = $recallDate;
return $this;
}
/**
* Get recallDate
*
* @return \DateTime
*/
public function getRecallDate()
{
return $this->recallDate;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
*
* @return Chronos
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set updatedAt
*
* @param \DateTime $updatedAt
*
* @return Chronos
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get updatedAt
*
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set preTreatmentSmsDate
*
* @param \DateTime $preTreatmentSmsDate
*
* @return Chronos
*/
public function setPreTreatmentSmsDate($preTreatmentSmsDate)
{
$this->preTreatmentSmsDate = $preTreatmentSmsDate;
return $this;
}
/**
* Get preTreatmentSmsDate
*
* @return \DateTime
*/
public function getPreTreatmentSmsDate()
{
return $this->preTreatmentSmsDate;
}
/**
* Set postTreatmentSmsDate
*
* @param \DateTime $postTreatmentSmsDate
*
* @return Chronos
*/
public function setPostTreatmentSmsDate($postTreatmentSmsDate)
{
$this->postTreatmentSmsDate = $postTreatmentSmsDate;
return $this;
}
/**
* Get postTreatmentSmsDate
*
* @return \DateTime
*/
public function getPostTreatmentSmsDate()
{
return $this->postTreatmentSmsDate;
}
/**
* Set callDestinationType
*
* @param string $callDestinationType
*
* @return Chronos
*/
public function setCallDestinationType($callDestinationType)
{
$this->callDestinationType = $callDestinationType;
return $this;
}
/**
* Get callDestinationType
*
* @return string
*/
public function getCallDestinationType()
{
return $this->callDestinationType;
}
}
I have some doubts and need to be clear before move to this awesome bundle. It's possible to use AliceFixturesBundle within DoctrineFixturesBundle? I mean right now I use Fixtures as follow:
class PaymentTypeFixtures extends AbstractFixture implements OrderedFixtureInterface
{
public function load(ObjectManager $manager)
{
$payment_type = array(
"Transferencia",
"Depósito"
);
foreach ($payment_type as $payment) {
$entity = new PaymentType();
$entity->setName($payment);
$manager->persist($entity);
$this->addReference('paymenttype-' . $payment, $entity);
}
$manager->flush();
}
public function getOrder()
{
return 3;
}
}
That allows me to define a reference
and use it in any Fixture by using getReference
and also define the order in which Fixtures are loaded because sometimes this is good since some entities relies on other entities and can cause troubles. If it's possible any example in how to get this done? If not it's possible to get this done from AliceFixturesBundle
or it's possible to use just the Faker part to generate current fake data?
Thanks in advance
When in .yml file I define:
Nelmio\Data\Geopoint (local): loader tries to persist this entity so I get Doctrine mapping error.
Im using doctrine's resolve interfaces (resolve target entity) ability to provide abstraction in my entities. The problem when I create a user this way:
It gives me an error when I do this:
Question\MyQuestionImplementaion\Question:
question{1..3}:
title: <realText(100)>
author: 1
text: <realText(2000)>
Question association looks like this:
@manyToMany(targetEntity="User\MyInterface\User")
Interface User\MyInterface\User
maps to User\MyImplementation\User
error I get is:
No ObjectManager for class User\MyInterface\User
Seems like issue is in h4cc\AliceFixturesBundle\ORM\Doctrine.php
How can I handle resolved interfaces?
Like DoctrineFixturesBundles, a getOrder()
Method will be handy for solving ordering problems when loading.
FixtureSets contain no reference to the used manager. When you have an ORM and an ODM manager, you cant load FixtureSets of both managers in one auto-detect request (php app/console h4cc_alice_fixtures:load:sets) ... you always have to load the sets separately.
So it seems to me at least.
Configure FixtureSets, instead of creating extra files for them.
These configured fixture sets, might also be used "by name" in the commands.
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
Unrecognized options "object_manager" under "h4cc_alice_fixtures.managers.default"
I am setting up NelmioAlice and Faker in a Symfony2 project through AlixeFixturesBundle. I need a composed fixture like for example:
representative{1..100}:
veeva_rep_id (unique): qlv_005800000067SwzAAE
which is a qlv_
prefix followed by a random 18 characters string. The best way I found to get this done (if anyone knows another one or a better way to get this done let me know) was using a custom faker and I wrote this piece of code:
<?php
/**
* FakerProvider: VeevaProvider.
*/
namespace PDI\PDOneBundle\DataFixtures;
use ReverseRegex\Lexer;
use ReverseRegex\Random\SimpleRandom;
use ReverseRegex\Parser;
use ReverseRegex\Generator\Scope;
class VeevaProvider extends \Faker\Provider\Base
{
public function veevaRepId()
{
$lexer = new Lexer('[a-zA-Z0-9]{18}');
$gen = new SimpleRandom(10007);
$result = '';
$parser = new Parser($lexer, new Scope(), new Scope());
$parser->parse()->getResult()->generate($result, $gen);
return 'qlv_' . $result;
}
}
As explain here in Faker docs. Now, here at NelmioAlice the author explain how to add Custom Faker Data Providers but it uses Doctrine Fixtures which I don't so, having this, how do I load and use the provider I wrote on the fixtures? Any advice around this? How the custom provider should be added and used on this bundle?
With the multi fixture manager feature, the compiler passes stopped working.
Because of the alias, this line failes:
$container->hasDefinition('h4cc_alice_fixtures.manager')
it needs to be replaced by
$container->findDefinition('h4cc_alice_fixtures.manager')
How can I go about troubleshooting entities which are not created. I've created a very simple fixture.yml and am using the h4cc_alice_fixtures:load:files command example to load it. The app/logs/dev.log show all the tables and index being recreated, and at the last two lines, there is a START TRANSACTION, and then an INSERT for the entity in the file. However, no rows are persisted to the database. I'm lost as to how to debug this.
The exact command I'm running is:
php app/console h4cc_alice_fixtures:load:files --manager=default --type=yaml --seed=42 --locale=de_DE --drop src/NM/Bundle/MyBundle/DataFixtures/Alice/Clients.yml
...and the fixture file simple contains:
NM\Bundle\MyBundle\Entity\Client:
client0:
name: Fixturetest
As requested in h4cc/AliceDemo#4 it would be a nice feature if fixture files and sets could be loaded from other or even multiple paths.
The current implementation using that single hardcoded path might not suite everywhere-
My idea is to have a list of paths relative to bundle base path configured somehow somewhere, which can also be changed by configuration.
I'm trying do achieve the following tricks.
From the Alice 1.x documentations:
You can reference entities' ID but you will then have to split fixtures in multiple files (this is because objects are persisted at the end of each file processing) :
# fixture_user.yml
Nelmio\Entity\User:
# ...
# fixture_group.yml
Nelmio\Entity\Group:
group1:
name: Admins
owner: @user1->id
Maybe there is something I miss but it look like objects are not persisted at the end of each file when I use Fixtures Set. Is it true or what did I miss ?
There seems to be a problem with doctrine persisting objects referencing already persisted other objects. Occured with 1-N references.
Example code that fixed a usecase:
foreach($entities as $key => $entity) {
$references[$key] = $manager->getORM()->find(get_class($entity), $entity->getId());
}
Please add the licence.
I was about to write this myself until I found this, the license could make it or break it :)
Can this bundle be used to load fixtures into Neo4j graph database?
Hi,
I've got a problem dealing with the Embeddable implemented in Doctrine 2.5.
Base on Doctrine documentation we can request the property of an Embeddable like this: "embeddable.property".
So my idea was that we should be able to generate fixture for the property the same way, for exemple:
AcmeBundle\Entity\Object:
email: <email()>
adress.city: Paris
Here I have Adress as an Embeddable and city one of the property.
Is it a way around in the current version or the functionnality still needs to be developped ?
Thanks for your work.
When I try to persist some fixtures using:
$manager = $client->getContainer()->get('h4cc_alice_fixtures.manager');
static::$fixtures = $manager->loadFiles(array(__DIR__ . '/../DataFixtures/product.yml',__DIR__ . '/../DataFixtures/itemProduct.yml'));
$manager->persist(static::$fixtures);
It fails with:
Doctrine\Common\Persistence\Mapping\MappingException: The class 'xxx\yyyBundle\Entity\Item' was not found in the chain configured namespaces
Because is not honouring the config.yml mapping configuration when you have multiple entity managers.
I think this is a good read on that:
http://php-and-symfony.matthiasnoback.nl/2014/05/inject-the-manager-registry-instead-of-the-entity-manager/
Instead of using files, a string with the content could be stored inside a FixtureSet or somehow else.
That would need quite seom changes, or may not be fully possible for PHP code.
First of all Thank you for this very nice/usefull Bundle.
When we get errors using it, we often don't have the yaml filename on our error stack.
For exemple the following error:
"[Symfony\Component\Debug\Exception\ContextErrorException]
Catchable Fatal Error: Argument 1 passed to
FOS\UserBundle\Model\User::setRoles() must be of the type array, string given, called in ...\vendor\nelmio\alice\src\Nelmio\Alice\Loader\Base.php on line 506 and defined"
To fix our bug, we must comment yaml files to be able to find where the current error is located
and then fix it.
With the concerned fixture yaml filename given, we could save precious time debugging :)
Fatal error: Nesting level too deep - recursive dependency? in /var/project/vendor/h4cc/alice-fixtures-bundle/Fixtures/FixtureManager.php on line 195
I'm seeing this when loading a YAML file with 180 objects.
Is there a way to add a config hook to skip this? Or can this be removed since it looks like it's fixed in Alice 1.7.0?
I have both databases in a project and would want to use this bundle to setup both with fixtures. Is that possible?
If not, any workaround i could try?
I have two bundles ComunBundle
and UsuariosBundle
each one have their own entities so I created DataFixtures
folder in each bundle and write fixtures
and sets
where them belongs to. But here goes the problem, in UsuarioBundle
I have this fixture defined:
UsuarioBundle\Entity\Usuario:
Usuario0:
pais: @Pais*
estado: @Estado*
municipio: @Municipio*
ciudad: @Ciudad*
parroquia: @Parroquia*
persona: f
correo_alternativo: [email protected]
telefono: <phoneNumber>
telefono_movil: <phoneNumber>
direccion: <address>
representativeName: <firstNameMale> <lastName>
username: admin
email: [email protected]
enabled: 1
plainPassword: 1qazxsw2
roles: ROLE_ADMIN
groups: @Grupo0
Usuario{1..10}:
pais: @Pais*
estado: @Estado*
municipio: @Municipio*
ciudad: @Ciudad*
parroquia: @Parroquia*
persona: <boolean(35)>
correo_alternativo: <safeEmail>
telefono: <phoneNumber>
telefono_movil: <phoneNumber>
direccion: <address>
representativeName: <firstNameMale> <lastName>
username: <firstNameMale>
email: <companyEmail>
enabled: <boolean(35)>
plainPassword: <lexify>
roles: 35%? [ROLE_ADMIN, ROLE_USER]
groups: @Grupo*
But @Pais*
, @Estado*
, @Municipio*
, @Ciudad*
and @Parroquia*
are references from ComunBundle
set. So when I try to load UsuarioBundle
set I get this error:
Symfony > h4cc_alice_fixtures:load:sets ./src/UsuarioBundle/DataFixtures/UsuarioSet.php
Loading file './src/UsuarioBundle/DataFixtures/UsuarioSet.php' ...
[UnexpectedValueException]
Reference mask "Pais*" did not match any existing reference, make sure the object is created after its references
How I should deal with external references? Any way to get all the sets loaded in some order since in order to work due to tables relationships (if this matter) I need to load first ComunBundle
sets and then UsuarioBundle
sets, any advice?
the command h4cc_alice_fixtures:load:files --drop should not truncate the doctrine migrations table(default is migration_versions ), if there's any .
When tearing down a testcase, some fixtures might be removed. Try to enable this.
Hi there!
Maybe I am missing something but following README instruction for adding new Faker providers lead me to the following error:
Symfony\Component\Debug\Exception\ContextErrorException]
Catchable Fatal Error: Argument 1 passed to Faker\Provider\Base::__construct() must be an instance of Faker\Generator, none given...
Every Faker Provider needs the dependency @faker.generator however this service is not registered by the bundle so if I add it the way:
services:
your.faker.provider:
class: YourProviderClass
arguments: [@faker.generator]
tags:
- { name: h4cc_alice_fixtures.provider }
I get the non existing dependency error.
Any clue?
I added the dev-master branch to my composer and added the bundle to my AppKernel. I get the following error using Symfony 2.3.6.
[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]
The service "h4cc_alice_fixtures.orm.schema_tool.doctrine" has a dependency on a non-existent parameter "h4cc_alice_fixtures.orm.schema_tool.doctrine". Did you mean one of these: "h4cc_alice_fixtures.orm.schema_tool.class", "h4cc_alice_fixtures.orm.schema_tool.doctrine.class"?
Was there any other configuration I was supposed to do?
Imagine the following 3 (simplified) entities:
Entity\Item:
type: entity
table: item
fields:
id:
id: true
type: integer
unsigned: true
nullable: false
generator:
strategy: IDENTITY
Entity\Product:
type: entity
table: product
fields:
id:
id: true
type: integer
unsigned: true
nullable: false
generator:
strategy: IDENTITY
Entity\ItemProduct:
type: entity
table: item_product
id:
item:
associationKey: true
product:
associationKey: true
fields:
updatedAt:
type: datetime
nullable: false
manyToOne:
item:
targetEntity: Entity\Item
oneToOne:
product:
targetEntity: Entity\Product
and the following fixture file:
Entity\Item:
item{1..10}:
itemName: <sentence()>
updatedAt: <dateTimeBetween('-1 year', 'now')>
Entity\Product:
product{1..20}:
productSku: <bothify('?????????##')>
updatedAt: <dateTimeBetween('-1 year', 'now')>
Entity\ItemProduct:
itemProduct{1..40}:
item: @item<numberBetween(1, 10)>
product: @product<numberBetween(1, 20)>
updatedAt: <dateTimeBetween('-1 year', 'now')>
When trying to load this It will always fail with an error such as:
[Doctrine\ORM\ORMException]
Entity of type Entity\ItemProduct has identity through a foreign entity Entity\Item,
however this entity has no identity itself. You have to call EntityManager#persist() on the related entity and make sure that an identifier was generated before
trying to persist 'Entity\ItemProduct'. In case of Post Insert ID Generation (such as MySQL Auto-Increment or PostgreSQL SER
IAL) this means you have to call EntityManager#flush() between both persist operations.
Since the id for Item and Product is generated by the database if you try to persist the entity with a primary key formed by association keys it will fail since it's not able to find an id to use when persisting.
I kind of "hacked" this behaviour by catching this exception an issuing a flush then but this is far from being the right solution.
I also tried separating the fixture into files doing first Product and Item and then ItemProduct but this way you can't keep the fanciness of using things such as @item<numberBetween(1, 10)>
when creating ItemProduct entities.
Another way will be to add a flag to force a flush between files, not the perfect one but it will alleviate the issue. Maybe I'm missing something else here but I'm not able to find a way to do this in a proper way 😞
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.