laracasts / TestDummy

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

The {type} model was not found. #69

Closed hardikaecor closed 9 years ago

hardikaecor commented 9 years ago

I am trying to load the basic testdummy as follows

<?php
                Factory::$factoriesPath = base_path() . '/tests/factories';
        $userAttributes = Factory::build('User');
        return $userAttributes;

and my tests/factories/users.php file is as follows:

<?php
    $factory('User', [
        'first_name' => $faker->firstName,
        'last_name' => $faker->lastName,
        'email' => $faker->unique()->email,
        'password' => $faker->password,
        'gender' => $faker->randomElement(['Male', 'Female']),
        'activated' => $faker->boolean
    ]);

but when i run, it gives me error The User model was not found.

does anyone knows what this is?

gin93r commented 9 years ago

I'm having the same issue when trying to use TestDummy for seeding. Basically the same setup as @hardikaecor . I've tried changing to TestDummy::times(5)->create('App\Events'); but I get a TestDummyException Could not locate a factory with the name: App\Events. Without App\ I get the same error as above.

gin93r commented 9 years ago

I was able to solve this by changing my factories.php file. I was using $factory('Events' instead of $factory('App\Events'.