You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using factories with Codeception quite some time. I'm just using them in my helpers (example here), but I encountered a problem with some memory leaks from Faker library.
If we want to support factories we'd need to re-bind Faker & EloquentFactory in _after hook, to remove all references to faker between tests, so garbage collector can do his job.
Something like that:
$this->app->singleton(FakerGenerator::class, function ($app) {
return FakerFactory::create($app['config']->get('app.faker_locale', 'en_US'));
});
$this->app->singleton(EloquentFactory::class, function ($app) {
return EloquentFactory::construct(
$app->make(FakerGenerator::class), $this->app->databasePath('factories')
);
});
I know that this isn't perfect but Laravel doesn't have build in method to run it on application. They're doing this here
Activity
torkiljohnsen commentedon Dec 20, 2016
👍
AdrianSkierniewski commentedon May 14, 2018
Hi,
I'm using factories with Codeception quite some time. I'm just using them in my helpers (example here), but I encountered a problem with some memory leaks from Faker library.
If we want to support factories we'd need to re-bind Faker & EloquentFactory in
_afterhook, to remove all references to faker between tests, so garbage collector can do his job.Something like that:
I know that this isn't perfect but Laravel doesn't have build in method to run it on application. They're doing this here
[-][Laravel 5.3] Can't use factory states with codeception[/-][+]Can't use factory states with Codeception[/+]