Skip to content
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

Fixed issue where getRoles and getPermissions methods returned empty lists #182

Open
wants to merge 1 commit into
base: 1.0
Choose a base branch
from

Conversation

konovalov-nk
Copy link

This fixes issue on Laravel 5.3 where existing model instances wouldn't work:

$user_admin = \App\User::first();
$user_admin->assignRole(ROLE_ADMIN);

// $user_admin->getRoles is empty!
$this->assertEquals($user_admin->getRoles(), [
    1 => ROLE_ADMIN
]);
// $user_admin->getPermissions is empty!
$this->assertEquals($user_admin->getPermissions(), $admin_role->getPermissions());

However, new created user works:

$user_admin = new User();
$user_admin->firstname = 'Role';
$user_admin->lastname = 'test';
$user_admin->newsletter = 0;
$user_admin->email = '[email protected]';
$user_admin->password = 'RoleTest';
$user_admin->save();

$user_admin->assignRole(ROLE_ADMIN);

// Test passes.
$this->assertEquals($user_admin->getRoles(), [
    1 => ROLE_ADMIN
]);
// Test passes.
$this->assertEquals($user_admin->getPermissions(), $admin_role->getPermissions());

@konovalov-nk konovalov-nk changed the title - Fixed issue where getRoles and getPermissions methods returned empty lists Fixed issue where getRoles and getPermissions methods returned empty lists Dec 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant