theofidry / AliceBundle

A Symfony bundle to manage fixtures with Alice and Faker.
MIT License
163 stars 98 forks source link

Complete reference to random data functions + related pre-existing entity in database #64

Open nzurita opened 8 months ago

nzurita commented 8 months ago

Hello, where can I find a complete reference to functions like <firstName()>, <lastName()>, <sentence()> etc.? I'm unable to find it in the docs.

And... Is there a function to reference a related pre-existing entity in database? This entity is not loaded in any fixture but already exists in database and has a relation to current entity in fixture.

Thank you.

theofidry commented 8 months ago

Hi!

where can I find a complete reference to functions like <firstName()>, <lastName()>, <sentence()> etc.? I'm unable to find it in the docs.

You can find more information about this here, including how to register your own.

And... Is there a function to reference a related pre-existing entity in database? This entity is not loaded in any fixture but already exists in database and has a relation to current entity in fixture.

IIRC, if you are using the underlying loader in your tests (to load specific files, as opposed to the generic load all fixtures based on an environment), you can fetch entities beforehand and pass them as existing object to the loader. In this case they can be referenced by the fixtures.

I don't remember the exact specifics though so you would need to dig a little bit there.