Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Passing non entity value from one fixture to others #273

Open
remi-blaise opened this issue Nov 12, 2017 · 0 comments
Open

Feature: Passing non entity value from one fixture to others #273

remi-blaise opened this issue Nov 12, 2017 · 0 comments

Comments

@remi-blaise
Copy link

Hello!

Here is my use case: I want to pass a list of references from AFixture to BFixture.
For now I'm forced to make a loop:

// in AFixture.php
foreach ($skills as $key => $skill) {
    $this->addReference('skill-' . $key, $skill);
}

Thus, I made a loop too for recovering the data:

// BFixture.php
$skills = [];
for ($i=0; $i < $nbOfRegisteredSkills; $i++) {
    $skills[] = $this->getReference('skill-' . $i);
}

There is one problem: I have no mean to get $nbOfRegisteredSkills, as I can't pass integer.

For now, I'm using a global variable:

// AFixture.php
$GLOBALS['count_skills'] = count($skills);

// BFixture.php
$skills = [];
for ($i=0; $i < $GLOBALS['count_skills'] - 3; $i++) {
    $skills[] = $this->getReference('skill-' . $i);
}

So it would be very usefull to be able to pass every type of data, especially integers and entities lists.
We could for exemple replace Doctrine\Bundle\FixturesBundle\Fixture::addReference/implement a new method accepting any kind of data.

What do you think about that?

Best regards,
Zzortell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants