Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[6.x] Add loadFactoriesFrom method #31133
This PR implements a new
$this->loadFactoriesFrom('source/database/factories'); $this->loadFactoriesFrom([ 'source_one/database/factories', 'source_two/database/factories', ]);
Right now, there is no way to use a package's factories that are using models provided by the package itself. For testing the package and the application integration, it's easier to use the package's factories if there is any, instead of rewrite the factories.
Right now, packages can't load their own factories like migrations, views or routes, however it may be a help to the developers to use the package factories easily as well.
orchestral/testbench offers something similar to solve this for package testing:
I did not find any tests for the route or migration loading from the provider and right now I don't see how to test this easily. This is why I skipped tests.
If more than one factory registers factory model for the same model more than one, how does we control it now? Remember, with this it automatically declared and loaded now.