laracasts / TestDummy

Easy factories for PHP integration testing.
https://laracasts.com/lessons/whats-new-in-testdummy
MIT License
456 stars 80 forks source link

Missing argument 2 for Laracasts\TestDummy\FactoriesLoader::{closure}() #85

Closed gbrock closed 9 years ago

gbrock commented 9 years ago
[ErrorException]                                                         
Missing argument 2 for Laracasts\TestDummy\FactoriesLoader::{closure}() 

This error seems to be thrown despite no changes in relevant code.

My factory:

$factory('App\User', function($faker, $overrides) {
    $created = $faker->dateTimeBetween('-2 years', 'now');

    return [
        'username' => $faker->userName,
        'friendly_name' => $faker->firstName,
        'email' => $faker->safeEmail,
        'created_at' => $created,
        'last_login' => $faker->dateTimeBetween($created, 'now'),
    ];
});

My seed:

use Illuminate\Database\Seeder;
use Laracasts\TestDummy\Factory;

class UserTableSeeder extends Seeder {

    public function run()
    {
        DB::table('users')->delete();
        Factory::times(200)->create('App\User');
    }
}
JeffreyWay commented 9 years ago

Remove the $overrides argument from your $factory() call.