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

Could not locate a factory #93

Open
prady00 opened this issue Mar 28, 2015 · 9 comments
Open

Could not locate a factory #93

prady00 opened this issue Mar 28, 2015 · 9 comments

Comments

@prady00
Copy link

prady00 commented Mar 28, 2015

#php artisan db:seed --class=TeamsTableSeeder

[Laracasts\TestDummy\TestDummyException]
Could not locate a factory with the name: App\Team

I have done composer dump-autoload and clear-cache

All files are present in their appropriate namespace.

What could be the possible reason for this error?

@JeffreyWay
Copy link
Collaborator

Let me see your factories file.

@Luckyfox
Copy link

Hi Jeff,

I get the same issue as above. But when in iterm2 all works fine apart from 5 of these messages each time..

Warning: include_once(): Failed opening '/Users/nigel/projects/work/laravel/tests/functional' for inclusion (include_path='/Users/nigel/projects/work/laravel/vendor/phpunit/php-text-template:/Users/nigel/projects/work/laravel/vendor/phpunit/php-timer:/Users/nigel/projects/work/laravel/vendor/phpunit/php-file-iterator:.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/lib/php/PHPUnit/Util/Fileloader.php on line 95

Hope that might shed some light ont he issue..

@ruuter
Copy link

ruuter commented Jul 29, 2015

I'm getting same error, but only in remote server.
In my local installation all works fine without any problems.
Dumping composer autoload and clearing cache did not help.

$ php artisan db:seed -vvv --class=WishTableSeeder

[Laracasts\TestDummy\TestDummyException]
Could not locate a factory with the name: App\Models\Wish

Exception trace:

() at ...vendor/laracasts/testdummy/src/Builder.php:196
Laracasts\TestDummy\Builder->getFixture() at ...vendor/laracasts/testdummy/src/Builder.php:155
Laracasts\TestDummy\Builder->getAttributes() at ...vendor/laracasts/testdummy/src/Builder.php:96
Laracasts\TestDummy\Builder->build() at ...vendor/laracasts/testdummy/src/Builder.php:134
Laracasts\TestDummy\Builder->persist() at ...vendor/laracasts/testdummy/src/Builder.php:115
Laracasts\TestDummy\Builder->create() at ...database/seeds/WishTableSeeder.php:11

@antoniputra
Copy link

I have the same issue. in my case, because the name of defineAs and factory method is different.
this happen for me after I change the namespaces of Model and I forgot to update the namespaces in factory() method

// ModelFactory.php
$factory->defineAs(App\Models\User::class, 'superadmin', function ($faker) use ($factory) {
    $user = $factory->raw(App\Models\User::class);

    return array_merge($user, config('site_default.users.superadmin'));
});
// UserSeeder.php file
factory('App\User', 'superadmin')->create();   // <---- I forget change this. should : App\Models\User
$this->command->comment(PHP_EOL .'User superadmin was generated...');

@ruuter
Copy link

ruuter commented Aug 12, 2015

@antoniputra
Unfortunately that is not a case for me, since everything is working in my local installation.
This happens only in remote server.

@antoniputra
Copy link

oh, are you sure with your remote server environment set up ?

you are using external package, I don't familiar with this Exception. [Laracasts\TestDummy\TestDummyException]

can you show me your ModelFactories and WishTableSeeder code ?

@ruuter
Copy link

ruuter commented Aug 12, 2015

@antoniputra I am using Laracast/Testdummy, the very same package in which git repo we talk right now.
Yes, I'm positive this only happens in remote server. Not sure what can cause this. I'm trying to track this down right now.
One interesting thing I did not notice before is the fact that my whole factories.php file gets printed to stdout.

@ruuter
Copy link

ruuter commented Aug 12, 2015

I found it. It was PHP environment problem.
I have shortcode php start tag in factories.php and even though I do have short_open_tag = On in remote php, I did not have it On in php cli.
So it was PHP environment problem.

@antoniputra
Copy link

glad hear it. :D

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

5 participants