Temporary fix for incorrect role class name #313
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to issue #306
After some intense digging, I might have found the problem. Whenever I run more than one phpunit test at once, Bouncer failes to fetch the list of abilities for current authenticated user. This only happens when using a custom role model with
Bouncer::useRoleModel(Role::class);
.When using the custom role model, the
getMorphClass()
function of laravelsHasRelationships.php
returns the keyroles
instead of the actual class name (but only starting at the second test while running phpunit!).Because of that, Bouncers
getRoleConstraint()
query failes to find the abilities since the tablesentitiy_type
column contains the custom role models class name instead of the returnedroles
string from the morph map.I am not entirely sure why you used
Models::role()->getMorphClass()
since I did not fully understand the concept yet. However, my change to this line eliminates the error for now while passing your unit tests.