Closed JonoB closed 8 years ago
I don't see how this could be happening?
https://github.com/thephpleague/factory-muffin/blob/master/src/FactoryMuffin.php#L181
Yeah, its because our factories were set up V2 style:
$fm->define(\Category::class, [
'code' => Faker::word(),
'name' => Faker::sentence(),
]);
Instead, we need to be using the setDefinitions
method:
$fm->define(Category::class)->setDefinitions([
'code' => Faker::word(),
'name' => Faker::sentence(),
]);
Assuming we have a factory as follows:
And in one of our tests we want to inject
companyId
property:In this case, if
$category->toArray()
looks like this:Basically, the default proprties (
code
andname
) are now gone. Why does injecting properties as the second parameter to->create()
method completely replace all model properties? This doesn't seem to be expected behavior (or consistent with V2).Am I missing something obvious here?