Hi @KenoKokoro,
Thank you for your reply.
I think I just found my problem:
This is how I set up my ACL in the AuthServiceProvider:
/**
* Register any authentication / authorization services.
*
* @param \Illuminate\Contracts\Auth\Access\Gate $gate
* @return void
*/
public function boot(GateContract $gate)
{
$this->registerPolicies();
foreach ($this->getPermissions() as $permission) {
$gate->define($permission->name, function($user) use ($permission) {
// check if the user has the roles that the permission is associated with
return $user->hasRole($permission->roles);
});
}
}
/**
* Get all permissions
*/
protected function getPermissions()
{
try {
return Permission::with('roles')->get();
} catch (\Exception $e) {
return [];
}
}
It looks like that, in the test, the getPermissions() method always returns an empty array, while in the browser, once the permissions table is not empty, getPermissions() method will return an array containing permissions.
I am just wondering if the boot method in AuthServicerProvider is only run once in the beginning of the
function an_admin_can_see_the_workshop_a_ticket_belongs_to_on_the_tickets_list_page()
{
...
}
testing method.
Another question, so when this line of code:
$this->visit('dashboard/tickets')
is executed, the Laravel serviceprovider is not initialised?
Thank you