Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Lloric Mayuga Garcia <[email protected]>
  • Loading branch information
lloricode committed Aug 11, 2024
1 parent d51b585 commit 55ae07d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tests/Fixture/Models/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

namespace Lloricode\FilamentSpatieLaravelPermissionPlugin\Tests\Fixture\Models;

class Permission extends \Lloricode\FilamentSpatieLaravelPermissionPlugin\Models\Permission {}
class Permission extends \Spatie\Permission\Models\Permission {}
2 changes: 1 addition & 1 deletion tests/Fixture/Models/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

namespace Lloricode\FilamentSpatieLaravelPermissionPlugin\Tests\Fixture\Models;

class Role extends \Lloricode\FilamentSpatieLaravelPermissionPlugin\Models\Role {}
class Role extends \Spatie\Permission\Models\Role {}
14 changes: 12 additions & 2 deletions tests/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
declare(strict_types=1);

use Illuminate\Database\Eloquent\Model;
use Lloricode\FilamentSpatieLaravelPermissionPlugin\Models\Role;
use Lloricode\FilamentSpatieLaravelPermissionPlugin\Tests\Fixture\UserFactory;
use Spatie\Permission\Contracts\Role as RoleContract;

Expand All @@ -12,12 +11,23 @@
function loginAsSuperAdmin()
{
$user = UserFactory::new()->createOne(['email' => '[email protected]']);
$user->assignRole(Role::superAdmin());
$user->assignRole(getSuperAdminRole());
actingAs($user);

return $user;
}

// get user admin role
function getSuperAdminRole(): RoleContract & Model
{
/** @var RoleContract&Model $role */
$role = app(RoleContract::class)->findByName(
name: config('filament-permission.roles.super_admin'),
);

return $role;
}

function createRole(string $name, ?string $guard = null): RoleContract & Model
{
/** @var RoleContract&Model $role */
Expand Down

0 comments on commit 55ae07d

Please sign in to comment.