fzaninotto/Faker

Smart enough to relate the populated Book entities to one of the populated Author

Opened this issue · 0 comments

Summary

Faker is smart enough to relate the populated Book entities to one of the populated Author entities.

Versions

Version
PHP 7.3.8
fzaninotto/faker v1.9.0

Self-enclosed code snippet for reproduction

        $populator->addEntity('User', 1);
        $populator->addEntity('Work', 5, [
            'state' => function () { return $this->generator->word(); }
        ]);

Expected output

5 work wntities related to a setInitiator which is user generated

Actual output

In the work entity I have 
    public function setInitiator(User $initiator) ....

TypeError: Argument 1 passed to Work::setInitiator() must be an instance of User, null given, called in /var/www/.../vendor/fzaninotto/faker/src/Faker/ORM/Doctrine/EntityPopulator.php on line 215

Do you have a workaround in such a case where Probably setInitiator method name confuses the expected setUser ?

with kind regards