Updating Laravel to 5.6.29 breaks Model observers.
Everything works fine on v5.6.28
Create UserObserver for User model.
Create "creating" method inside UserObserver, to assign for example "pin" to user model.
'creating' method won't be called at all on v5.6.29.
It works for me. Can you post your code?
Or ideally a unit test that proves that, so we can avoid breaking it in the future?
If your test suite is failing on Eloquent event assertions, it may be due to a breaking change made to Event::fake() called for specific classes:
Event::fake(['eloquent.creating: ' . User::class]);
It'll be fixed in 5.6.30 that I assume comes out tomorrow: https://github.com/laravel/framework/pull/24985
@derekmd I have 'pin' field in my table which is not null. Value has to be generated randomly when creating model, so I never mocked it in unit tests it so it could work the way it is.
All tests are passing on v5.6.28. But on v5.6.29, in unit test where I create new model with factory 'creating' method on observer never being called and test fails with MySQL error null not violation.
I just created fresh Laravel project. Did the same thing, interestingly everything works without a problem.
I think this is fixed now, as of the latest release. Please ping if not. :)
@GrahamCampbell This is not fixed yet because v5.6.30 has not yet been released.
I don't know the deciding factors for when a minor release is done but I think that an accidental breaking change should probably be an influential one.
@GrahamCampbell This is still not fixed at the moment, due to 5.6.30 not being tagged. We use the https://github.com/illuminate/support subtree split for some projects here and the fix missed the 5.6.29 by just a day there.
Any chance a new release could be tagged with the fix? Our test suite is failing at the moment.
Most helpful comment
@GrahamCampbell This is not fixed yet because v5.6.30 has not yet been released.
I don't know the deciding factors for when a minor release is done but I think that an accidental breaking change should probably be an influential one.