kirkbushell / eloquence

A drop-in library for certain database functionality in Laravel, that allows for extra features that may never make it into the main project.
MIT License
537 stars 58 forks source link

PHPUnit Tests Fail while using Uuid Model #24

Closed brenjt closed 9 years ago

brenjt commented 9 years ago

When testing models with phpunit. I get an Field 'id' doesn't have a default value. For some reason all second tests fail when creating the id. It looks like the static::creating callback is never getting called the second time. This is only prevalent in unit testing and not in regular laravel. Thoughts?

kirkbushell commented 9 years ago

Can you provide an example of your model + tests? Can't really help otherwise. Creating should only get called once - when the model object is originally "created". And this only happens if the model has no id and $exists is false.

brenjt commented 9 years ago

It looks like this is the real issue here. https://github.com/laravel/framework/issues/1181

kirkbushell commented 9 years ago

Okay closing as it appears as though it's something else :)

brenjt commented 9 years ago

Yeah when it came down to it, the problem was Laravel not calling the events again during unit tests. Although it appeared that the issue was on UUID model it is in fact on Laravel. Not much one can do until it's fixed with them.

cyrodjohn commented 8 years ago

Is there a solution for this? static::creating callback is never called on a phpunit test by default so the UUID is never generated when performing tests.