Replies: 2 comments 2 replies
-
Laravel 11 seems to be working, look: https://github.com/spatie/laravel-permission/actions/runs/9239793952/job/25419362560 |
Beta Was this translation helpful? Give feedback.
0 replies
-
I seem to have solved the issue by having to pull the permissions registrar from the container, set the team id and put it back in the container during my test before calling $registrar = app(PermissionRegistrar::class);
$registrar->setPermissionsTeamId($this->team->id);
$this->swap(PermissionRegistrar::class, $registrar); Not sure why though |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
I am currently working through the Laravel Shift bits to upgrade a project from Laravel 10 to 11. We make use of the permissions package, and have teams enabled.
However, we are encountering issues in the test suite when running our Feature tests, which use
$this->user->assignRole('admin');
. These tests are all producing a MySQL constraint exception because theteam_id
cannot be found.Things I've tried
I have chased the code for the teams through and found the helpers
setPermissionsTeamId()
andgetPermissionsTeamId()
, but adding these I still get an error.I can
dd()
both the sessionteam_id
and also thegetPermissionsTeamId()
and they return the correct value.I also tried flushing the permissions using
forgetCachedPermissions()
in thePermissionRegistrar
class.Any thoughts?
Beta Was this translation helpful? Give feedback.
All reactions