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

Eloquent model factory makes 2 models when it should build 0 #15755

Closed
etherealite opened this issue Oct 4, 2016 · 0 comments
Closed

Eloquent model factory makes 2 models when it should build 0 #15755

etherealite opened this issue Oct 4, 2016 · 0 comments

Comments

@etherealite
Copy link

  • Laravel Version: 5.3.15
  • PHP Version: 7.0.8-2+deb.sury.org~xenial+1 (cli) ( NTS )
  • Database Driver & Version: Irrelevant

Description:

Eloquent model factories (the ones for seeding test data and such) that reside in database/factories/ModelFactory.php, have a strange behavior.
The FactoryBuilder::make() method makes multiple models even when FactoryBuilder::$amount
is set to 0.

Steps To Reproduce:

vagrant@homestead: php artisan tinker
Psy Shell v0.7.2 (PHP 7.0.8-2+deb.sury.org~xenial+1 — cli) by Justin Hileman
>>> factory(App\User::class, 0)->make();
=> Illuminate\Database\Eloquent\Collection {#704
     all: [
       App\User {#700
         name: "Emie Will",
         email: "nicolas.kathleen@example.org",
       },
       App\User {#687
         name: "Anna Jones",
         email: "eli76@example.org",
       },
     ],
   }

As per the above, one would expect the make() method to create an empty array or some other indicator that no models were created. Instead an array with 2 models is returned.

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

2 participants