-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using HasRelationshipObservables trait in multiple models causes double events to be fired in tests #40
Comments
Thanks, @BoyeMagnus |
Yes I'll provide one asap 😄 |
Thanks again, i'll look into it tomorrow. |
ping @BoyeMagnus |
Sorry for the delay, had a pretty rough sprint. Adding I've created a PR with the test here: #41 |
@chelout ping |
@BoyeMagnus sorry for the huge delay, working on MVP project for days and nights 🤯 |
When adding the HasRelationshipObservables trait to multiple models, the tests often fail, because of observers receiving the event twice.
For eg. a user and a group model with HasRelationshipObservables. With two observers that subscribe to belongsToManyAttached both.
Static properties will most of the time in tests never be reset, because of how PHPUnit works. When booting
HasRelationshipObservables
, then it merges the$methods
with thestatic $relationshipObservables
. This causes the observer to be fire multiple times in tests where the static property is never reset.A solution would be to set $relationshipObservables to an empty array in the bootHasRelationshipObservables. Anyone expiring the same issues?
The text was updated successfully, but these errors were encountered: