Skip to content

Commit f37edc9

Browse files
committed
fix factory function call to compability with Laravel 7
1 parent d6bcc25 commit f37edc9

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/Codeception/Module/Laravel5.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Illuminate\Database\Eloquent\Model as EloquentModel;
1515
use Illuminate\Support\Collection;
1616
use Symfony\Component\Console\Output\OutputInterface;
17+
use Illuminate\Foundation\Application;
1718

1819
/**
1920
*
@@ -437,7 +438,7 @@ public function callArtisan($command, $parameters = [], OutputInterface $output
437438
$this->debug($output);
438439
return $output;
439440
}
440-
441+
441442
$console->call($command, $parameters, $output);
442443
}
443444

@@ -1164,7 +1165,7 @@ public function haveMultiple($model, $times, $attributes = [], $name = 'default'
11641165
$this->fail("Could not create model: \n\n" . get_class($e) . "\n\n" . $e->getMessage());
11651166
}
11661167
}
1167-
1168+
11681169
/**
11691170
* Use Laravel's model factory to make a model instance.
11701171
* Can only be used with Laravel 5.1 and later.
@@ -1192,7 +1193,7 @@ public function make($model, $attributes = [], $name = 'default')
11921193
$this->fail("Could not make model: \n\n" . get_class($e) . "\n\n" . $e->getMessage());
11931194
}
11941195
}
1195-
1196+
11961197
/**
11971198
* Use Laravel's model factory to make multiple model instances.
11981199
* Can only be used with Laravel 5.1 and later.
@@ -1236,7 +1237,13 @@ protected function modelFactory($model, $name, $times = 1)
12361237
'This functionality relies on Laravel model factories, which were introduced in Laravel 5.1.');
12371238
}
12381239

1239-
return factory($model, $name, $times);
1240+
if (version_compare(Application::VERSION, '7.0.0', '<')) {
1241+
$factory = factory($model, $name, $times);
1242+
} else {
1243+
$factory = factory($model, $times);
1244+
}
1245+
1246+
return $factory;
12401247
}
12411248

12421249
/**

0 commit comments

Comments
 (0)