Skip to content

Commit

Permalink
Merge pull request #6 from marvin255/feature/fix-haveMany
Browse files Browse the repository at this point in the history
Fix factory function call to compability with Laravel 7
  • Loading branch information
Naktibalda authored Mar 28, 2020
2 parents d6bcc25 + f37edc9 commit 419c382
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Codeception/Module/Laravel5.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Illuminate\Database\Eloquent\Model as EloquentModel;
use Illuminate\Support\Collection;
use Symfony\Component\Console\Output\OutputInterface;
use Illuminate\Foundation\Application;

/**
*
Expand Down Expand Up @@ -437,7 +438,7 @@ public function callArtisan($command, $parameters = [], OutputInterface $output
$this->debug($output);
return $output;
}

$console->call($command, $parameters, $output);
}

Expand Down Expand Up @@ -1164,7 +1165,7 @@ public function haveMultiple($model, $times, $attributes = [], $name = 'default'
$this->fail("Could not create model: \n\n" . get_class($e) . "\n\n" . $e->getMessage());
}
}

/**
* Use Laravel's model factory to make a model instance.
* Can only be used with Laravel 5.1 and later.
Expand Down Expand Up @@ -1192,7 +1193,7 @@ public function make($model, $attributes = [], $name = 'default')
$this->fail("Could not make model: \n\n" . get_class($e) . "\n\n" . $e->getMessage());
}
}

/**
* Use Laravel's model factory to make multiple model instances.
* Can only be used with Laravel 5.1 and later.
Expand Down Expand Up @@ -1236,7 +1237,13 @@ protected function modelFactory($model, $name, $times = 1)
'This functionality relies on Laravel model factories, which were introduced in Laravel 5.1.');
}

return factory($model, $name, $times);
if (version_compare(Application::VERSION, '7.0.0', '<')) {
$factory = factory($model, $name, $times);
} else {
$factory = factory($model, $times);
}

return $factory;
}

/**
Expand Down

0 comments on commit 419c382

Please sign in to comment.