From 65452a48da691648a56c732af2673f73370095bf Mon Sep 17 00:00:00 2001 From: Ivelin Pavlov Date: Wed, 7 Apr 2021 14:22:33 +0300 Subject: [PATCH] Fix Factory compatibility issue with Lumen < 7 With illuminate/database version 7 Factory names are removed - more info https://github.com/laravel/framework/pull/30867/ Checking for property `name` ensures that this parameter can be passed. --- src/Codeception/Module/Lumen.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Codeception/Module/Lumen.php b/src/Codeception/Module/Lumen.php index aaef12e..7096ebe 100644 --- a/src/Codeception/Module/Lumen.php +++ b/src/Codeception/Module/Lumen.php @@ -587,10 +587,16 @@ public function makeMultiple(string $model, int $times, array $attributes = [], */ protected function modelFactory(string $model, string $name, int $times = 1) { - if (function_exists('factory')) { + if (!function_exists('factory')) { + return $model::factory()->count($times); + } + + // Support for Lumen < 7 (Factory names defined in illuminate/database version < 7) + if (property_exists(FactoryBuilder::class, 'name')) { return factory($model, $name, $times); } - return $model::factory()->count($times); + + return factory($model, $times); } /**