Laravel 5.1 Eloquent isFillable() discrepancy in unit tests

后端 未结 1 933
Happy的楠姐
Happy的楠姐 2021-01-24 07:35

Is there a reason why Eloquent ignores the fillable settings for a model when used in a unit test?

In a non test situation, I get the following output, which is correct,

1条回答
  •  無奈伤痛
    2021-01-24 08:21

    I was running into this as well. Apparently Laravel unguards models during unit tests so you have to reguard them with Eloquent::reguard(). I would put it in the setUp() method so it runs before every test.

    0 讨论(0)
提交回复
热议问题