Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Traits/HasPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public function checkPermissionTo($permission, $guardName = null): bool
{
try {
return $this->hasPermissionTo($permission, $guardName);
} catch (PermissionDoesNotExist $e) {
} catch (PermissionDoesNotExist) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function it_can_setup_teams_upgrade()
->assertExitCode(0);

$matchingFiles = glob(database_path('migrations/*_add_teams_fields.php'));
$this->assertTrue(count($matchingFiles) > 0);
$this->assertNotEmpty($matchingFiles);

$AddTeamsFields = require $matchingFiles[count($matchingFiles) - 1];
$AddTeamsFields->up();
Expand Down
2 changes: 1 addition & 1 deletion tests/GateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function it_can_determine_if_a_user_has_a_direct_permission_using_enums()
{
$enum = TestModels\TestRolePermissionsEnum::VIEWARTICLES;

$permission = app(Permission::class)->findOrCreate($enum->value, 'web');
app(Permission::class)->findOrCreate($enum->value, 'web');

$this->assertFalse($this->testUser->can($enum->value));
$this->assertFalse($this->testUser->canAny([$enum->value, 'some other permission']));
Expand Down
18 changes: 9 additions & 9 deletions tests/HasPermissionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function it_can_assign_and_remove_a_permission_using_enums()
{
$enum = TestModels\TestRolePermissionsEnum::VIEWARTICLES;

$permission = app(Permission::class)->findOrCreate($enum->value, 'web');
app(Permission::class)->findOrCreate($enum->value, 'web');

$this->testUser->givePermissionTo($enum);

Expand All @@ -113,13 +113,13 @@ public function it_can_scope_users_using_enums()
{
$enum1 = TestModels\TestRolePermissionsEnum::VIEWARTICLES;
$enum2 = TestModels\TestRolePermissionsEnum::EDITARTICLES;
$permission1 = app(Permission::class)->findOrCreate($enum1->value, 'web');
$permission2 = app(Permission::class)->findOrCreate($enum2->value, 'web');
app(Permission::class)->findOrCreate($enum1->value, 'web');
app(Permission::class)->findOrCreate($enum2->value, 'web');

User::all()->each(fn ($item) => $item->delete());
$user1 = User::create(['email' => '[email protected]']);
$user2 = User::create(['email' => '[email protected]']);
$user3 = User::create(['email' => '[email protected]']);
User::create(['email' => '[email protected]']);
$user1->givePermissionTo([$enum1, $enum2]);
$this->testUserRole->givePermissionTo($enum2);
$user2->assignRole('testRole');
Expand All @@ -142,7 +142,7 @@ public function it_can_scope_users_using_a_string()
User::all()->each(fn ($item) => $item->delete());
$user1 = User::create(['email' => '[email protected]']);
$user2 = User::create(['email' => '[email protected]']);
$user3 = User::create(['email' => '[email protected]']);
User::create(['email' => '[email protected]']);
$user1->givePermissionTo(['edit-articles', 'edit-news']);
$this->testUserRole->givePermissionTo('edit-articles');
$user2->assignRole('testRole');
Expand All @@ -163,7 +163,7 @@ public function it_can_scope_users_using_a_int()
User::all()->each(fn ($item) => $item->delete());
$user1 = User::create(['email' => '[email protected]']);
$user2 = User::create(['email' => '[email protected]']);
$user3 = User::create(['email' => '[email protected]']);
User::create(['email' => '[email protected]']);
$user1->givePermissionTo([1, 2]);
$this->testUserRole->givePermissionTo(1);
$user2->assignRole('testRole');
Expand Down Expand Up @@ -267,7 +267,7 @@ public function it_can_scope_users_with_only_direct_permission()
User::all()->each(fn ($item) => $item->delete());
$user1 = User::create(['email' => '[email protected]']);
$user2 = User::create(['email' => '[email protected]']);
$user3 = User::create(['email' => '[email protected]']);
User::create(['email' => '[email protected]']);
$user1->givePermissionTo(['edit-news']);
$user2->givePermissionTo(['edit-articles', 'edit-news']);

Expand Down Expand Up @@ -810,7 +810,7 @@ public function it_can_check_permission_based_on_logged_in_user_guard()
#[Test]
public function it_can_reject_permission_based_on_logged_in_user_guard()
{
$unassignedPermission = app(Permission::class)::create([
app(Permission::class)::create([
'name' => 'do_that',
'guard_name' => 'api',
]);
Expand Down Expand Up @@ -859,7 +859,7 @@ public function it_does_not_fire_an_event_when_events_are_not_enabled()

$this->testUser->givePermissionTo(['edit-articles', 'edit-news']);

$ids = app(Permission::class)::whereIn('name', ['edit-articles', 'edit-news'])
app(Permission::class)::whereIn('name', ['edit-articles', 'edit-news'])
->pluck($this->testUserPermission->getKeyName())
->toArray();

Expand Down
8 changes: 4 additions & 4 deletions tests/HasRolesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ public function it_can_scope_a_role_using_enums()
{
$enum1 = TestModels\TestRolePermissionsEnum::USERMANAGER;
$enum2 = TestModels\TestRolePermissionsEnum::WRITER;
$role1 = app(Role::class)->findOrCreate($enum1->value, 'web');
$role2 = app(Role::class)->findOrCreate($enum2->value, 'web');
app(Role::class)->findOrCreate($enum1->value, 'web');
app(Role::class)->findOrCreate($enum2->value, 'web');

User::all()->each(fn ($item) => $item->delete());
$user1 = User::create(['email' => '[email protected]']);
User::create(['email' => '[email protected]']);
$user2 = User::create(['email' => '[email protected]']);
$user3 = User::create(['email' => '[email protected]']);
User::create(['email' => '[email protected]']);

// assign only one user to a role
$user2->assignRole($enum1);
Expand Down