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

Factory::create() weird behaviour #61

Open
toonevdb opened this issue Jun 24, 2014 · 0 comments
Open

Factory::create() weird behaviour #61

toonevdb opened this issue Jun 24, 2014 · 0 comments

Comments

@toonevdb
Copy link

What I encounter is that Factory::product() does an sql query for categories when I use a Factory::create() call.

    // create dummy data in db
    //$user = Factory::create('User');
    $user = Factory::user();
    $user->company_id = null;
    $user->save();

    //$company = Factory::create('Company');
    $company = Factory::company();
    $company->save();

    $category = Factory::category();
    $category->parent_id = null;
    $category->save();

    $product = Factory::product();
    dd($product);
    $product->category_id = $category->id;
    $product->company_id = $company->id;
    //$product->save();

If I uncomment $company = Factory::create('Company') or $user = Factory::create('User') an error is thrown on the $product = Factory::product() line because it tries to insert data in the categories table.. I do see that the last call with Factory is Factory::category() before calling Factory::product() but it should not do any queries and certainly not on the categories table.

The code above works because all Factory::create() calls are worked around. I can create my test and make it work but it's probably not expected behaviour.

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

No branches or pull requests

1 participant